commit: 226efce255762325c4575f1ad42143ecd1d395ae
parent f5d3de45fe20ecf2c1fe97587b89c83ef2a20469
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 23 Sep 2024 05:15:35 +0200
cmd/id: make sure calloc isn't passed zero (or-negative)
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/cmd/id.c b/cmd/id.c
@@ -166,6 +166,11 @@ main(int argc, char *argv[])
 
 	int ngroups = 0;
 	int ngroups_max = (int)sysconf(_SC_NGROUPS_MAX) + 1;
+	if(ngroups_max <= 0)
+	{
+		perror("id: error: sysconf(_SC_NGROUPS_MAX)");
+		return 1;
+	}
 	gid_t *groups = NULL;
 	groups = calloc(ngroups_max, sizeof(*groups));
 	if(groups == NULL)