Skip to content

C ++安全指南.md 修改建议 #63

Description

@code1w

// Bad
char a[4] = {0};
_snprintf(a, 4, "%s", "AAAA");
foo = strlen(a);

上述代码在MSVC中执行后, a[4] == 'A',因此字符串未以0结尾。

这里的a[4]== 'A' 应该改成a[3]=='A'

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