some clients chose to accidently send negative numwants

dynamic-accesslists
erdgeist 17 years ago
parent 1fce733ea0
commit ab9246618b

@ -511,6 +511,7 @@ ANNOUNCE_WORKAROUND:
if(!byte_diff(data,7,"numwant")) {
len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE );
if( ( len <= 0 ) || scan_fixed_int( data, len, &numwant ) ) HTTPERROR_400_PARAM;
if( numwant < 0 ) numwant = 50;
if( numwant > 200 ) numwant = 200;
} else if(!byte_diff(data,7,"compact")) {
len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE );

@ -78,8 +78,11 @@ ssize_t scan_urlencoded_query(char **string, char *deststring, SCAN_SEARCHPATH_F
}
ssize_t scan_fixed_int( char *data, size_t len, int *tmp ) {
int minus = 0;
*tmp = 0;
if( *data == '-' ) --len, ++data, ++minus;
while( (len > 0) && (*data >= '0') && (*data <= '9') ) { --len; *tmp = 10**tmp + *data++-'0'; }
if( minus ) *tmp = -*tmp;
return len;
}

Loading…
Cancel
Save