now uses MAX_UID_T_LEN

This commit is contained in:
Todd C. Miller
1995-07-23 21:48:30 +00:00
parent 2ff580d88a
commit e70f526da5

9
sudo.c
View File

@@ -737,21 +737,16 @@ void set_perms(perm)
static char *uid2str(uid)
uid_t uid;
{
int len;
unsigned n;
char *uidstr;
for (len = 1, n = (unsigned) uid; (unsigned) (n = n / 10) != 0; )
++len;
uidstr = (char *) malloc(len+1);
uidstr = (char *) malloc(MAX_UID_T_LEN + 1);
if (uidstr == NULL) {
perror("malloc");
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
exit(1);
}
(void) sprintf(uidstr, "%u", (unsigned) uid);
(void) sprintf(uidstr, "%ld", uid);
return(uidstr);
}