Skip to content

sprintf 缓冲区溢出风险 #70

Description

@helozht

位置:
so/dkapture.cpp:353
描述:
代码使用:
char pid_s[16];
sprintf(pid_s, "%d", pid);
sprintf() 不进行边界检查。
风险:
虽然常见 pid_t 值通常不会超过 16 字节输出,但该写法仍然存在缓冲区溢出风险。
建议修复:
使用 snprintf(pid_s, sizeof(pid_s), "%d", pid);
或直接使用更安全的格式化方式,避免未定义写入。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions