Commit 99b94ad7a7280ebcb23a103b28c81900bbe250ee

Omar Polo 2022-06-13T20:30:09

got patch: ensure new and old paths are NUL-terminated

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/lib/patch.c b/lib/patch.c
index 5567c9d..8555dfb 100644
--- a/lib/patch.c
+++ b/lib/patch.c
@@ -176,6 +176,12 @@ recv_patch(struct imsgbuf *ibuf, int *done, struct got_patch *p, int strip)
 	}
 	memcpy(&patch, imsg.data, sizeof(patch));
 
+	if (patch.old[sizeof(patch.old)-1] != '\0' ||
+	    patch.new[sizeof(patch.new)-1] != '\0') {
+		err = got_error(GOT_ERR_PRIVSEP_LEN);
+		goto done;
+	}
+
 	/* automatically set strip=1 for git-style diffs */
 	if (strip == -1 && patch.git &&
 	    (*patch.old == '\0' || !strncmp(patch.old, "a/", 2)) &&