diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/compat.c | 8 | ||||
-rw-r--r-- | common/path.c | 2 | ||||
-rw-r--r-- | common/url.c | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/common/compat.c b/common/compat.c index de5b99b..02e6408 100644 --- a/common/compat.c +++ b/common/compat.c @@ -41,6 +41,7 @@ #define _XOPEN_SOURCE 700 #include "compat.h" +#include "debug.h" #include <assert.h> #include <dirent.h> @@ -503,8 +504,11 @@ strconcat (const char *first, va_start (va, first); - for (arg = first; arg; arg = va_arg (va, const char*)) - length += strlen (arg); + for (arg = first; arg; arg = va_arg (va, const char*)) { + size_t old_length = length; + length += strlen (arg); + return_val_if_fail (length >= old_length, NULL); + } va_end (va); diff --git a/common/path.c b/common/path.c index 34c00cb..8b8b66c 100644 --- a/common/path.c +++ b/common/path.c @@ -214,7 +214,9 @@ p11_path_build (const char *path, len = 1; va_start (va, path); while (path != NULL) { + size_t old_len = len; len += strlen (path) + 1; + return_val_if_fail (len >= old_len, NULL); path = va_arg (va, const char *); } va_end (va); diff --git a/common/url.c b/common/url.c index 4b7e47b..884c584 100644 --- a/common/url.c +++ b/common/url.c @@ -71,7 +71,7 @@ p11_url_decode (const char *value, */ if (*value == '%') { value++; - if (value + 2 > end) { + if (end - value < 2) { free (result); return NULL; } |