[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 01/05: test_postprocessor: fixed call of memcmp() with N
From: |
gnunet |
Subject: |
[libmicrohttpd] 01/05: test_postprocessor: fixed call of memcmp() with NULL pointers |
Date: |
Sun, 12 Sep 2021 18:32:22 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit bf6be24be37beceecd6c279047f4376c42e120c6
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Sep 12 18:31:54 2021 +0300
test_postprocessor: fixed call of memcmp() with NULL pointers
---
src/microhttpd/test_postprocessor.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/microhttpd/test_postprocessor.c
b/src/microhttpd/test_postprocessor.c
index 17d09c91..b3e12323 100644
--- a/src/microhttpd/test_postprocessor.c
+++ b/src/microhttpd/test_postprocessor.c
@@ -105,6 +105,17 @@ mismatch (const char *a, const char *b)
}
+static int
+mismatch2 (const char *data, const char *expected, size_t offset, size_t size)
+{
+ if (data == expected)
+ return 0;
+ if ((data == NULL) || (expected == NULL))
+ return 1;
+ return 0 != memcmp (data, expected + offset, size);
+}
+
+
static enum MHD_Result
value_checker (void *cls,
enum MHD_ValueKind kind,
@@ -144,9 +155,7 @@ value_checker (void *cls,
(mismatch (filename, expct->fname)) ||
(mismatch (content_type, expct->cnt_type)) ||
(mismatch (transfer_encoding, expct->tr_enc)) ||
- (0 != memcmp (data,
- &expct->data[off],
- size)))
+ (mismatch2 (data, expct->data, off, size)))
{
*idxp = (unsigned int) -1;
fprintf (stderr,
@@ -171,7 +180,7 @@ value_checker (void *cls,
(mismatch (filename, expct->fname)),
(mismatch (content_type, expct->cnt_type)),
(mismatch (transfer_encoding, expct->tr_enc)),
- (0 != memcmp (data, &expct->data[off], size)));
+ (mismatch2 (data, expct->data, off, size)));
return MHD_NO;
}
if ( ( (NULL == expct->data) &&
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.