now uses MAX_UID_T_LEN
This commit is contained in:
9
sudo.c
9
sudo.c
@@ -737,21 +737,16 @@ void set_perms(perm)
|
|||||||
static char *uid2str(uid)
|
static char *uid2str(uid)
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
{
|
{
|
||||||
int len;
|
|
||||||
unsigned n;
|
|
||||||
char *uidstr;
|
char *uidstr;
|
||||||
|
|
||||||
for (len = 1, n = (unsigned) uid; (unsigned) (n = n / 10) != 0; )
|
uidstr = (char *) malloc(MAX_UID_T_LEN + 1);
|
||||||
++len;
|
|
||||||
|
|
||||||
uidstr = (char *) malloc(len+1);
|
|
||||||
if (uidstr == NULL) {
|
if (uidstr == NULL) {
|
||||||
perror("malloc");
|
perror("malloc");
|
||||||
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
|
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) sprintf(uidstr, "%u", (unsigned) uid);
|
(void) sprintf(uidstr, "%ld", uid);
|
||||||
|
|
||||||
return(uidstr);
|
return(uidstr);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user