From: Stanislav Malyshev <stas@php.net>
Date: Fri, 23 Mar 2012 07:26:33 +0000 (-0700)
Subject: fix bug #61487 - bad bounds check in grapheme_strpos
X-Git-Tag: php-5.4.1RC1~23^2^2
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd9cd36d7e81af19eba3631b371ec40658874a8b;p=php

fix bug #61487 - bad bounds check in grapheme_strpos
---

diff --git a/ext/intl/grapheme/grapheme_util.h b/ext/intl/grapheme/grapheme_util.h
index 675c6481b7..c91aeaff7d 100755
--- a/ext/intl/grapheme/grapheme_util.h
+++ b/ext/intl/grapheme/grapheme_util.h
@@ -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
index 0000000000..361debe408
--- /dev/null
+++ b/ext/intl/tests/bug61487.phpt
@@ -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)