PHP是一款流行的编程语言。grapheme_extract()存在空指针应用错误,代码如下:- -grapheme_extract()--...if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|llz", (char**)&str, &str_len, &size, &extract_type, &lstart, &next) == FAILURE) { <=== str='a' and size='-1'.../* if the string is all ASCII up to size+1 - or str_len whichever is first- then we are done.(size + 1 because the size-th character might be the beginning of agrapheme cluster)*/if ( -1 != grapheme_ascii_check(pstr, size + 1 < str_len ? size + 1 :str_len ) ) { <=== ( size=-1+1=0 ) ===long nsize = ( size < str_len ? size : str_len ); <=== nsize = -1if ( NULL != next ) {ZVAL_LONG(next, start+nsize);}RETURN_STRINGL(((char *)pstr), nsize, 1); <=== CRASH POINT}...- -grapheme_extract()--如果可以调用grapheme_ascii_check(pstr,0):- -grapheme_ascii_check()--/* {{{ grapheme_ascii_check: ASCII check */int grapheme_ascii_check(const unsigned char *day, int32_t len) <====len=0{int ret_len = len;while ( len-- ) {if ( *day++ > 0x7f )return -1;}return ret_len; <=== return 0}- -grapheme_ascii_check()--就会导致get (int)0并且long nsize = ( size < str_len ? size : str_len );为-1,因此:RETURN_STRINGL(((char *)pstr), nsize, 1);会触发空指针引用。
用户可参考如下供应商提供的安全公告获得补丁信息:http://svn.php.net/viewvc?view=revision&revision=306449