Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

security: fix sscanf rv checks (CodeQL) #6184

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/firejail/restrict_users.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ static void sanitize_passwd(void) {
goto errout;

// process uid
int uid;
int uid = -1;
int rv = sscanf(ptr, "%d:", &uid);
if (rv == 0 || uid < 0)
if (rv != 1 || uid < 0)
goto errout;
assert(uid_min);
if (uid < uid_min || uid == 65534) { // on Debian platforms user nobody is 65534
Expand Down Expand Up @@ -349,9 +349,9 @@ static void sanitize_group(void) {
goto errout;

// process uid
int gid;
int gid = -1;
int rv = sscanf(ptr, "%d:", &gid);
if (rv == 0 || gid < 0)
if (rv != 1 || gid < 0)
goto errout;
assert(gid_min);
if (gid < gid_min || gid == 65534) { // on Debian platforms 65534 is group nogroup
Expand Down
Loading