diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-07-28 21:49:24 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-07-28 21:49:24 +0200 |
commit | b17d0316dc51c254d503e7a095a5883f1848c7f6 (patch) | |
tree | c4e2d48ef8b5b245def5e8b2dac670d48a01a416 | |
parent | f5734c0a40cbb2e9362b6f2d3efb4a0453bf2dbc (diff) |
util, absuri: check truncation of more cases
-rw-r--r-- | util.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -80,6 +80,7 @@ absuri(const char *link, const char *base, char *buf, size_t bufsiz) struct uri ulink, ubase; char tmp[4096] = "", *p; int r = -1, c; + size_t i; buf[0] = '\0'; if (parseuri(base, &ubase, 0) == -1 || @@ -107,11 +108,14 @@ absuri(const char *link, const char *base, char *buf, size_t bufsiz) /* temporary null-terminate */ c = *(++p); *p = '\0'; - strlcat(tmp, ubase.path, sizeof(tmp)); + i = strlcat(tmp, ubase.path, sizeof(tmp)); *p = c; /* restore */ + if (i >= sizeof(tmp)) + return -1; } } else { - strlcat(tmp, ubase.path, sizeof(tmp)); + if (strlcat(tmp, ubase.path, sizeof(tmp)) >= sizeof(tmp)) + return -1; } } if (strlcat(tmp, ulink.path, sizeof(tmp)) >= sizeof(tmp)) |