We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fc7479f commit 0e769ccCopy full SHA for 0e769cc
su.c
@@ -369,7 +369,16 @@ int main(int argc, char *argv[])
369
struct passwd *pw;
370
pw = getpwnam(argv[optind]);
371
if (!pw) {
372
- su_to.uid = atoi(argv[optind]);
+ char *endptr;
373
+
374
+ /* It seems we shouldn't do this at all */
375
+ errno = 0;
376
+ su_to.uid = strtoul(argv[optind], &endptr, 10);
377
+ if (errno || *endptr) {
378
+ LOGE("Unknown id: %s\n", argv[optind]);
379
+ fprintf(stderr, "Unknown id: %s\n", argv[optind]);
380
+ exit(EXIT_FAILURE);
381
+ }
382
} else {
383
su_to.uid = pw->pw_uid;
384
}
0 commit comments