sfeed

Simple RSS and Atom feed parser
git clone https://git.sinitax.com/codemadness/sfeed
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit c24278318f75ccd155b8575ad55f3135537088d8
parent aee6c97096e319b8a4d5a4744002bd0f18398fb2
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat,  8 Aug 2015 00:44:59 +0200

sfeed: use snprintf -> strlcpy for some case

Diffstat:
Msfeed.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sfeed.c b/sfeed.c @@ -279,15 +279,16 @@ gettimetz(const char *s, char *buf, size_t bufsiz, int *tzoffset) time_ok: /* timezone set but non-match */ if (tzbuf[0] && !tz[0]) { - r = snprintf(buf, bufsiz, "%s", tzbuf); + if (strlcpy(buf, tzbuf, bufsiz) >= bufsiz) + return -1; /* truncation */ tzhour = tzmin = 0; c = '+'; } else { r = snprintf(buf, bufsiz, "%s%c%02d:%02d", tz[0] ? tz : "UTC", c, tzhour, tzmin); + if (r < 0 || (size_t)r >= bufsiz) + return -1; /* truncation or error */ } - if (r < 0 || (size_t)r >= bufsiz) - return -1; /* truncation or error */ if (tzoffset) *tzoffset = ((tzhour * 3600) + (tzmin * 60)) * (c == '-' ? -1 : 1);