summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorKen Smith <kensmith@FreeBSD.org>2009-07-22 20:46:17 +0000
committerKen Smith <kensmith@FreeBSD.org>2009-07-22 20:46:17 +0000
commit1a8db5b2127d43a49d986fb97b62bd51db655b10 (patch)
tree79d8dcb23e1c7b4d4278a7e85c9cf76c8b4a9c2f /libc
parent6e4f22c83ba4231d78dad1c8aff9c65c936d3750 (diff)
downloadpw-darwin-1a8db5b2127d43a49d986fb97b62bd51db655b10.tar.gz
pw-darwin-1a8db5b2127d43a49d986fb97b62bd51db655b10.tar.zst
pw-darwin-1a8db5b2127d43a49d986fb97b62bd51db655b10.zip
It is believed the last subsystem that limited ID sizes to something
other than the current system-wide size (32-bits) has been updated so for now just cautiously turn the check off. While here fix the check for IDs being too large which doesn't work due to type mis-matches. Reviewed by: jhb (previous version) Approved by: re (kib) MFC after: 1 month (type mis-match fixes only)
Diffstat (limited to 'libc')
-rw-r--r--libc/gen/pw_scan.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/libc/gen/pw_scan.c b/libc/gen/pw_scan.c
index 9242dd0..24e8225 100644
--- a/libc/gen/pw_scan.c
+++ b/libc/gen/pw_scan.c
@@ -58,8 +58,14 @@ __FBSDID("$FreeBSD$");
*
* If pw_big_ids_warning is -1 on entry to pw_scan(), it will be set based
* on the existence of PW_SCAN_BIG_IDS in the environment.
+ *
+ * It is believed all baseline system software that can not handle the
+ * normal ID sizes is now gone so pw_big_ids_warning is disabled for now.
+ * But the code has been left in place in case end-users want to re-enable
+ * it and/or for the next time the ID sizes get bigger but pieces of the
+ * system lag behind.
*/
-static int pw_big_ids_warning = -1;
+static int pw_big_ids_warning = 0;
int
__pw_scan(char *bp, struct passwd *pw, int flags)
@@ -67,6 +73,7 @@ __pw_scan(char *bp, struct passwd *pw, int flags)
uid_t id;
int root;
char *ep, *p, *sh;
+ unsigned long temp;
if (pw_big_ids_warning == -1)
pw_big_ids_warning = getenv("PW_SCAN_BIG_IDS") == NULL ? 1 : 0;
@@ -94,12 +101,14 @@ __pw_scan(char *bp, struct passwd *pw, int flags)
return (0);
}
}
- id = strtoul(p, &ep, 10);
- if (errno == ERANGE) {
+ errno = 0;
+ temp = strtoul(p, &ep, 10);
+ if ((temp == ULONG_MAX && errno == ERANGE) || temp > UID_MAX) {
if (flags & _PWSCAN_WARN)
- warnx("%s > max uid value (%lu)", p, ULONG_MAX);
+ warnx("%s > max uid value (%u)", p, UID_MAX);
return (0);
}
+ id = temp;
if (*ep != '\0') {
if (flags & _PWSCAN_WARN)
warnx("%s uid is incorrect", p);
@@ -127,12 +136,14 @@ __pw_scan(char *bp, struct passwd *pw, int flags)
return (0);
}
}
- id = strtoul(p, &ep, 10);
- if (errno == ERANGE) {
+ errno = 0;
+ temp = strtoul(p, &ep, 10);
+ if ((temp == ULONG_MAX && errno == ERANGE) || temp > GID_MAX) {
if (flags & _PWSCAN_WARN)
- warnx("%s > max gid value (%lu)", p, ULONG_MAX);
+ warnx("%s > max gid value (%u)", p, GID_MAX);
return (0);
}
+ id = temp;
if (*ep != '\0') {
if (flags & _PWSCAN_WARN)
warnx("%s gid is incorrect", p);