pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
sfeed: Address more ctype(3) UBs
Module Name: pkgsrc-wip
Committed By: Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By: leot
Date: Fri Sep 7 18:18:05 2018 +0200
Changeset: 89f53cb8da228d9fe03c6de7789965ad1ce28528
Modified Files:
sfeed/distinfo
sfeed/patches/patch-sfeed.c
Log Message:
sfeed: Address more ctype(3) UBs
Now sfeed should no longer "eat" UTF-8 characters.
(This was accidentally previously not committed because the patches
was applied manually in the WRKSRC... but of course applying more
than a patch overwrite the `.orig'!, Whoops!)
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=89f53cb8da228d9fe03c6de7789965ad1ce28528
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
sfeed/distinfo | 2 +-
sfeed/patches/patch-sfeed.c | 137 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 136 insertions(+), 3 deletions(-)
diffs:
diff --git a/sfeed/distinfo b/sfeed/distinfo
index be653000f9..662f47ffc2 100644
--- a/sfeed/distinfo
+++ b/sfeed/distinfo
@@ -4,7 +4,7 @@ SHA1 (sfeed-0.9.5.tar.gz) = 6de7b76ec357c7f6d5289e88a842924cb95e7846
RMD160 (sfeed-0.9.5.tar.gz) = 349e363785877c0a0a9879038746085de797dbf7
SHA512 (sfeed-0.9.5.tar.gz) = f9c667632fb86395588a7917bb92c48e82768021c54595db8cd5e8bbaf043def2678f54f77cbbb7c8d673eff04d5f99d00d1c244b1089d7b77f4e23e8fa3e079
Size (sfeed-0.9.5.tar.gz) = 37374 bytes
-SHA1 (patch-sfeed.c) = 6ff9e8e7d8ab061fce5aa603008a4ec338bfdbb9
+SHA1 (patch-sfeed.c) = 7239a85c8c8a1fd207d2a8386d691c09b3b8cc4f
SHA1 (patch-sfeed__opml__import.c) = f4870e075cf2675cfa6a104ecd594e7b373537e2
SHA1 (patch-sfeed__web.c) = 361c9b985e8610bedf35176147c3b8c9511233ce
SHA1 (patch-sfeed__xmlenc.c) = 2476f0f4ff215a60da57cfd7eec5c1b6af1e7c55
diff --git a/sfeed/patches/patch-sfeed.c b/sfeed/patches/patch-sfeed.c
index 8c8c63d9ae..2fa975094f 100644
--- a/sfeed/patches/patch-sfeed.c
+++ b/sfeed/patches/patch-sfeed.c
@@ -2,9 +2,58 @@ $NetBSD$
Avoid possible UBs in ctype(3) functions.
---- sfeed.c.orig 2018-09-07 13:27:10.299338895 +0000
+--- sfeed.c.orig 2018-09-07 16:16:51.071550475 +0000
+++ sfeed.c
-@@ -381,11 +381,11 @@ gettzoffset(const char *s)
+@@ -247,10 +247,10 @@ string_print_encoded(String *s)
+ return;
+
+ /* skip leading whitespace */
+- for (p = s->data; *p && isspace((int)*p); p++)
++ for (p = s->data; *p && isspace((unsigned char)*p); p++)
+ ;
+ /* seek location of trailing whitespace */
+- for (e = s->data + s->len; e > p && isspace((int)*(e - 1)); e--)
++ for (e = s->data + s->len; e > p && isspace((unsigned char)*(e - 1)); e--)
+ ;
+
+ for (; *p && p != e; p++) {
+@@ -260,7 +260,7 @@ string_print_encoded(String *s)
+ case '\t': fputs("\\t", stdout); break;
+ default:
+ /* ignore control chars */
+- if (!iscntrl((int)*p))
++ if (!iscntrl((unsigned char)*p))
+ putchar(*p);
+ break;
+ }
+@@ -278,16 +278,16 @@ string_print_trimmed(String *s)
+ return;
+
+ /* skip leading whitespace */
+- for (p = s->data; *p && isspace((int)*p); p++)
++ for (p = s->data; *p && isspace((unsigned char)*p); p++)
+ ;
+ /* seek location of trailing whitespace */
+- for (e = s->data + s->len; e > p && isspace((int)*(e - 1)); e--)
++ for (e = s->data + s->len; e > p && isspace((unsigned char)*(e - 1)); e--)
+ ;
+
+ for (; *p && p != e; p++) {
+- if (isspace((int)*p))
++ if (isspace((unsigned char)*p))
+ putchar(' '); /* any whitespace to space */
+- else if (!iscntrl((int)*p))
++ else if (!iscntrl((unsigned char)*p))
+ /* ignore other control chars */
+ putchar((int)*p);
+ }
+@@ -376,20 +376,20 @@ gettzoffset(const char *s)
+ int tzhour = 0, tzmin = 0;
+ size_t i, namelen;
+
+- for (; *s && isspace((int)*s); s++)
++ for (; *s && isspace((unsigned char)*s); s++)
+ ;
switch (s[0]) {
case '-': /* offset */
case '+':
@@ -19,3 +68,87 @@ Avoid possible UBs in ctype(3) functions.
tzmin = (tzmin * 10) + (*p - '0');
return ((tzhour * 3600) + (tzmin * 60)) * (s[0] == '-' ? -1 : 1);
default: /* timezone name */
+- for (i = 0; *s && isalpha((int)s[i]); i++)
++ for (i = 0; *s && isalpha((unsigned char)s[i]); i++)
+ ;
+ namelen = i; /* end of name */
+ /* optimization: these are always non-matching */
+@@ -429,49 +429,49 @@ parsetime(const char *s, time_t *tp)
+ int va[6] = { 0 }, i, j, v, vi;
+ size_t m;
+
+- for (; *s && isspace((int)*s); s++)
++ for (; *s && isspace((unsigned char)*s); s++)
+ ;
+- if (!isdigit((int)*s) && !isalpha((int)*s))
++ if (!isdigit((unsigned char)*s) && !isalpha((unsigned char)*s))
+ return -1;
+
+- if (isdigit((int)*s)) {
++ if (isdigit((unsigned char)*s)) {
+ /* format "%Y-%m-%d %H:%M:%S" or "%Y-%m-%dT%H:%M:%S" */
+ vi = 0;
+ time:
+ for (; *s && vi < 6; vi++) {
+- for (i = 0, v = 0; *s && i < 4 && isdigit((int)*s); s++, i++)
++ for (i = 0, v = 0; *s && i < 4 && isdigit((unsigned char)*s); s++, i++)
+ v = (v * 10) + (*s - '0');
+ va[vi] = v;
+ if ((vi < 2 && *s == '-') ||
+- (vi == 2 && (*s == 'T' || isspace((int)*s))) ||
++ (vi == 2 && (*s == 'T' || isspace((unsigned char)*s))) ||
+ (vi > 2 && *s == ':'))
+ s++;
+ }
+ /* TODO: only if seconds are parsed (vi == 5)? */
+ /* skip milliseconds for: %Y-%m-%dT%H:%M:%S.000Z */
+ if (*s == '.') {
+- for (s++; *s && isdigit((int)*s); s++)
++ for (s++; *s && isdigit((unsigned char)*s); s++)
+ ;
+ }
+ end = s;
+- } else if (isalpha((int)*s)) {
++ } else if (isalpha((unsigned char)*s)) {
+ /* format: "%a, %d %b %Y %H:%M:%S" */
+ /* parse "%a, %d %b %Y " part, then use time parsing as above */
+- for (; *s && isalpha((int)*s); s++)
++ for (; *s && isalpha((unsigned char)*s); s++)
+ ;
+- for (; *s && isspace((int)*s); s++)
++ for (; *s && isspace((unsigned char)*s); s++)
+ ;
+ if (*s != ',')
+ return -1;
+- for (s++; *s && isspace((int)*s); s++)
++ for (s++; *s && isspace((unsigned char)*s); s++)
+ ;
+- for (v = 0, i = 0; *s && i < 4 && isdigit((int)*s); s++, i++)
++ for (v = 0, i = 0; *s && i < 4 && isdigit((unsigned char)*s); s++, i++)
+ v = (v * 10) + (*s - '0');
+ va[2] = v; /* day */
+- for (; *s && isspace((int)*s); s++)
++ for (; *s && isspace((unsigned char)*s); s++)
+ ;
+ /* end of word month */
+- for (j = 0; *s && isalpha((int)s[j]); j++)
++ for (j = 0; *s && isalpha((unsigned char)s[j]); j++)
+ ;
+ /* check month name */
+ if (j < 3 || j > 9)
+@@ -487,12 +487,12 @@ time:
+ }
+ if (m >= 12)
+ return -1; /* no month found */
+- for (; *s && isspace((int)*s); s++)
++ for (; *s && isspace((unsigned char)*s); s++)
+ ;
+- for (v = 0, i = 0; *s && i < 4 && isdigit((int)*s); s++, i++)
++ for (v = 0, i = 0; *s && i < 4 && isdigit((unsigned char)*s); s++, i++)
+ v = (v * 10) + (*s - '0');
+ va[0] = v; /* year */
+- for (; *s && isspace((int)*s); s++)
++ for (; *s && isspace((unsigned char)*s); s++)
+ ;
+ /* parse regular time, see above */
+ vi = 3;
Home |
Main Index |
Thread Index |
Old Index