summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-08-08 00:44:59 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-08-08 00:44:59 +0200
commitc24278318f75ccd155b8575ad55f3135537088d8 (patch)
tree137d40ba6660277d31c1fb730ec00d77fb557d73
parentaee6c97096e319b8a4d5a4744002bd0f18398fb2 (diff)
sfeed: use snprintf -> strlcpy for some case
-rw-r--r--sfeed.c7
1 files 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);