diff --git a/tests/libtest/lib1520.c b/tests/libtest/lib1520.c index c439666c9e..a76c64a5a9 100644 --- a/tests/libtest/lib1520.c +++ b/tests/libtest/lib1520.c @@ -54,7 +54,7 @@ static size_t t1520_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) if(data) { size_t len = strlen(data); - memcpy(ptr, data, len); + memcpy(ptr, data, len); /* NOLINT(bugprone-not-null-terminated-result) */ upload_ctx->lines_read++; return len; diff --git a/tests/libtest/lib1525.c b/tests/libtest/lib1525.c index 3c558d7c26..29ce7a9a0b 100644 --- a/tests/libtest/lib1525.c +++ b/tests/libtest/lib1525.c @@ -30,17 +30,18 @@ #include "first.h" -static const char t1525_testdata[] = "Hello Cloud!\n"; +static const char t1525_data[] = "Hello Cloud!\n"; +static size_t const t1525_datalen = sizeof(t1525_data) - 1; static size_t t1525_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - if(amount < strlen(t1525_testdata)) { - return strlen(t1525_testdata); + if(amount < t1525_datalen) { + return t1525_datalen; } (void)stream; - memcpy(ptr, t1525_testdata, strlen(t1525_testdata)); - return strlen(t1525_testdata); + memcpy(ptr, t1525_data, t1525_datalen); + return t1525_datalen; } static CURLcode test_lib1525(const char *URL) @@ -81,7 +82,7 @@ static CURLcode test_lib1525(const char *URL) test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); test_setopt(curl, CURLOPT_READFUNCTION, t1525_read_cb); test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); - test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1525_testdata)); + test_setopt(curl, CURLOPT_INFILESIZE, (long)t1525_datalen); result = curl_easy_perform(curl); diff --git a/tests/libtest/lib1526.c b/tests/libtest/lib1526.c index eac11b60aa..30c4f55235 100644 --- a/tests/libtest/lib1526.c +++ b/tests/libtest/lib1526.c @@ -29,17 +29,18 @@ #include "first.h" -static const char t1526_testdata[] = "Hello Cloud!\n"; +static const char t1526_data[] = "Hello Cloud!\n"; +static size_t const t1526_datalen = sizeof(t1526_data) - 1; static size_t t1526_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - if(amount < strlen(t1526_testdata)) { - return strlen(t1526_testdata); + if(amount < t1526_datalen) { + return t1526_datalen; } (void)stream; - memcpy(ptr, t1526_testdata, strlen(t1526_testdata)); - return strlen(t1526_testdata); + memcpy(ptr, t1526_data, t1526_datalen); + return t1526_datalen; } static CURLcode test_lib1526(const char *URL) @@ -85,7 +86,7 @@ static CURLcode test_lib1526(const char *URL) test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); test_setopt(curl, CURLOPT_READFUNCTION, t1526_read_cb); test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); - test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1526_testdata)); + test_setopt(curl, CURLOPT_INFILESIZE, (long)t1526_datalen); result = curl_easy_perform(curl); diff --git a/tests/libtest/lib1527.c b/tests/libtest/lib1527.c index af9f9fc21f..efa39efb73 100644 --- a/tests/libtest/lib1527.c +++ b/tests/libtest/lib1527.c @@ -29,17 +29,18 @@ #include "first.h" -static const char t1527_testdata[] = "Hello Cloud!\n"; +static const char t1527_data[] = "Hello Cloud!\n"; +static size_t const t1527_datalen = sizeof(t1527_data) - 1; static size_t t1527_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - if(amount < strlen(t1527_testdata)) { - return strlen(t1527_testdata); + if(amount < t1527_datalen) { + return t1527_datalen; } (void)stream; - memcpy(ptr, t1527_testdata, strlen(t1527_testdata)); - return strlen(t1527_testdata); + memcpy(ptr, t1527_data, t1527_datalen); + return t1527_datalen; } static CURLcode test_lib1527(const char *URL) @@ -82,7 +83,7 @@ static CURLcode test_lib1527(const char *URL) test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); test_setopt(curl, CURLOPT_READFUNCTION, t1527_read_cb); test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); - test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1527_testdata)); + test_setopt(curl, CURLOPT_INFILESIZE, (long)t1527_datalen); test_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_UNIFIED); result = curl_easy_perform(curl); diff --git a/tests/libtest/lib1531.c b/tests/libtest/lib1531.c index 86facffbb6..f8c9071e3b 100644 --- a/tests/libtest/lib1531.c +++ b/tests/libtest/lib1531.c @@ -25,8 +25,8 @@ static CURLcode test_lib1531(const char *URL) { - static char const testData[] = ".abc\0xyz"; - static curl_off_t const testDataSize = sizeof(testData) - 1; + static char const testdata[] = ".abc\0xyz"; + static curl_off_t const testdatalen = sizeof(testdata) - 1; CURL *curl; CURLM *multi; @@ -50,8 +50,8 @@ static CURLcode test_lib1531(const char *URL) /* set the options (I left out a few, you get the point anyway) */ curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, testDataSize); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, testData); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, testdatalen); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, testdata); /* we start some action by calling perform right away */ curl_multi_perform(multi, &still_running); diff --git a/tests/libtest/lib1576.c b/tests/libtest/lib1576.c index daa85a6652..5357f2ec13 100644 --- a/tests/libtest/lib1576.c +++ b/tests/libtest/lib1576.c @@ -23,17 +23,18 @@ ***************************************************************************/ #include "first.h" -static char t1576_testdata[] = "request indicates that the client, which made"; +static char t1576_data[] = "request indicates that the client, which made"; +static size_t const t1576_datalen = sizeof(t1576_data) - 1; static size_t t1576_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - if(amount < strlen(t1576_testdata)) { - return strlen(t1576_testdata); + if(amount < t1576_datalen) { + return t1576_datalen; } (void)stream; - memcpy(ptr, t1576_testdata, strlen(t1576_testdata)); - return strlen(t1576_testdata); + memcpy(ptr, t1576_data, t1576_datalen); + return t1576_datalen; } static int t1576_seek_callback(void *ptr, curl_off_t offset, int origin) @@ -69,7 +70,7 @@ static CURLcode test_lib1576(const char *URL) test_setopt(curl, CURLOPT_UPLOAD, 1L); test_setopt(curl, CURLOPT_READFUNCTION, t1576_read_cb); test_setopt(curl, CURLOPT_SEEKFUNCTION, t1576_seek_callback); - test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1576_testdata)); + test_setopt(curl, CURLOPT_INFILESIZE, (long)t1576_datalen); test_setopt(curl, CURLOPT_CUSTOMREQUEST, "CURL"); if(testnum == 1578 || testnum == 1580) { diff --git a/tests/libtest/lib1662.c b/tests/libtest/lib1662.c index 630dcd2f90..0e4942e9ad 100644 --- a/tests/libtest/lib1662.c +++ b/tests/libtest/lib1662.c @@ -30,17 +30,17 @@ struct t1662_WriteThis { static size_t t1662_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { static const char testdata[] = "mooaaa"; + static size_t const testdatalen = sizeof(testdata) - 1; struct t1662_WriteThis *pooh = (struct t1662_WriteThis *)userp; - size_t len = strlen(testdata); - if(size * nmemb < len) + if(size * nmemb < testdatalen) return 0; if(pooh->sizeleft) { - memcpy(ptr, testdata, strlen(testdata)); + memcpy(ptr, testdata, testdatalen); pooh->sizeleft = 0; - return len; + return testdatalen; } return 0; /* no more data left to deliver */ diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 268bc6349e..c325dc0bb7 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -51,7 +51,7 @@ static size_t t510_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) curl_mfprintf(stderr, "read buffer is too small to run test\n"); return 0; } - memcpy(ptr, data, len); + memcpy(ptr, data, len); /* NOLINT(bugprone-not-null-terminated-result) */ pooh->counter++; /* advance pointer */ return len; } diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 6611bdeaec..dd0f787ee6 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -29,7 +29,7 @@ #include "first.h" static const char t547_uploadthis[] = "this is the blurb we want to upload\n"; -#define T547_DATALEN (sizeof(t547_uploadthis) - 1) +static size_t const t547_datalen = sizeof(t547_uploadthis) - 1; static size_t t547_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) { @@ -42,10 +42,10 @@ static size_t t547_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) } (*counter)++; /* bump */ - if(size * nmemb >= T547_DATALEN) { + if(size * nmemb >= t547_datalen) { curl_mfprintf(stderr, "READ!\n"); - memcpy(ptr, t547_uploadthis, T547_DATALEN); - return T547_DATALEN; + memcpy(ptr, t547_uploadthis, t547_datalen); + return t547_datalen; } curl_mfprintf(stderr, "READ NOT FINE!\n"); return 0; @@ -96,7 +96,7 @@ static CURLcode test_lib547(const char *URL) test_setopt(curl, CURLOPT_READDATA, &counter); /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ - test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)T547_DATALEN); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)t547_datalen); } test_setopt(curl, CURLOPT_POST, 1L); test_setopt(curl, CURLOPT_PROXY, libtest_arg2); diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index 883b73b5bb..9e11aae7d7 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -33,7 +33,7 @@ #include "first.h" static const char t555_uploadthis[] = "this is the blurb we want to upload\n"; -#define T555_DATALEN (sizeof(t555_uploadthis) - 1) +static size_t const t555_datalen = sizeof(t555_uploadthis) - 1; static size_t t555_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) { @@ -46,10 +46,10 @@ static size_t t555_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) } (*counter)++; /* bump */ - if(size * nmemb >= T555_DATALEN) { + if(size * nmemb >= t555_datalen) { curl_mfprintf(stderr, "READ!\n"); - memcpy(ptr, t555_uploadthis, T555_DATALEN); - return T555_DATALEN; + memcpy(ptr, t555_uploadthis, t555_datalen); + return t555_datalen; } curl_mfprintf(stderr, "READ NOT FINE!\n"); return 0; @@ -92,7 +92,7 @@ static CURLcode test_lib555(const char *URL) easy_setopt(curl, CURLOPT_READDATA, &counter); /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ - easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)T555_DATALEN); + easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)t555_datalen); easy_setopt(curl, CURLOPT_POST, 1L); easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); diff --git a/tests/libtest/lib579.c b/tests/libtest/lib579.c index 1d1cfc3901..35ccd84855 100644 --- a/tests/libtest/lib579.c +++ b/tests/libtest/lib579.c @@ -91,7 +91,7 @@ static size_t t579_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) if(data) { size_t len = strlen(data); - memcpy(ptr, data, len); + memcpy(ptr, data, len); /* NOLINT(bugprone-not-null-terminated-result) */ pooh->counter++; /* advance pointer */ return len; } diff --git a/tests/libtest/lib757.c b/tests/libtest/lib757.c index b3237becf9..88f863746a 100644 --- a/tests/libtest/lib757.c +++ b/tests/libtest/lib757.c @@ -31,15 +31,15 @@ static size_t write_757(char *ptr, size_t size, size_t nmemb, void *userdata) return size * nmemb; } -#define DATA757 "fun-times" -#define DATALEN (sizeof(DATA757) - 1) +static const char t757_data[] = "fun-times"; +static size_t const t757_datalen = sizeof(t757_data) - 1; static size_t read_757(char *buffer, size_t size, size_t nitems, void *arg) { (void)arg; - if((size * nitems) >= DATALEN) { - memcpy(buffer, DATA757, DATALEN); - return DATALEN; + if((size * nitems) >= t757_datalen) { + memcpy(buffer, t757_data, t757_datalen); + return t757_datalen; } return 0; } @@ -83,7 +83,7 @@ static CURLcode test_lib757(const char *URL) /* Build the first mime structure. */ mime1 = curl_mime_init(curl); part = curl_mime_addpart(mime1); - curl_mime_data_cb(part, DATALEN, read_757, seek_757, NULL, NULL); + curl_mime_data_cb(part, t757_datalen, read_757, seek_757, NULL, NULL); curl_mime_type(part, "text/html"); curl_mime_name(part, "data"); diff --git a/tests/server/mqttd.c b/tests/server/mqttd.c index c2bff9b751..7b5c7c8043 100644 --- a/tests/server/mqttd.c +++ b/tests/server/mqttd.c @@ -351,6 +351,7 @@ static int publish(FILE *dump, packet[1 + encodedlen] = (unsigned char)(topiclen >> 8); packet[2 + encodedlen] = (unsigned char)(topiclen & 0xff); + /* NOLINTNEXTLINE(bugprone-not-null-terminated-result) */ memcpy(&packet[3 + encodedlen], topic, topiclen); payloadindex = 3 + topiclen + encodedlen; diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index fcc97b2ca3..5e337650d5 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -317,6 +317,7 @@ static int rtspd_ProcessRequest(struct rtspd_httprequest *req) /* Fill it with junk data */ for(i = 0; i < rtp_size; i += RTP_DATA_SIZE) { + /* NOLINTNEXTLINE(bugprone-not-null-terminated-result) */ memcpy(rtp_scratch + 4 + i, RTP_DATA, RTP_DATA_SIZE); }