Commit 0e9b9dab33734f1598fc9617b94cf518ef9f1230
Committed by
GitHub
Merge pull request #1263 from m-holger/fuzz
Guard against 0 byte writes in Pl_Buffer and Pl_String
Showing
2 changed files
with
6 additions
and
0 deletions
libqpdf/Pl_Buffer.cc
| ... | ... | @@ -19,6 +19,9 @@ Pl_Buffer::~Pl_Buffer() // NOLINT (modernize-use-equals-default) |
| 19 | 19 | void |
| 20 | 20 | Pl_Buffer::write(unsigned char const* buf, size_t len) |
| 21 | 21 | { |
| 22 | + if (!len) { | |
| 23 | + return; | |
| 24 | + } | |
| 22 | 25 | m->data.append(reinterpret_cast<char const*>(buf), len); |
| 23 | 26 | m->ready = false; |
| 24 | 27 | ... | ... |
libqpdf/Pl_String.cc
| ... | ... | @@ -21,6 +21,9 @@ Pl_String::~Pl_String() // NOLINT (modernize-use-equals-default) |
| 21 | 21 | void |
| 22 | 22 | Pl_String::write(unsigned char const* buf, size_t len) |
| 23 | 23 | { |
| 24 | + if (!len) { | |
| 25 | + return; | |
| 26 | + } | |
| 24 | 27 | m->s.append(reinterpret_cast<char const*>(buf), len); |
| 25 | 28 | if (getNext(true)) { |
| 26 | 29 | getNext()->write(buf, len); | ... | ... |