Browse Source

Merge pull request #751 from c3h2-ctf/arguments

printbuf: do not allow invalid arguments
tags/json-c-0.16-20220414
Eric Hawicz GitHub 3 years ago
parent
commit
1491d92038
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      printbuf.c

+ 2
- 2
printbuf.c View File

@@ -91,7 +91,7 @@ static int printbuf_extend(struct printbuf *p, int min_size)
int printbuf_memappend(struct printbuf *p, const char *buf, int size)
{
/* Prevent signed integer overflows with large buffers. */
if (size > INT_MAX - p->bpos - 1)
if (size < 0 || size > INT_MAX - p->bpos - 1)
return -1;
if (p->size <= p->bpos + size + 1)
{
@@ -111,7 +111,7 @@ int printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len)
if (offset == -1)
offset = pb->bpos;
/* Prevent signed integer overflows with large buffers. */
if (len > INT_MAX - offset)
if (len < 0 || offset < -1 || len > INT_MAX - offset)
return -1;
size_needed = offset + len;
if (pb->size < size_needed)


Loading…
Cancel
Save