diff options
Diffstat (limited to 'coreutils/id.c')
-rw-r--r-- | coreutils/id.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/coreutils/id.c b/coreutils/id.c index 85b288c..c7f6153 100644 --- a/coreutils/id.c +++ b/coreutils/id.c @@ -68,8 +68,7 @@ extern int id_main(int argc, char **argv) my_getgrgid(group, getegid()); } } else { - strncpy(user, argv[optind], 8); - user[8] = '\0'; + safe_strncpy(user, argv[optind], sizeof(user)); gid = my_getpwnamegid(user); my_getgrgid(group, gid); } @@ -78,12 +77,12 @@ extern int id_main(int argc, char **argv) grnam=my_getgrnam(group); if (no_group) { - if(name_not_number && user) + if(name_not_number) puts(user); else printf("%ld\n", pwnam); } else if (no_user) { - if(name_not_number && group) + if(name_not_number) puts(group); else printf("%ld\n", grnam); |