Bläddra i källkod

Force string length limits for vsnprintf operations (#175)

See 3 of https://github.com/civetweb/civetweb/issues/175#issuecomment-139703181
bel 10 år sedan
förälder
incheckning
3792243dc3
1 ändrade filer med 2 tillägg och 1 borttagningar
  1. 2 1
      src/civetweb.c

+ 2 - 1
src/civetweb.c

@@ -3704,8 +3704,9 @@ static int alloc_vprintf2(char **buf, const char *fmt, va_list ap)
 			break;
 		}
 		va_copy(ap_copy, ap);
-		len = vsnprintf_impl(*buf, size, fmt, ap_copy);
+		len = vsnprintf_impl(*buf, size - 1, fmt, ap_copy);
 		va_end(ap_copy);
+		*buf[size - 1] = 0;
 	}
 
 	return len;