summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-07-28 21:49:24 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-07-28 21:49:24 +0200
commitb17d0316dc51c254d503e7a095a5883f1848c7f6 (patch)
treec4e2d48ef8b5b245def5e8b2dac670d48a01a416
parentf5734c0a40cbb2e9362b6f2d3efb4a0453bf2dbc (diff)
util, absuri: check truncation of more cases
-rw-r--r--util.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/util.c b/util.c
index 8e7b744..cce6ef3 100644
--- a/util.c
+++ b/util.c
@@ -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))