From d14278c71c190ee93f3a8fbe0db5fe9f64fcee24 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 23 Apr 2014 21:06:41 +0000 Subject: Audit malloc(3)/calloc(3)/realloc(3) usage. * Change eight reallocs to reallocarray to be safe from overflows. * Change one malloc to reallocarray to be safe from overflows. * Change one calloc to reallocarray, no zeroing needed. * Change the order of arguments of three callocs (aesthetical). --- mandoc_aux.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mandoc_aux.c') diff --git a/mandoc_aux.c b/mandoc_aux.c index 297fc199..f01e02e7 100644 --- a/mandoc_aux.c +++ b/mandoc_aux.c @@ -80,6 +80,18 @@ mandoc_realloc(void *ptr, size_t size) return(ptr); } +void * +mandoc_reallocarray(void *ptr, size_t num, size_t size) +{ + + ptr = reallocarray(ptr, num, size); + if (NULL == ptr) { + perror(NULL); + exit((int)MANDOCLEVEL_SYSERR); + } + return(ptr); +} + char * mandoc_strdup(const char *ptr) { -- cgit