]> granicus.if.org Git - curl/commitdiff
lib510: don't write past the end of the buffer if it's too small
authorDan Fandrich <dan@coneharvesters.com>
Sat, 13 May 2017 20:57:49 +0000 (22:57 +0200)
committerDan Fandrich <dan@coneharvesters.com>
Sat, 13 May 2017 21:13:09 +0000 (23:13 +0200)
tests/libtest/lib510.c

index 68588cfe6c6caa56611b6e6d63959a8c696de801..4c290f1ef7c7aaa70d29c8da9679b5e7d3379dd2 100644 (file)
@@ -48,6 +48,10 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
 
   if(data) {
     size_t len = strlen(data);
+    if(size*nmemb < len) {
+      fprintf(stderr, "read buffer is too small to run test\n");
+      return 0;
+    }
     memcpy(ptr, data, len);
     pooh->counter++; /* advance pointer */
     return len;