diff options
author | Patrick Steinhardt <ps@pks.im> | 2018-10-03 16:17:21 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2018-10-03 16:17:21 +0200 |
commit | 1bc5b05c614c7b10de021fa392943e8e6bd12c77 (patch) | |
tree | 0156c79574ae5af8653e79ad4c5b4a1ed8597ca1 | |
parent | c05790a8a8dd4351e61fc06c0a06c6a6fb6134dc (diff) | |
download | libgit2-1bc5b05c614c7b10de021fa392943e8e6bd12c77.tar.gz |
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.
-rw-r--r-- | src/transports/smart_pkt.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/transports/smart_pkt.c b/src/transports/smart_pkt.c index 4a5e71c3b..6a404efe4 100644 --- a/src/transports/smart_pkt.c +++ b/src/transports/smart_pkt.c @@ -437,10 +437,10 @@ int git_pkt_parse_line( } /* - * If we were given a buffer length, then make sure there is - * enough in the buffer to satisfy this line + * Make sure there is enough in the buffer to satisfy + * this line. */ - if (linelen > 0 && linelen < (size_t)len) + if (linelen < len) return GIT_EBUFS; /* |