sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit b17d0316dc51c254d503e7a095a5883f1848c7f6
parent f5734c0a40cbb2e9362b6f2d3efb4a0453bf2dbc
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue, 28 Jul 2015 21:49:24 +0200

util, absuri: check truncation of more cases

Diffstat:
Mutil.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git 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))