diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-08-08 00:44:59 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-08-08 00:44:59 +0200 |
commit | c24278318f75ccd155b8575ad55f3135537088d8 (patch) | |
tree | 137d40ba6660277d31c1fb730ec00d77fb557d73 | |
parent | aee6c97096e319b8a4d5a4744002bd0f18398fb2 (diff) |
sfeed: use snprintf -> strlcpy for some case
-rw-r--r-- | sfeed.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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); |