Browse Source

some clients chose to accidently send negative numwants

master
Dirk Engling 14 years ago
parent
commit
7075730766
  1. 1
      opentracker.c
  2. 3
      scan_urlencoded_query.c

1
opentracker.c

@ -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 );

3
scan_urlencoded_query.c

@ -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