2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-11 15:40:58 +00:00

Merge pull request #1263 from m-holger/fuzz

Guard against 0 byte writes in Pl_Buffer and Pl_String
This commit is contained in:
m-holger 2024-08-08 01:09:15 +01:00 committed by GitHub
commit 0e9b9dab33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -19,6 +19,9 @@ Pl_Buffer::~Pl_Buffer() // NOLINT (modernize-use-equals-default)
void void
Pl_Buffer::write(unsigned char const* buf, size_t len) Pl_Buffer::write(unsigned char const* buf, size_t len)
{ {
if (!len) {
return;
}
m->data.append(reinterpret_cast<char const*>(buf), len); m->data.append(reinterpret_cast<char const*>(buf), len);
m->ready = false; m->ready = false;

View File

@ -21,6 +21,9 @@ Pl_String::~Pl_String() // NOLINT (modernize-use-equals-default)
void void
Pl_String::write(unsigned char const* buf, size_t len) Pl_String::write(unsigned char const* buf, size_t len)
{ {
if (!len) {
return;
}
m->s.append(reinterpret_cast<char const*>(buf), len); m->s.append(reinterpret_cast<char const*>(buf), len);
if (getNext(true)) { if (getNext(true)) {
getNext()->write(buf, len); getNext()->write(buf, len);