mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
Fixed scanf format errors. The error handling is not quite bug for bug
compatible. I think small negative uids are handled compatibly but other out of bounds ones are truncated differently for certain sizes of uid_t.
This commit is contained in:
parent
c6966b0c4a
commit
2a29b52b98
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37300
@ -76,6 +76,7 @@ netname2user(netname, uidp, gidp, gidlenp, gidlist)
|
|||||||
char *p;
|
char *p;
|
||||||
int gidlen;
|
int gidlen;
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
|
long luid;
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
char val[1024];
|
char val[1024];
|
||||||
char *val1, *val2;
|
char *val1, *val2;
|
||||||
@ -126,14 +127,10 @@ netname2user(netname, uidp, gidp, gidlenp, gidlist)
|
|||||||
if (strcmp(val2 + 1, domain))
|
if (strcmp(val2 + 1, domain))
|
||||||
return (0); /* wrong domain */
|
return (0); /* wrong domain */
|
||||||
|
|
||||||
/* XXX: uid_t have different sizes on different OS's. sigh! */
|
if (sscanf(val, "%ld", &luid) != 1)
|
||||||
if (sizeof (uid_t) == sizeof (short)) {
|
|
||||||
if (sscanf(val, "%hd", (short *)&uid) != 1)
|
|
||||||
return (0);
|
|
||||||
} else {
|
|
||||||
if (sscanf(val, "%ld", &uid) != 1)
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
uid = luid;
|
||||||
|
|
||||||
/* use initgroups method */
|
/* use initgroups method */
|
||||||
pwd = getpwuid(uid);
|
pwd = getpwuid(uid);
|
||||||
if (pwd == NULL)
|
if (pwd == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user