com php-src: Fix out-of bounds access: ext/standard/strnatcmp.c

From: Date: Fri, 06 Jul 2018 17:02:19 +0000
Subject: com php-src: Fix out-of bounds access: ext/standard/strnatcmp.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102457@lists.php.net to get a copy of this message
Commit: 69a49af0d320be6d62028bd6a6996b49d4f200bc Author: Zenju <zenju@gmx.de> Sun, 12 Feb 2017 16:47:34 +0100 Committer: Anatol Belski <ab@php.net> Fri, 6 Jul 2018 19:02:19 +0200 Parents: b37dafcc232f71c1ae86ad819e68c201484dce39 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=69a49af0d320be6d62028bd6a6996b49d4f200bc Log: Fix out-of bounds access Test case: strnatcmp_ex(L"333", 3, L"333 ", 4, true) The reason this bug didn't come up earlier is probably because most input strings are null-terminated. Changed paths: M ext/standard/strnatcmp.c Diff: diff --git a/ext/standard/strnatcmp.c b/ext/standard/strnatcmp.c index ac8d2a2..64ff8fc 100644 --- a/ext/standard/strnatcmp.c +++ b/ext/standard/strnatcmp.c @@ -141,6 +141,10 @@ PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len else if (ap == aend && bp == bend) /* End of the strings. Let caller sort them out. */ return 0; + else if (ap == aend) + return -1; + else if (bp == bend) + return 1; else { /* Keep on comparing from the current point. */ ca = *ap; cb = *bp;

« previous php.cvs (#102457) next »