summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven G. Johnson <stevenj@mit.edu>2016-02-04 10:57:25 -0500
committerSteven G. Johnson <stevenj@mit.edu>2016-02-04 10:57:25 -0500
commit5a84e53b0cf676b53c9a8b80d42ef91311b124f9 (patch)
treecec3e05eb7b416717edf22fa5f8c301fc8df7c77
parentec0daa50bbedc36a0bada4a0f713eb9dc317d444 (diff)
parent1f17487aa952a11f2ac53481b26b5a25b9a2fccc (diff)
downloadlibutf8proc-5a84e53b0cf676b53c9a8b80d42ef91311b124f9.tar.gz
libutf8proc-5a84e53b0cf676b53c9a8b80d42ef91311b124f9.tar.bz2
Merge pull request #66 from michaelnmmeyer/master
Fix overrun
-rw-r--r--CMakeLists.txt2
-rw-r--r--MANIFEST6
-rw-r--r--Makefile2
-rw-r--r--test/iterate.c10
-rw-r--r--utf8proc.c2
5 files changed, 14 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff0c819..8958bcd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,7 +9,7 @@ project (utf8proc C)
# Be sure to also update these in Makefile!
set(SO_MAJOR 2)
set(SO_MINOR 0)
-set(SO_PATCH 0)
+set(SO_PATCH 1)
add_definitions (
-DUTF8PROC_EXPORTS
diff --git a/MANIFEST b/MANIFEST
index f79d541..0be40e0 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -2,6 +2,6 @@ include/
include/utf8proc.h
lib/
lib/libutf8proc.a
-lib/libutf8proc.so -> libutf8proc.so.2.0.0
-lib/libutf8proc.so.2 -> libutf8proc.so.2.0.0
-lib/libutf8proc.so.2.0.0
+lib/libutf8proc.so -> libutf8proc.so.2.0.1
+lib/libutf8proc.so.2 -> libutf8proc.so.2.0.1
+lib/libutf8proc.so.2.0.1
diff --git a/Makefile b/Makefile
index ff5e771..1179748 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ UCFLAGS = $(CFLAGS) $(PICFLAG) $(C99FLAG) $(WCFLAGS) -DUTF8PROC_EXPORTS
# Be sure to also update these in MANIFEST and CMakeLists.txt!
MAJOR=2
MINOR=0
-PATCH=0
+PATCH=1
OS := $(shell uname)
ifeq ($(OS),Darwin) # MacOS X
diff --git a/test/iterate.c b/test/iterate.c
index 30b307d..c1674b7 100644
--- a/test/iterate.c
+++ b/test/iterate.c
@@ -13,11 +13,17 @@ static void testbytes(unsigned char *buf, int len, utf8proc_ssize_t retval, int
utf8proc_int32_t out[16];
utf8proc_ssize_t ret;
+ /* Make a copy to ensure that memory is left uninitialized after "len"
+ * bytes. This way, Valgrind can detect overreads.
+ */
+ unsigned char tmp[16];
+ memcpy(tmp, buf, len);
+
tests++;
- if ((ret = utf8proc_iterate(buf, len, out)) != retval) {
+ if ((ret = utf8proc_iterate(tmp, len, out)) != retval) {
fprintf(stderr, "Failed (%d):", line);
for (int i = 0; i < len ; i++) {
- fprintf(stderr, " 0x%02x", buf[i]);
+ fprintf(stderr, " 0x%02x", tmp[i]);
}
fprintf(stderr, " -> %zd\n", ret);
error++;
diff --git a/utf8proc.c b/utf8proc.c
index ab23a87..dc1000a 100644
--- a/utf8proc.c
+++ b/utf8proc.c
@@ -128,7 +128,7 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_iterate(
if ((uc - 0xc2) > (0xf4-0xc2)) return UTF8PROC_ERROR_INVALIDUTF8;
if (uc < 0xe0) { // 2-byte sequence
// Must have valid continuation character
- if (!utf_cont(*str)) return UTF8PROC_ERROR_INVALIDUTF8;
+ if (str >= end || !utf_cont(*str)) return UTF8PROC_ERROR_INVALIDUTF8;
*dst = ((uc & 0x1f)<<6) | (*str & 0x3f);
return 2;
}