diff options
author | Russell Belfer <rb@github.com> | 2014-05-08 10:17:14 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-05-08 10:17:14 -0700 |
commit | 1e4976cb015bd10a2a8c377e02801306473afc26 (patch) | |
tree | 73cde51de2a436cdffa825b155c6888df41671bd /src/pack-objects.c | |
parent | ed476c236b8328c31acb150ee69eaf00c821b9e3 (diff) | |
download | libgit2-1e4976cb015bd10a2a8c377e02801306473afc26.tar.gz |
Be more careful with user-supplied buffersrb/fix-2333
This adds in missing calls to `git_buf_sanitize` and fixes a
number of places where `git_buf` APIs could inadvertently write
NUL terminator bytes into invalid buffers. This also changes the
behavior of `git_buf_sanitize` to NUL terminate a buffer if it can
and of `git_buf_shorten` to do nothing if it can.
Adds tests of filtering code with zeroed (i.e. unsanitized) buffer
which was previously triggering a segfault.
Diffstat (limited to 'src/pack-objects.c')
-rw-r--r-- | src/pack-objects.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/pack-objects.c b/src/pack-objects.c index ace8afd17..b50338578 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -1276,6 +1276,7 @@ int git_packbuilder_foreach(git_packbuilder *pb, int (*cb)(void *buf, size_t siz int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb) { PREPARE_PACK; + git_buf_sanitize(buf); return write_pack(pb, &write_pack_buf, buf); } |