summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hanselmann <public@hansmi.ch>2021-05-29 17:29:44 +0200
committerVictor Toso <me@victortoso.com>2021-06-01 20:58:07 +0000
commitc243c7244c06cb31d77b1c373726d9798a0c39f9 (patch)
treebc8c960152a0671d7a8e5548b85a305ed5462b73
parentdc26377dff414e4f0b7194c19eb71cd1251a97d1 (diff)
fuzzing: Read complete source buffer on write
By reading the whole buffer an instrumented build can detect potential buffer overflows on writing to a network connection. Signed-off-by: Michael Hanselmann <public@hansmi.ch>
-rw-r--r--fuzzing/usbredirparserfuzz.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/fuzzing/usbredirparserfuzz.cc b/fuzzing/usbredirparserfuzz.cc
index 7bd0e02..d163f8d 100644
--- a/fuzzing/usbredirparserfuzz.cc
+++ b/fuzzing/usbredirparserfuzz.cc
@@ -77,6 +77,11 @@ int parser_write(void *priv, uint8_t *data, int count)
{
log("%s: %d bytes\n", __func__, count);
+ // Read over complete source buffer to detect buffer overflows on write
+ void *buf = malloc(count);
+ memcpy(buf, data, count);
+ free(buf);
+
return count;
}