Merge pull request #7118 from oliverchang/fix

Fixed a heap-buffer-overflow in the smart_pkt.c:set_data function.
This commit is contained in:
Edward Thomson
2026-04-29 20:15:04 +01:00
committed by GitHub

View File

@@ -238,13 +238,13 @@ static int set_data(
if (strncmp(caps, "object-format=", CONST_STRLEN("object-format=")) == 0)
format_str = caps + CONST_STRLEN("object-format=");
else if ((format_str = strstr(caps, " object-format=")) != NULL)
else if ((format_str = git__memmem(caps, len - (caps - line), " object-format=", CONST_STRLEN(" object-format="))) != NULL)
format_str += CONST_STRLEN(" object-format=");
}
if (format_str) {
if ((eos = strchr(format_str, ' ')) == NULL)
eos = strchr(format_str, '\0');
if ((eos = memchr(format_str, ' ', len - (format_str - line))) == NULL)
eos = memchr(format_str, '\0', len - (format_str - line));
GIT_ASSERT(eos);