Преглед изворни кода

exception if invalid throttle parameter is used

If '*' is used as `throttle` parameter, there is a segfault
at the first request (see #350). This is a quick fix to avoid the
segfault exception.
Note that in general civetweb.c does not check parameters in advance,
in order to keep the code simple. Other invalid parameters may still
cause exceptions. It is the responsibility of the caller to pass
valid parameters to mg_start.
bel пре 8 година
родитељ
комит
3b6461d2a0
1 измењених фајлова са 3 додато и 3 уклоњено
  1. 3 3
      src/civetweb.c

+ 3 - 3
src/civetweb.c

@@ -9680,9 +9680,9 @@ set_throttle(const char *spec, uint32_t remote_ip, const char *uri)
 
 	while ((spec = next_option(spec, &vec, &val)) != NULL) {
 		mult = ',';
-		if (sscanf(val.ptr, "%lf%c", &v, &mult) < 1 || v < 0
-		    || (lowercase(&mult) != 'k' && lowercase(&mult) != 'm'
-		        && mult != ',')) {
+		if ((val.ptr == NULL) || (sscanf(val.ptr, "%lf%c", &v, &mult) < 1)
+		    || (v < 0) || ((lowercase(&mult) != 'k')
+		                   && (lowercase(&mult) != 'm') && (mult != ','))) {
 			continue;
 		}
 		v *= (lowercase(&mult) == 'k')