user-record: Handle invalid uid/gid case

I'm not that familiar with outer code to guide Coverity with an
assert(), so consider invalid uid/gid as non-matching in order to avoid
-EINVAL for bit shifts calculation.

Fixes: CID#1590746
This commit is contained in:
Michal Koutný
2025-03-03 19:14:56 +01:00
parent 1644724a4d
commit 5eceb5a7a2
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -350,6 +350,9 @@ int group_record_match(GroupRecord *h, const UserDBMatch *match) {
if (!match)
return true;
if (!gid_is_valid(h->gid))
return false;
if (h->gid < match->gid_min || h->gid > match->gid_max)
return false;
+3
View File
@@ -2775,6 +2775,9 @@ int user_record_match(UserRecord *u, const UserDBMatch *match) {
if (!match)
return true;
if (!uid_is_valid(u->uid))
return false;
if (u->uid < match->uid_min || u->uid > match->uid_max)
return false;