|
substr_compare() performs two sanity checks on the input parameters:
Sanity Check #1 - ensures that a negative offset is considered relative to the end of the first input string
if (offset < 0) {
offset = s1_len + offset;
offset = (offset < 0) ? 0 : offset;
}
Sanity Check #2 - ensures that offset and requested length do not exceed the buffer length, but does not take into account that the addition of two positive signed variables can result in a negative value when an integer overflow occurs
if ((offset + len) > s1_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed ...");
RETURN_FALSE;
}
Comparing an ASCIIZ char and a ASCII 01 char with an offset outside the buffer and comparing the return values of substr_compare() it is possible to determine ASCII value of the byte outside the buffer.
|