pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

sfeed: Add patches to avoid ctype(3) UB



Module Name:	pkgsrc-wip
Committed By:	Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By:	leot
Date:		Fri Sep 7 18:06:11 2018 +0200
Changeset:	57a17d3c5d882be5f5d5d385a4c848e44f75ef48

Modified Files:
	sfeed/distinfo
Added Files:
	sfeed/patches/patch-sfeed.c
	sfeed/patches/patch-sfeed__opml__import.c
	sfeed/patches/patch-sfeed__web.c
	sfeed/patches/patch-sfeed__xmlenc.c
	sfeed/patches/patch-util.c

Log Message:
sfeed: Add patches to avoid ctype(3) UB

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=57a17d3c5d882be5f5d5d385a4c848e44f75ef48

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 sfeed/distinfo                            |  5 +++++
 sfeed/patches/patch-sfeed.c               | 21 +++++++++++++++++++++
 sfeed/patches/patch-sfeed__opml__import.c | 15 +++++++++++++++
 sfeed/patches/patch-sfeed__web.c          | 15 +++++++++++++++
 sfeed/patches/patch-sfeed__xmlenc.c       | 15 +++++++++++++++
 sfeed/patches/patch-util.c                | 24 ++++++++++++++++++++++++
 6 files changed, 95 insertions(+)

diffs:
diff --git a/sfeed/distinfo b/sfeed/distinfo
index 9f39fe8b14..be653000f9 100644
--- a/sfeed/distinfo
+++ b/sfeed/distinfo
@@ -4,3 +4,8 @@ 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__opml__import.c) = f4870e075cf2675cfa6a104ecd594e7b373537e2
+SHA1 (patch-sfeed__web.c) = 361c9b985e8610bedf35176147c3b8c9511233ce
+SHA1 (patch-sfeed__xmlenc.c) = 2476f0f4ff215a60da57cfd7eec5c1b6af1e7c55
+SHA1 (patch-util.c) = e5e4992e1ab2646108c92830e7737b5c784c5afd
diff --git a/sfeed/patches/patch-sfeed.c b/sfeed/patches/patch-sfeed.c
new file mode 100644
index 0000000000..8c8c63d9ae
--- /dev/null
+++ b/sfeed/patches/patch-sfeed.c
@@ -0,0 +1,21 @@
+$NetBSD$
+
+Avoid possible UBs in ctype(3) functions.
+
+--- sfeed.c.orig	2018-09-07 13:27:10.299338895 +0000
++++ sfeed.c
+@@ -381,11 +381,11 @@ gettzoffset(const char *s)
+ 	switch (s[0]) {
+ 	case '-': /* offset */
+ 	case '+':
+-		for (i = 0, p = s + 1; i < 2 && *p && isdigit(*p); i++, p++)
++		for (i = 0, p = s + 1; i < 2 && *p && isdigit((unsigned char)*p); i++, p++)
+ 			tzhour = (tzhour * 10) + (*p - '0');
+-		if (*p && !isdigit(*p))
++		if (*p && !isdigit((unsigned char)*p))
+ 			p++;
+-		for (i = 0; i < 2 && *p && isdigit(*p); i++, p++)
++		for (i = 0; i < 2 && *p && isdigit((unsigned char)*p); i++, p++)
+ 			tzmin = (tzmin * 10) + (*p - '0');
+ 		return ((tzhour * 3600) + (tzmin * 60)) * (s[0] == '-' ? -1 : 1);
+ 	default: /* timezone name */
diff --git a/sfeed/patches/patch-sfeed__opml__import.c b/sfeed/patches/patch-sfeed__opml__import.c
new file mode 100644
index 0000000000..4bd76b9e30
--- /dev/null
+++ b/sfeed/patches/patch-sfeed__opml__import.c
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Avoid possible UBs in ctype(3) functions.
+
+--- sfeed_opml_import.c.orig	2018-08-26 13:03:06.000000000 +0000
++++ sfeed_opml_import.c
+@@ -18,7 +18,7 @@ static void
+ printsafe(const char *s)
+ {
+ 	for (; *s; s++) {
+-		if (iscntrl((int)*s))
++		if (iscntrl((unsigned char)*s))
+ 			continue;
+ 		else if (*s == '\\')
+ 			fputs("\\\\", stdout);
diff --git a/sfeed/patches/patch-sfeed__web.c b/sfeed/patches/patch-sfeed__web.c
new file mode 100644
index 0000000000..26262b5b76
--- /dev/null
+++ b/sfeed/patches/patch-sfeed__web.c
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Avoid possible UBs in ctype(3) functions.
+
+--- sfeed_web.c.orig	2018-08-26 13:03:06.000000000 +0000
++++ sfeed_web.c
+@@ -22,7 +22,7 @@ static void
+ printfeedtype(const char *s, FILE *fp)
+ {
+ 	for (; *s; s++)
+-		if (!isspace((int)*s))
++		if (!isspace((unsigned char)*s))
+ 			fputc(*s, fp);
+ }
+ 
diff --git a/sfeed/patches/patch-sfeed__xmlenc.c b/sfeed/patches/patch-sfeed__xmlenc.c
new file mode 100644
index 0000000000..95f2c0804c
--- /dev/null
+++ b/sfeed/patches/patch-sfeed__xmlenc.c
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Avoid possible UBs in ctype(3) functions.
+
+--- sfeed_xmlenc.c.orig	2018-08-26 13:03:06.000000000 +0000
++++ sfeed_xmlenc.c
+@@ -37,7 +37,7 @@ xmlattr(XMLParser *p, const char *tag, s
+ 		if (*value) {
+ 			/* output lowercase */
+ 			for (; *value; value++)
+-				putc(tolower((int)*value), stdout);
++				putc(tolower((unsigned char)*value), stdout);
+ 			putchar('\n');
+ 		}
+ 		exit(0);
diff --git a/sfeed/patches/patch-util.c b/sfeed/patches/patch-util.c
new file mode 100644
index 0000000000..2ac4a4f42a
--- /dev/null
+++ b/sfeed/patches/patch-util.c
@@ -0,0 +1,24 @@
+$NetBSD$
+
+Avoid possible UBs in ctype(3) functions.
+
+--- util.c.orig	2018-08-26 13:03:06.000000000 +0000
++++ util.c
+@@ -31,7 +31,7 @@ parseuri(const char *s, struct uri *u, i
+ 		p += 2; /* skip "//" */
+ 	} else {
+ 		/* protocol part */
+-		for (p = s; *p && (isalpha((int)*p) || isdigit((int)*p) ||
++		for (p = s; *p && (isalpha((unsigned char)*p) || isdigit((unsigned char)*p) ||
+ 			       *p == '+' || *p == '-' || *p == '.'); p++)
+ 			;
+ 		if (!strncmp(p, "://", 3)) {
+@@ -101,7 +101,7 @@ encodeuri(char *buf, size_t bufsiz, cons
+ 	for (i = 0, b = 0; s[i]; i++) {
+ 		if ((int)s[i] == ' ' ||
+ 		    (unsigned char)s[i] > 127 ||
+-		    iscntrl((int)s[i])) {
++		    iscntrl((unsigned char)s[i])) {
+ 			if (b + 3 >= bufsiz)
+ 				return -1;
+ 			buf[b++] = '%';


Home | Main Index | Thread Index | Old Index