sfeed

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

commit d9c62a32df99cc602b95bff5eebae430c0de2e02
parent 1f7beb9181acf0f18d37449bb209e92a12572015
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri,  2 Jan 2015 20:29:31 +0100

sfeed: fix incorrect strlcpy, style and strict check for buf

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

diff --git a/sfeed.c b/sfeed.c @@ -309,7 +309,8 @@ gettimetz(const char *s, char *buf, size_t bufsiz) unsigned int i; char c; - buf[0] = '\0'; + if(buf && bufsiz > 0) + buf[0] = '\0'; if(bufsiz < sizeof(tzname) + STRSIZ(" -00:00")) return 0; for(; *p && isspace((int)*p); p++); /* skip whitespace */ @@ -319,7 +320,7 @@ gettimetz(const char *s, char *buf, size_t bufsiz) /* TODO: cleanup / simplify */ if(isalpha((int)*p)) { if(*p == 'Z' || *p == 'z') { - strlcpy(buf, "GMT+00:00", sizeof(buf)); + strlcpy(buf, "GMT+00:00", bufsiz); return 0; } else { for(i = 0, t = &tzname[0]; i < (sizeof(tzname) - 1) && @@ -333,8 +334,10 @@ gettimetz(const char *s, char *buf, size_t bufsiz) strlcpy(buf, tzname, bufsiz); return 0; } - if((sscanf(p, "%c%02d:%02d", &c, &tzhour, &tzmin)) > 0); - else if(sscanf(p, "%c%02d%02d", &c, &tzhour, &tzmin) > 0); + if((sscanf(p, "%c%02d:%02d", &c, &tzhour, &tzmin)) > 0) + ; + else if(sscanf(p, "%c%02d%02d", &c, &tzhour, &tzmin) > 0) + ; else if(sscanf(p, "%c%d", &c, &tzhour) > 0) tzmin = 0; snprintf(buf, bufsiz, "%s%c%02d%02d", tzname, c, tzhour, tzmin);