detect empty mode string and avoid off-by-one

This commit is contained in:
Antony Dovgal 2006-06-26 21:13:22 +00:00
parent e9c59b98ac
commit d4bb248ae0

View File

@ -205,7 +205,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
if (strncasecmp("compress.bzip2://", path, 17) == 0) {
path += 17;
}
if (mode[0] != 'w' && mode[0] != 'r' && mode[1] != '\0') {
if (mode[0] == '\0' || (mode[0] != 'w' && mode[0] != 'r' && mode[1] != '\0')) {
return NULL;
}