diff options
author | Nikolaus Rath <Nikolaus@rath.org> | 2018-05-11 14:56:45 +0100 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2018-05-11 15:01:04 +0100 |
commit | 44deb68ce1259e1c5c79de7c5d4b2b05d07cf82d (patch) | |
tree | f4119898ee6f79f143ee9f8c9f87a8fe7120d9bf | |
parent | 27a112e86dba7c8d47f2d77ae002b3954ef53116 (diff) |
add_arg(): check for overflow
Fixes: #222.
-rw-r--r-- | util/mount.fuse.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/util/mount.fuse.c b/util/mount.fuse.c index 3f498db..169fe53 100644 --- a/util/mount.fuse.c +++ b/util/mount.fuse.c @@ -13,6 +13,7 @@ #include <string.h> #include <unistd.h> #include <errno.h> +#include <stdint.h> static char *progname; @@ -40,6 +41,10 @@ static void add_arg(char **cmdp, const char *opt) { size_t optlen = strlen(opt); size_t cmdlen = *cmdp ? strlen(*cmdp) : 0; + if (optlen >= (SIZE_MAX - cmdlen - 4)/4) { + fprintf(stderr, "%s: argument too long\n", progname); + exit(1); + } char *cmd = xrealloc(*cmdp, cmdlen + optlen * 4 + 4); char *s; s = cmd + cmdlen; |