diff options
author | Erik Aigner <aigner.erik@gmail.com> | 2019-02-20 15:30:11 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2019-02-21 08:48:05 +0100 |
commit | 014d49559acfe9351a3b1f77e9aa43513ce53c94 (patch) | |
tree | 19b2b93338f6e58bbcd474e336d084d68b401dc0 /AUTHORS | |
parent | 1a107fac0fc88a4d74b64ffc9ae2fd178ba631c0 (diff) | |
download | libgit2-014d49559acfe9351a3b1f77e9aa43513ce53c94.tar.gz |
apply: prevent OOB read when parsing source buffer
When parsing the patch image from a string, we split the string
by newlines to get a line-based view of it. To split, we use
`memchr` on the buffer and limit the buffer length by the
original length provided by the caller. This works just fine for
the first line, but for every subsequent line we need to actually
subtract the amount of bytes that we have already read.
The above issue can be easily triggered by having a source buffer
with at least two lines, where the second line does _not_ end in
a newline. Given a string "foo\nb", we have an original length of
five bytes. After having extracted the first line, we will point
to 'b' and again try to `memchr(p, '\n', 5)`, resulting in an
out-of-bounds read of four bytes.
Fix the issue by correctly subtracting the amount of bytes
already read.
Diffstat (limited to 'AUTHORS')
-rw-r--r-- | AUTHORS | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -23,6 +23,7 @@ Dmitry Kovega Emeric Fermas Emmanuel Rodriguez Eric Myhre +Erik Aigner Florian Forster Holger Weiss Ingmar Vanhassel |