Skip to content

Commit 1bc5b05

Browse files
committed
smart_pkt: do not accept callers passing in no line length
Right now, we simply ignore the `linelen` parameter of `git_pkt_parse_line` in case the caller passed in zero. But in fact, we never want to assume anything about the provided buffer length and always want the caller to pass in the available number of bytes. And in fact, checking all the callers, one can see that the funciton is never being called in case where the buffer length is zero, and thus we are safe to remove this check.
1 parent c05790a commit 1bc5b05

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/transports/smart_pkt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ int git_pkt_parse_line(
437437
}
438438

439439
/*
440-
* If we were given a buffer length, then make sure there is
441-
* enough in the buffer to satisfy this line
440+
* Make sure there is enough in the buffer to satisfy
441+
* this line.
442442
*/
443-
if (linelen > 0 && linelen < (size_t)len)
443+
if (linelen < len)
444444
return GIT_EBUFS;
445445

446446
/*

0 commit comments

Comments
 (0)