diff options
author | erdgeist <> | 2007-10-23 00:39:21 +0000 |
---|---|---|
committer | erdgeist <> | 2007-10-23 00:39:21 +0000 |
commit | ab9246618b1d369cdba1140135dedb8affc5485e (patch) | |
tree | cf17f7cf4d164677597f1a4502f27ad8dfb48919 | |
parent | 1fce733ea0037d67fd07d6738bed92da3ae7c81a (diff) |
some clients chose to accidently send negative numwants
-rw-r--r-- | opentracker.c | 1 | ||||
-rw-r--r-- | scan_urlencoded_query.c | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/opentracker.c b/opentracker.c index 41df0ee..cfa051a 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -511,6 +511,7 @@ ANNOUNCE_WORKAROUND: | |||
511 | if(!byte_diff(data,7,"numwant")) { | 511 | if(!byte_diff(data,7,"numwant")) { |
512 | len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE ); | 512 | len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE ); |
513 | if( ( len <= 0 ) || scan_fixed_int( data, len, &numwant ) ) HTTPERROR_400_PARAM; | 513 | if( ( len <= 0 ) || scan_fixed_int( data, len, &numwant ) ) HTTPERROR_400_PARAM; |
514 | if( numwant < 0 ) numwant = 50; | ||
514 | if( numwant > 200 ) numwant = 200; | 515 | if( numwant > 200 ) numwant = 200; |
515 | } else if(!byte_diff(data,7,"compact")) { | 516 | } else if(!byte_diff(data,7,"compact")) { |
516 | len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE ); | 517 | len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE ); |
diff --git a/scan_urlencoded_query.c b/scan_urlencoded_query.c index 241a904..a78a697 100644 --- a/scan_urlencoded_query.c +++ b/scan_urlencoded_query.c | |||
@@ -78,8 +78,11 @@ ssize_t scan_urlencoded_query(char **string, char *deststring, SCAN_SEARCHPATH_F | |||
78 | } | 78 | } |
79 | 79 | ||
80 | ssize_t scan_fixed_int( char *data, size_t len, int *tmp ) { | 80 | ssize_t scan_fixed_int( char *data, size_t len, int *tmp ) { |
81 | int minus = 0; | ||
81 | *tmp = 0; | 82 | *tmp = 0; |
83 | if( *data == '-' ) --len, ++data, ++minus; | ||
82 | while( (len > 0) && (*data >= '0') && (*data <= '9') ) { --len; *tmp = 10**tmp + *data++-'0'; } | 84 | while( (len > 0) && (*data >= '0') && (*data <= '9') ) { --len; *tmp = 10**tmp + *data++-'0'; } |
85 | if( minus ) *tmp = -*tmp; | ||
83 | return len; | 86 | return len; |
84 | } | 87 | } |
85 | 88 | ||