From 02e6ba91e887bd11146a57185b223582f56f3f09 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 30 Sep 2002 20:39:56 +0000 Subject: Vodz' last_patch57: Hi, Erik. my_getpw(uid/gid) and applets used it have problem: if username for uid not found, applets can`t detect it (but code pessent). Also "%8ld " format is bad: spaces not required (applets have self format or spec format (tar applet) and overflow for "id" applet...) This problem also pressent in stable version. Patch for unstable in attach. --w vodz --- coreutils/id.c | 7 +++---- coreutils/logname.c | 3 +-- coreutils/whoami.c | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'coreutils') 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); diff --git a/coreutils/logname.c b/coreutils/logname.c index 0924b24..3e10fba 100644 --- a/coreutils/logname.c +++ b/coreutils/logname.c @@ -32,8 +32,7 @@ extern int logname_main(int argc, char **argv) if (argc > 1) show_usage(); - my_getpwuid(user, geteuid()); - if (*user) { + if (my_getpwuid(user, geteuid())) { puts(user); return EXIT_SUCCESS; } diff --git a/coreutils/whoami.c b/coreutils/whoami.c index c3b1140..a9d6ecf 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c @@ -35,8 +35,7 @@ extern int whoami_main(int argc, char **argv) if (argc > 1) show_usage(); - my_getpwuid(user, uid); - if (*user) { + if (my_getpwuid(user, uid)) { puts(user); return EXIT_SUCCESS; } -- cgit v1.1