@@ -53,24 +53,29 @@ static bool node_is_equal_xsd(xmlNodePtr node, const char *name)
5353 return node_is_equal_ex_one_of (node , name , ns );
5454}
5555
56- static int schema_parse_int (const xmlChar * value , const char * name )
56+ static int schema_parse_int (const xmlChar * value , const char * name , bool allow_negative )
5757{
5858 const char * str = (const char * ) value ;
5959 zend_long lval = 0 ;
6060 int oflow_info = 0 ;
6161 uint8_t type = is_numeric_string_ex (str , strlen (str ), & lval , NULL , true, & oflow_info , NULL );
6262
63- if (oflow_info > 0 || (type == IS_LONG && ZEND_LONG_INT_OVFL (lval ))) {
63+ if (oflow_info || (type == IS_LONG && ZEND_LONG_EXCEEDS_INT (lval ))) {
6464 soap_error1 (E_ERROR , "Parsing Schema: %s value is out of range" , name );
6565 }
6666
6767 if (type == IS_LONG ) {
68+ if (!allow_negative && lval < 0 ) {
69+ soap_error1 (E_ERROR , "Parsing Schema: %s value is out of range" , name );
70+ }
6871 return (int ) lval ;
6972 }
7073
7174 errno = 0 ;
7275 lval = ZEND_STRTOL (str , NULL , 10 );
73- if ((errno == ERANGE && lval > 0 ) || ZEND_LONG_INT_OVFL (lval )) {
76+ if ((errno == ERANGE && (lval > 0 || lval < 0 ))
77+ || ZEND_LONG_EXCEEDS_INT (lval )
78+ || (!allow_negative && lval < 0 )) {
7479 soap_error1 (E_ERROR , "Parsing Schema: %s value is out of range" , name );
7580 }
7681
@@ -878,7 +883,7 @@ static int schema_restriction_var_int(xmlNodePtr val, sdlRestrictionIntPtr *valp
878883 soap_error0 (E_ERROR , "Parsing Schema: missing restriction value" );
879884 }
880885
881- (* valptr )-> value = schema_parse_int (value -> children -> content , (const char * ) val -> name );
886+ (* valptr )-> value = schema_parse_int (value -> children -> content , (const char * ) val -> name , true );
882887
883888 return TRUE;
884889}
@@ -1040,7 +1045,7 @@ void schema_min_max(xmlNodePtr node, sdlContentModelPtr model)
10401045 xmlAttrPtr attr = get_attribute (node -> properties , "minOccurs" );
10411046
10421047 if (attr ) {
1043- model -> min_occurs = schema_parse_int (attr -> children -> content , "minOccurs" );
1048+ model -> min_occurs = schema_parse_int (attr -> children -> content , "minOccurs" , false );
10441049 } else {
10451050 model -> min_occurs = 1 ;
10461051 }
@@ -1050,7 +1055,7 @@ void schema_min_max(xmlNodePtr node, sdlContentModelPtr model)
10501055 if (!strncmp ((char * )attr -> children -> content , "unbounded" , sizeof ("unbounded" ))) {
10511056 model -> max_occurs = -1 ;
10521057 } else {
1053- model -> max_occurs = schema_parse_int (attr -> children -> content , "maxOccurs" );
1058+ model -> max_occurs = schema_parse_int (attr -> children -> content , "maxOccurs" , false );
10541059 }
10551060 } else {
10561061 model -> max_occurs = 1 ;
0 commit comments