Skip to content

Commit 437ee5a

Browse files
committed
Verify ref_pkt's are long enough
If the remote sends a too-short packet, we'll allow `len` to go negative and eventually issue a malloc for <= 0 bytes on ``` pkt->head.name = git__malloc(alloclen); ```
1 parent e212011 commit 437ee5a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/transports/smart_pkt.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len)
216216
git_pkt_ref *pkt;
217217
size_t alloclen;
218218

219+
if (len < GIT_OID_HEXSZ + 1) {
220+
giterr_set(GITERR_NET, "error parsing pkt-line");
221+
return -1;
222+
}
223+
219224
pkt = git__malloc(sizeof(git_pkt_ref));
220225
GITERR_CHECK_ALLOC(pkt);
221226

0 commit comments

Comments
 (0)