aboutsummaryrefslogtreecommitdiffstats
path: root/textproc
diff options
context:
space:
mode:
authoramdmi3 <amdmi3@FreeBSD.org>2014-11-01 21:59:42 +0800
committeramdmi3 <amdmi3@FreeBSD.org>2014-11-01 21:59:42 +0800
commit4b4684a0f90a2c6eba7c1620fff022881deaba9f (patch)
tree47a98c02acd3c94d34cce5448c4bff7cc1d1c028 /textproc
parent8d4e0958ecfedca3cf12639c2ccdc11903b3e2da (diff)
downloadfreebsd-ports-gnome-4b4684a0f90a2c6eba7c1620fff022881deaba9f.tar.gz
freebsd-ports-gnome-4b4684a0f90a2c6eba7c1620fff022881deaba9f.tar.zst
freebsd-ports-gnome-4b4684a0f90a2c6eba7c1620fff022881deaba9f.zip
- Fix UB which leads to guaranteed crash when built with clang 3.4.1+ (e.g. on FreeBSD 10.1+)
Reported by: Alex Petrov
Diffstat (limited to 'textproc')
-rw-r--r--textproc/catdoc/Makefile2
-rw-r--r--textproc/catdoc/files/patch-src__fileutil.c60
2 files changed, 61 insertions, 1 deletions
diff --git a/textproc/catdoc/Makefile b/textproc/catdoc/Makefile
index 0d80c2a56989..109ed41708d4 100644
--- a/textproc/catdoc/Makefile
+++ b/textproc/catdoc/Makefile
@@ -3,7 +3,7 @@
PORTNAME= catdoc
PORTVERSION= 0.94.2
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= textproc
MASTER_SITES= http://mirror.amdmi3.ru/distfiles/ \
LOCAL/amdmi3 \
diff --git a/textproc/catdoc/files/patch-src__fileutil.c b/textproc/catdoc/files/patch-src__fileutil.c
new file mode 100644
index 000000000000..71086302ee08
--- /dev/null
+++ b/textproc/catdoc/files/patch-src__fileutil.c
@@ -0,0 +1,60 @@
+diff --git src/fileutil.c src/fileutil.c
+index d902a6a..6afddec 100644
+--- src/fileutil.c
++++ src/fileutil.c
+@@ -71,13 +71,12 @@ char *find_file(char *name, const char *path)
+ char *q;
+ char path_buf[PATH_BUF_SIZE];
+ char dir_sep[2]={DIR_SEP,0};
+- for (p=path;p;p=q+1) {
++ for (p=path;p;) {
+ q=strchr(p,LIST_SEP);
+
+ if (q) {
+ if (!prepare_path_buf(path_buf,p,q)) continue;
+ } else {
+- q--;
+ if (!prepare_path_buf(path_buf,p,p+strlen(p))) continue;
+ }
+ strcat(path_buf,dir_sep); /* always one char */
+@@ -88,6 +87,11 @@ char *find_file(char *name, const char *path)
+ free(name);
+ return strdup(path_buf);
+ }
++ if (q) {
++ p = q + 1;
++ } else {
++ p = NULL;
++ }
+ }
+ /* if we are here, nothing found */
+ free(name);
+@@ -186,7 +190,7 @@ void list_charsets(void) {
+ int count,glob_flags=GLOB_ERR;
+ #endif
+ char **ptr;
+- for (p=charset_path;p;p=q+1) {
++ for (p=charset_path;p;) {
+ q=strchr(p,LIST_SEP);
+
+ if (q) {
+@@ -197,7 +201,6 @@ void list_charsets(void) {
+ strncpy(path_buf,p,q-p);
+ path_buf[q-p]=0;
+ } else {
+- q--;
+ if (strlen(p)>=PATH_BUF_SIZE) continue;
+ strcpy(path_buf,p);
+ }
+@@ -244,6 +247,11 @@ void list_charsets(void) {
+ }
+ glob_flags|=GLOB_APPEND;
+ #endif
++ if (q) {
++ p = q + 1;
++ } else {
++ p = NULL;
++ }
+ }
+ #ifdef __MSDOS__
+ fputs("utf-8\n",stdout);