From c24278318f75ccd155b8575ad55f3135537088d8 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sat, 8 Aug 2015 00:44:59 +0200 Subject: sfeed: use snprintf -> strlcpy for some case --- sfeed.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sfeed.c b/sfeed.c index a05304b..045b1ad 100644 --- 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); -- cgit v1.2.3