libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit bf6be24be37beceecd6c279047f4376c42e120c6
parent ce7e1e50d3fcc4930c0aff95d5afe9c200ab80d9
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 12 Sep 2021 18:31:54 +0300

test_postprocessor: fixed call of memcmp() with NULL pointers

Diffstat:
Msrc/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 @@ -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) &&