summaryrefslogtreecommitdiffstats
path: root/lib/compat/vasprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compat/vasprintf.c')
-rw-r--r--lib/compat/vasprintf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/compat/vasprintf.c b/lib/compat/vasprintf.c
index 9d53a32..b5a2783 100644
--- a/lib/compat/vasprintf.c
+++ b/lib/compat/vasprintf.c
@@ -19,6 +19,8 @@
#include <config.h>
+#include <errno.h>
+#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -36,7 +38,9 @@ vasprintf(char **strp, char const *fmt, va_list args)
needed = vsnprintf(NULL, 0, fmt, args_copy);
va_end(args_copy);
- if (needed < 0) {
+ if (needed < 0 || needed >= INT_MAX) {
+ if (needed >= INT_MAX)
+ errno = EOVERFLOW;
*strp = NULL;
return -1;
}