"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
leak in got_fetch_pack
To:
gameoftrees@openbsd.org
Date:
Sun, 13 Feb 2022 21:33:38 +0100

Download raw body.

Thread
Hello,

while studying a bit the code that wraps the various libexec helpers, I
stumbled across this.  fetchibuf is local to the function and it doesn't
seem to be used afterwards, same for imsg_fetchfds.  regress with the
following diff passes, and I've also fetched from a couple of
repositories successfully.

(the imsg_clear call is possibly useless if there aren't any pending
messages enqueued, but I thought that it reads better; I can drop it)


diff 32b5305fbed2d1a4c55b0eef6b93349b93ba7db0 /home/op/w/got-fetch-leak
blob - 6c0dbf4a0ba8148e5f95f882f51bda4b71ebc4f1
file + lib/fetch.c
--- lib/fetch.c
+++ lib/fetch.c
@@ -353,6 +353,11 @@ got_fetch_pack(struct got_object_id **pack_hash, struc
 			packfile_size = packfile_size_cur;
 		}
 	}
+	imsg_clear(&fetchibuf);
+	if (close(imsg_fetchfds[0]) == -1) {
+		err = got_error_from_errno("close");
+		goto done;
+	}
 	if (waitpid(fetchpid, &fetchstatus, 0) == -1) {
 		err = got_error_from_errno("waitpid");
 		goto done;