summaryrefslogtreecommitdiff
path: root/coreutils/id.c
diff options
context:
space:
mode:
authorEric Andersen2000-12-13 01:52:39 +0000
committerEric Andersen2000-12-13 01:52:39 +0000
commitbd193a42a5624f0a72b5f99d554e9a8d2afc64cc (patch)
tree7aacebe98730fbfee623943425a100fd158ba48a /coreutils/id.c
parent77508b29fa63d99136fc09f00c5a2addd6331b4c (diff)
downloadbusybox-bd193a42a5624f0a72b5f99d554e9a8d2afc64cc.zip
busybox-bd193a42a5624f0a72b5f99d554e9a8d2afc64cc.tar.gz
Fix from Matt Kraai -- a better way to NULL terminate strings for the
my_* passwd and group routines. I should have thought of doing it this way...
Diffstat (limited to 'coreutils/id.c')
-rw-r--r--coreutils/id.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/coreutils/id.c b/coreutils/id.c
index 86667f5..3a8e77a 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -31,12 +31,11 @@
extern int id_main(int argc, char **argv)
{
int no_user = 0, no_group = 0, print_real = 0;
- char *cp, *user, *group;
+ char user[9], group[9];
long gid;
long pwnam, grnam;
int opt;
- cp = user = group = NULL;
gid = 0;
while ((opt = getopt(argc, argv, "ugr")) > 0) {
@@ -57,11 +56,7 @@ extern int id_main(int argc, char **argv)
if (no_user && no_group) usage(id_usage);
- user = argv[optind];
-
- if (user == NULL) {
- user = xcalloc(9, sizeof(char));
- group = xcalloc(9, sizeof(char));
+ if (argv[optind] == NULL) {
if (print_real) {
my_getpwuid(user, getuid());
my_getgrgid(group, getgid());
@@ -70,7 +65,8 @@ extern int id_main(int argc, char **argv)
my_getgrgid(group, getegid());
}
} else {
- group = xcalloc(9, sizeof(char));
+ strncpy(user, argv[optind], 8);
+ user[8] = '\0';
gid = my_getpwnamegid(user);
my_getgrgid(group, gid);
}