]> granicus.if.org Git - php/commitdiff
fix bug #61487 - bad bounds check in grapheme_strpos
authorStanislav Malyshev <stas@php.net>
Fri, 23 Mar 2012 07:26:33 +0000 (00:26 -0700)
committerStanislav Malyshev <stas@php.net>
Sun, 25 Mar 2012 07:56:38 +0000 (00:56 -0700)
ext/intl/grapheme/grapheme_util.h
ext/intl/tests/bug61487.phpt [new file with mode: 0644]

index 675c6481b73d024c33a38a3702cc846ab79ce4a5..c91aeaff7dd12dbc25197db033460c1cc8a6979c 100755 (executable)
@@ -54,6 +54,6 @@ UBreakIterator*
 grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status TSRMLS_DC );
 
 /* OUTSIDE_STRING: check if (possibly negative) long offset is outside the string with int32_t length */
-#define OUTSIDE_STRING(offset, max_len) ( offset < INT32_MIN || offset > INT32_MAX || (offset < 0 ? -offset > (long) max_len : offset >= (long) max_len) )
+#define OUTSIDE_STRING(offset, max_len) ( offset <= INT32_MIN || offset > INT32_MAX || (offset < 0 ? -offset > (long) max_len : offset >= (long) max_len) )
 
 #endif // GRAPHEME_GRAPHEME_UTIL_H
diff --git a/ext/intl/tests/bug61487.phpt b/ext/intl/tests/bug61487.phpt
new file mode 100644 (file)
index 0000000..361debe
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+grapheme() str[i]pos limits
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+var_dump(grapheme_stripos(1,1,2147483648));
+var_dump(grapheme_strpos(1,1,2147483648));
+--EXPECT--
+bool(false)
+bool(false)