tCheck for INT_MAX in case of variable allocation. - rohrpost - A commandline mail client to change the world as we see it.
(HTM) git clone git://r-36.net/rohrpost
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit cc1288fba991ad4fe8b9d5fffe809565cb6c1585
(DIR) parent d9866b46a35ac8ebf46db2ecbf1b7d62b9f88407
(HTM) Author: Christoph Lohmann <20h@r-36.net>
Date: Sat, 24 Feb 2018 13:30:29 +0100
Check for INT_MAX in case of variable allocation.
Diffstat:
ind.c | 4 ++++
1 file changed, 4 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/ind.c b/ind.c
t@@ -15,6 +15,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
+#include <limits.h>
#include "ind.h"
t@@ -136,6 +137,9 @@ smprintf(char *fmt, ...)
len = vsnprintf(NULL, 0, fmt, fmtargs);
va_end(fmtargs);
+ if (len == INT_MAX)
+ return NULL;
+
va_start(fmtargs, fmt);
ret = vsmprintf(fmt, fmtargs, len);
va_end(fmtargs);