1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
From: Jakub Wilk <jwilk@debian.org>
Date: Mon, 12 Aug 2019 23:29:30 +0000
Subject: improve error handling in the which() function
Forwarded: yes
Last-Update: 2014-02-06
---
which.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/which.c b/which.c
index 2bd4a08..48f47e9 100644
--- a/which.c
+++ b/which.c
@@ -109,7 +109,11 @@ extern char *which(char *name, bool verbose) {
#endif
if (ngroups) {
gidset = ealloc(ngroups * sizeof(GETGROUPS_T));
- getgroups(ngroups, gidset);
+ ngroups = getgroups(ngroups, gidset);
+ if (ngroups < 0) {
+ uerror("getgroups");
+ rc_exit(1);
+ }
}
#endif
}
|