File: 0001-which-error-handling.patch

package info (click to toggle)
rc 1.7.4%2B97.gceb59bb-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 800 kB
  • sloc: ansic: 7,965; yacc: 136; sh: 133; makefile: 49; perl: 25; sed: 5
file content (27 lines) | stat: -rw-r--r-- 642 bytes parent folder | download | duplicates (3)
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
 	}