aboutsummaryrefslogtreecommitdiff
path: root/audio/flac/files/patch-src_share_utf8_iconvert.c
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@FreeBSD.org>2007-11-13 14:28:29 +0000
committerChristian Weisgerber <naddy@FreeBSD.org>2007-11-13 14:28:29 +0000
commit18adb1480081525ed31aaa6be0627d6cea8bc213 (patch)
tree3dac703897b26e14df5b17502e86ee09fa42371a /audio/flac/files/patch-src_share_utf8_iconvert.c
parente0a98018767124342c291af2c47bd35b4e1e06ed (diff)
downloadports-18adb1480081525ed31aaa6be0627d6cea8bc213.tar.gz
ports-18adb1480081525ed31aaa6be0627d6cea8bc213.zip
Notes
Diffstat (limited to 'audio/flac/files/patch-src_share_utf8_iconvert.c')
-rw-r--r--audio/flac/files/patch-src_share_utf8_iconvert.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/audio/flac/files/patch-src_share_utf8_iconvert.c b/audio/flac/files/patch-src_share_utf8_iconvert.c
new file mode 100644
index 000000000000..755f1eaabd39
--- /dev/null
+++ b/audio/flac/files/patch-src_share_utf8_iconvert.c
@@ -0,0 +1,49 @@
+
+$FreeBSD$
+
+--- src/share/utf8/iconvert.c.orig
++++ src/share/utf8/iconvert.c
+@@ -27,6 +27,7 @@
+ #include <iconv.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include "share/alloc.h"
+
+ /*
+ * Convert data from one encoding to another. Return:
+@@ -79,7 +80,7 @@
+ * This is deliberately not a config option as people often
+ * change their iconv library without rebuilding applications.
+ */
+- tocode1 = (char *)malloc(strlen(tocode) + 11);
++ tocode1 = (char *)safe_malloc_add_2op_(strlen(tocode), /*+*/11);
+ if (!tocode1)
+ goto fail;
+
+@@ -117,6 +118,8 @@
+ break;
+ if (obl < 6) {
+ /* Enlarge the buffer */
++ if(utflen*2 < utflen) /* overflow check */
++ goto fail;
+ utflen *= 2;
+ newbuf = (char *)realloc(utfbuf, utflen);
+ if (!newbuf)
+@@ -143,7 +146,7 @@
+ iconv_close(cd1);
+ return ret;
+ }
+- newbuf = (char *)realloc(utfbuf, (ob - utfbuf) + 1);
++ newbuf = (char *)safe_realloc_add_2op_(utfbuf, (ob - utfbuf), /*+*/1);
+ if (!newbuf)
+ goto fail;
+ ob = (ob - utfbuf) + newbuf;
+@@ -194,7 +197,7 @@
+ outlen += ob - tbuf;
+
+ /* Convert from UTF-8 for real */
+- outbuf = (char *)malloc(outlen + 1);
++ outbuf = (char *)safe_malloc_add_2op_(outlen, /*+*/1);
+ if (!outbuf)
+ goto fail;
+ ib = utfbuf;