Skip to content

Commit d298b02

Browse files
committed
transport: safely handle messages with no caps
If there are no caps, don't try to advance past the first NULL to look for object-format. This prevents a possible out-of-bounds read.
1 parent a2bde63 commit d298b02

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libgit2/transports/smart_pkt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ static int set_data(
232232

233233
GIT_ASSERT_ARG(data);
234234

235-
if ((caps = memchr(line, '\0', len)) != NULL) {
235+
if ((caps = memchr(line, '\0', len)) != NULL &&
236+
len > (size_t)((caps - line) + 1)) {
236237
caps++;
237238

238239
if (strncmp(caps, "object-format=", CONST_STRLEN("object-format=")) == 0)

0 commit comments

Comments
 (0)