summaryrefslogtreecommitdiff
path: root/coreutils/id.c
diff options
context:
space:
mode:
authorEric Andersen2002-09-30 20:39:56 +0000
committerEric Andersen2002-09-30 20:39:56 +0000
commit02e6ba91e887bd11146a57185b223582f56f3f09 (patch)
treecc1954165fe7e6efed1ba0dfa7d5c3aea97fffa5 /coreutils/id.c
parenta6f6e06107e69b79858acaa511c452a0a73cf207 (diff)
downloadbusybox-02e6ba91e887bd11146a57185b223582f56f3f09.zip
busybox-02e6ba91e887bd11146a57185b223582f56f3f09.tar.gz
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
Diffstat (limited to 'coreutils/id.c')
-rw-r--r--coreutils/id.c7
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);