diff options
author | 2017-03-14 16:46:05 +0000 | |
---|---|---|
committer | 2017-03-14 16:46:05 +0000 | |
commit | 327226135d5332449d5471b2002b4524f95811ff (patch) | |
tree | e11ee89bb3df370d24085693321c8234e3191db1 /lib/libc/stdio/vasprintf.c | |
parent | KNF spacing is more important than long lines (diff) | |
download | wireguard-openbsd-327226135d5332449d5471b2002b4524f95811ff.tar.xz wireguard-openbsd-327226135d5332449d5471b2002b4524f95811ff.zip |
Use a macro for the initial length of the buffer instead of 127; OK deraadt@
Diffstat (limited to 'lib/libc/stdio/vasprintf.c')
-rw-r--r-- | lib/libc/stdio/vasprintf.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/stdio/vasprintf.c b/lib/libc/stdio/vasprintf.c index 98cdb45549f..a5d08509963 100644 --- a/lib/libc/stdio/vasprintf.c +++ b/lib/libc/stdio/vasprintf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vasprintf.c,v 1.19 2015/12/28 22:08:18 mmcc Exp $ */ +/* $OpenBSD: vasprintf.c,v 1.20 2017/03/14 16:46:05 millert Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> @@ -22,6 +22,8 @@ #include <errno.h> #include "local.h" +#define INITIAL_LEN 127 /* plus one for the NUL */ + int vasprintf(char **str, const char *fmt, __va_list ap) { @@ -33,10 +35,10 @@ vasprintf(char **str, const char *fmt, __va_list ap) _FILEEXT_SETUP(&f, &fext); f._file = -1; f._flags = __SWR | __SSTR | __SALC; - f._bf._base = f._p = malloc(128); + f._bf._base = f._p = malloc(INITIAL_LEN + 1); if (f._bf._base == NULL) goto err; - f._bf._size = f._w = 127; /* Leave room for the NUL */ + f._bf._size = f._w = INITIAL_LEN; ret = __vfprintf(&f, fmt, ap); if (ret == -1) goto err; |