projects
/
systemd
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0fa25bd
)
socket-util: check for sysconf() error before using value
author
Luca Boccassi
<bluca@debian.org>
Tue, 30 Jan 2024 12:16:26 +0000
(12:16 +0000)
committer
Luca Boccassi
<luca.boccassi@gmail.com>
Tue, 30 Jan 2024 15:19:16 +0000
(15:19 +0000)
Otherwise -1 will be casted to uint32_t. Found by coverity.
CID#
1533989
Follow-up for
7e8aa5c2eebd86efe9bbf36d8db1e98964611aab
src/basic/socket-util.c
patch
|
blob
|
history
diff --git
a/src/basic/socket-util.c
b/src/basic/socket-util.c
index a9ad1cc9936e7d9ff0d95503d6585ff5f96a3936..68e6afc67fc162de913d66d5d668ab29288e20a4 100644
(file)
--- a/
src/basic/socket-util.c
+++ b/
src/basic/socket-util.c
@@
-930,13
+930,15
@@
int getpeersec(int fd, char **ret) {
}
int getpeergroups(int fd, gid_t **ret) {
+ socklen_t n = sizeof(gid_t) * 64U;
_cleanup_free_ gid_t *d = NULL;
assert(fd >= 0);
assert(ret);
long ngroups_max = sysconf(_SC_NGROUPS_MAX);
- socklen_t n = sizeof(gid_t) * MAX((socklen_t) ngroups_max, 64U);
+ if (ngroups_max > 0)
+ n = MAX(n, sizeof(gid_t) * (socklen_t) ngroups_max);
for (;;) {
d = malloc(n);