Browse Source

Grow buffers using recallocarray, to avoid the potential dribble that

the standard realloc*() functions can leave behind.  imsg buffers are
sometimes used in protocol stacks which require some secrecy, and layering
violations would be needed to resolve this issue otherwise.
Discussed with many.
OPENBSD_6_1
deraadt 7 years ago
parent
commit
a6614e5870
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/lib/libutil/imsg-buffer.c

+ 2
- 2
src/lib/libutil/imsg-buffer.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: imsg-buffer.c,v 1.8 2015/12/29 18:05:01 benno Exp $ */
/* $OpenBSD: imsg-buffer.c,v 1.9 2017/03/17 14:51:26 deraadt Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -78,7 +78,7 @@ ibuf_realloc(struct ibuf *buf, size_t len)
return (-1);
}
b = realloc(buf->buf, buf->wpos + len);
b = recallocarray(buf->buf, buf->size, buf->wpos + len, 1);
if (b == NULL)
return (-1);
buf->buf = b;


Loading…
Cancel
Save