Procházet zdrojové kódy

fix mishandling of ENOMEM return case in internal getgrent_a function

due to an incorrect return statement in this error case, the
previously blocked cancellation state was not restored and no result
was stored. this could lead to invalid (read) accesses in the caller
resulting in crashes or nonsensical result data in the event of memory
exhaustion.
Rich Felker před 10 roky
rodič
revize
58fa856960
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. 2 1
      src/passwd/getgrent_a.c

+ 2 - 1
src/passwd/getgrent_a.c

@@ -48,7 +48,8 @@ int __getgrent_a(FILE *f, struct group *gr, char **line, size_t *size, char ***m
 		rv = errno;
 		free(*line);
 		*line = 0;
-		return 0;
+		gr = 0;
+		goto end;
 	}
 	if (*mems) {
 		mem[0][0] = mems;