@@ -106,7 +106,7 @@ typedef zend_long (*int_string_formater)(const char*, char**, int);
106106/*
107107 * Declarations for functions used only in this file.
108108 */
109- static char * BuildCharSet (CharSet * cset , char * format );
109+ static const char * BuildCharSet (CharSet * cset , const char * format );
110110static bool CharInSet (const CharSet * cset , char c );
111111static void ReleaseCharSet (CharSet * cset );
112112static inline void scan_set_error_return (bool assignToVariables , zval * return_value );
@@ -129,7 +129,7 @@ static inline void scan_set_error_return(bool assignToVariables, zval *return_va
129129 *
130130 *----------------------------------------------------------------------
131131 */
132- static char * BuildCharSet (CharSet * cset , char * format )
132+ static const char * BuildCharSet (CharSet * cset , const char * format )
133133{
134134 const char * ch ;
135135 int nranges ;
@@ -570,22 +570,24 @@ static int ValidateFormat(const char *format, uint32_t numVars, uint32_t *totalS
570570 * return_value set with the results of the scan
571571 */
572572
573- PHPAPI int php_sscanf_internal ( char * string , char * format ,
573+ PHPAPI int php_sscanf_internal ( char * string , const char * format ,
574574 uint32_t argCount , zval * args ,
575575 zval * return_value )
576576{
577577 int numVars , nconversions ;
578578 int result ;
579579 zend_long value ;
580580 zend_ulong objIndex ;
581- char * end , * baseString ;
581+ char * end ;
582+ const char * baseString ;
582583 zval * current ;
583584 char op = 0 ;
584585 int base = 0 ;
585586 int underflow = 0 ;
586587 size_t width ;
587588 int_string_formater fn = NULL ;
588- char * ch , sch ;
589+ const char * ch ;
590+ char sch ;
589591 int flags ;
590592 char buf [64 ]; /* Temporary buffer to hold scanned number
591593 * strings before they are passed to strtoul() */
@@ -704,7 +706,9 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
704706 * Parse any width specifier.
705707 */
706708 if ( isdigit (UCHAR (* ch ))) {
707- width = ZEND_STRTOUL (format - 1 , & format , 10 );
709+ char * end_ptr = NULL ;
710+ width = ZEND_STRTOUL (format - 1 , & end_ptr , 10 );
711+ format = end_ptr ;
708712 ch = format ++ ;
709713 } else {
710714 width = 0 ;
0 commit comments