Commit 8a4f8535de4903dd333ad924bd7ff874afa741fa

Stefan Sperling 2021-12-27T05:19:52

fix NULL dereference in 'got clone' if server sends an empty pack file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/got/got.c b/got/got.c
index 2bf465e..9e4617d 100644
--- a/got/got.c
+++ b/got/got.c
@@ -1658,6 +1658,11 @@ cmd_clone(int argc, char *argv[])
 		goto done;
 	}
 
+	if (pack_hash == NULL) {
+		error = got_error_fmt(GOT_ERR_FETCH_FAILED, "%s",
+		    "server sent an empty pack file");
+		goto done;
+	}
 	error = got_object_id_str(&id_str, pack_hash);
 	if (error)
 		goto done;