aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/test_toolarge.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/test_toolarge.c')
-rw-r--r--src/testcurl/test_toolarge.c73
1 files changed, 37 insertions, 36 deletions
diff --git a/src/testcurl/test_toolarge.c b/src/testcurl/test_toolarge.c
index 30f0d922..2b94ab7b 100644
--- a/src/testcurl/test_toolarge.c
+++ b/src/testcurl/test_toolarge.c
@@ -219,7 +219,7 @@ _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum)
219/* Global parameters */ 219/* Global parameters */
220static int verbose; /**< Be verbose */ 220static int verbose; /**< Be verbose */
221static int oneone; /**< If false use HTTP/1.0 for requests*/ 221static int oneone; /**< If false use HTTP/1.0 for requests*/
222static int global_port; /**< MHD daemons listen port number */ 222static uint16_t global_port; /**< MHD daemons listen port number */
223static int large_req_method; /**< Large request method */ 223static int large_req_method; /**< Large request method */
224static int large_req_url; /**< Large request URL */ 224static int large_req_url; /**< Large request URL */
225static int large_req_header_name; /**< Large request single header name */ 225static int large_req_header_name; /**< Large request single header name */
@@ -256,8 +256,8 @@ test_global_cleanup (void)
256struct headers_check_result 256struct headers_check_result
257{ 257{
258 unsigned int num_n1_headers; 258 unsigned int num_n1_headers;
259 unsigned int large_header_name_size; 259 size_t large_header_name_size;
260 unsigned int large_header_value_size; 260 size_t large_header_value_size;
261 int large_header_valid; 261 int large_header_valid;
262}; 262};
263 263
@@ -281,7 +281,7 @@ lcurl_hdr_callback (char *buffer, size_t size, size_t nitems,
281 if (NULL != col_ptr) 281 if (NULL != col_ptr)
282 { 282 {
283 const char *const name = buffer; 283 const char *const name = buffer;
284 const size_t name_len = col_ptr - buffer; 284 const size_t name_len = (size_t) (col_ptr - buffer);
285 const size_t val_pos = name_len + 2; 285 const size_t val_pos = name_len + 2;
286 const size_t val_len = data_size - val_pos - 2; /* 2 = strlen("\r\n") */ 286 const size_t val_len = data_size - val_pos - 2; /* 2 = strlen("\r\n") */
287 const char *const value = buffer + val_pos; 287 const char *const value = buffer + val_pos;
@@ -367,8 +367,8 @@ check_uri_cb (void *cls,
367struct mhd_header_checker_param 367struct mhd_header_checker_param
368{ 368{
369 unsigned int num_n1_headers; 369 unsigned int num_n1_headers;
370 unsigned int large_header_name_size; 370 size_t large_header_name_size;
371 unsigned int large_header_value_size; 371 size_t large_header_value_size;
372 int large_header_valid; 372 int large_header_valid;
373}; 373};
374 374
@@ -520,10 +520,10 @@ ahcCheck (void *cls,
520 externalErrorExit (); 520 externalErrorExit ();
521 large_hrd_name[0] = '0'; /* Name starts with zero for unique identification */ 521 large_hrd_name[0] = '0'; /* Name starts with zero for unique identification */
522 for (i = 1; i < large_hdr_name_size; i++) 522 for (i = 1; i < large_hdr_name_size; i++)
523 large_hrd_name[i] = 'a' + i % ('z' - 'a' + 1); 523 large_hrd_name[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1));
524 large_hrd_name[large_hdr_name_size] = 0; 524 large_hrd_name[large_hdr_name_size] = 0;
525 for (i = 0; i < large_hdr_value_size; i++) 525 for (i = 0; i < large_hdr_value_size; i++)
526 large_hrd_value[i] = 'Z' - i % ('Z' - 'A' + 1); 526 large_hrd_value[i] = 'Z' - (char) (unsigned char) (i % ('Z' - 'A' + 1));
527 if (NULL != large_hrd_value) 527 if (NULL != large_hrd_value)
528 large_hrd_value[large_hdr_value_size] = 0; 528 large_hrd_value[large_hdr_value_size] = 0;
529 if (MHD_YES != MHD_add_response_header (response, 529 if (MHD_YES != MHD_add_response_header (response,
@@ -549,7 +549,7 @@ ahcCheck (void *cls,
549 549
550static CURL * 550static CURL *
551curlEasyInitForTest (const char *queryPath, const char *method, 551curlEasyInitForTest (const char *queryPath, const char *method,
552 int port, 552 uint16_t port,
553 struct lcurl_data_cb_param *dcbp, 553 struct lcurl_data_cb_param *dcbp,
554 struct headers_check_result *hdr_chk_result, 554 struct headers_check_result *hdr_chk_result,
555 struct curl_slist *headers) 555 struct curl_slist *headers)
@@ -701,13 +701,13 @@ struct curlQueryParams
701 const char *method; 701 const char *method;
702 702
703 /* Destination port for CURL query */ 703 /* Destination port for CURL query */
704 int queryPort; 704 uint16_t queryPort;
705 705
706 /* List of additional request headers */ 706 /* List of additional request headers */
707 struct curl_slist *headers; 707 struct curl_slist *headers;
708 708
709 /* CURL query result error flag */ 709 /* CURL query result error flag */
710 volatile int queryError; 710 volatile unsigned int queryError;
711 711
712 /* Response HTTP code, zero if no response */ 712 /* Response HTTP code, zero if no response */
713 volatile int responseCode; 713 volatile int responseCode;
@@ -715,7 +715,7 @@ struct curlQueryParams
715 715
716 716
717/* Returns zero for successful response and non-zero for failed response */ 717/* Returns zero for successful response and non-zero for failed response */
718static int 718static unsigned int
719doCurlQueryInThread (struct MHD_Daemon *d, 719doCurlQueryInThread (struct MHD_Daemon *d,
720 struct curlQueryParams *p, 720 struct curlQueryParams *p,
721 struct headers_check_result *hdr_res, 721 struct headers_check_result *hdr_res,
@@ -810,13 +810,13 @@ doCurlQueryInThread (struct MHD_Daemon *d,
810 810
811 811
812/* Perform test queries, shut down MHD daemon, and free parameters */ 812/* Perform test queries, shut down MHD daemon, and free parameters */
813static int 813static unsigned int
814performTestQueries (struct MHD_Daemon *d, int d_port, 814performTestQueries (struct MHD_Daemon *d, uint16_t d_port,
815 struct ahc_cls_type *ahc_param, 815 struct ahc_cls_type *ahc_param,
816 struct check_uri_cls *uri_cb_param) 816 struct check_uri_cls *uri_cb_param)
817{ 817{
818 struct curlQueryParams qParam; 818 struct curlQueryParams qParam;
819 int ret = 0; /* Return value */ 819 unsigned int ret = 0; /* Return value */
820 struct headers_check_result rp_headers_check; 820 struct headers_check_result rp_headers_check;
821 char *buf; 821 char *buf;
822 size_t i; 822 size_t i;
@@ -845,7 +845,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
845 if (large_req_method) 845 if (large_req_method)
846 { 846 {
847 for (i = 0; i < TEST_START_SIZE; i++) 847 for (i = 0; i < TEST_START_SIZE; i++)
848 buf[i] = 'A' + i % ('Z' - 'A' + 1); 848 buf[i] = 'A' + (char) (unsigned char) (i % ('Z' - 'A' + 1));
849 for (; i <= TEST_FAIL_SIZE; i++) 849 for (; i <= TEST_FAIL_SIZE; i++)
850 { 850 {
851 buf[i] = 0; 851 buf[i] = 0;
@@ -890,7 +890,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
890 if (0 != rp_headers_check.large_header_name_size) 890 if (0 != rp_headers_check.large_header_name_size)
891 mhdErrorExitDesc ("Detected unexpected large reply header"); 891 mhdErrorExitDesc ("Detected unexpected large reply header");
892 892
893 buf[i] = 'A' + i % ('Z' - 'A' + 1); 893 buf[i] = 'A' + (char) (unsigned char) (i % ('Z' - 'A' + 1));
894 } 894 }
895 } 895 }
896 else if (large_req_url) 896 else if (large_req_url)
@@ -901,7 +901,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
901 memcpy (buf, URL_SCHEME_HOST, base_size); 901 memcpy (buf, URL_SCHEME_HOST, base_size);
902 url[0] = '/'; 902 url[0] = '/';
903 for (i = 1; i < TEST_START_SIZE; i++) 903 for (i = 1; i < TEST_START_SIZE; i++)
904 url[i] = 'a' + i % ('z' - 'a' + 1); 904 url[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1));
905 for (; i <= TEST_FAIL_SIZE; i++) 905 for (; i <= TEST_FAIL_SIZE; i++)
906 { 906 {
907 url[i] = 0; 907 url[i] = 0;
@@ -947,14 +947,14 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
947 if (0 != rp_headers_check.large_header_name_size) 947 if (0 != rp_headers_check.large_header_name_size)
948 mhdErrorExitDesc ("Detected unexpected large reply header"); 948 mhdErrorExitDesc ("Detected unexpected large reply header");
949 949
950 url[i] = 'a' + i % ('z' - 'a' + 1); 950 url[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1));
951 } 951 }
952 } 952 }
953 else if (large_req_header_name) 953 else if (large_req_header_name)
954 { 954 {
955 buf[0] = '0'; /* Name starts with zero for unique identification */ 955 buf[0] = '0'; /* Name starts with zero for unique identification */
956 for (i = 1; i < TEST_START_SIZE; i++) 956 for (i = 1; i < TEST_START_SIZE; i++)
957 buf[i] = 'a' + i % ('z' - 'a' + 1); 957 buf[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1));
958 for (; i <= TEST_FAIL_SIZE; i++) 958 for (; i <= TEST_FAIL_SIZE; i++)
959 { 959 {
960 struct curl_slist *curl_headers; 960 struct curl_slist *curl_headers;
@@ -1020,7 +1020,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
1020 mhdErrorExitDesc ("Detected unexpected large reply header"); 1020 mhdErrorExitDesc ("Detected unexpected large reply header");
1021 1021
1022 curl_slist_free_all (curl_headers); 1022 curl_slist_free_all (curl_headers);
1023 buf[i] = 'a' + i % ('z' - 'a' + 1); 1023 buf[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1));
1024 } 1024 }
1025 } 1025 }
1026 else if (large_req_header_value) 1026 else if (large_req_header_value)
@@ -1029,7 +1029,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
1029 /* Name starts with zero for unique identification */ 1029 /* Name starts with zero for unique identification */
1030 memcpy (buf, "0: ", 3); /* Note: strlen(": Z") is less than strlen(URL_SCHEME_HOST) */ 1030 memcpy (buf, "0: ", 3); /* Note: strlen(": Z") is less than strlen(URL_SCHEME_HOST) */
1031 for (i = 0; i < TEST_START_SIZE; i++) 1031 for (i = 0; i < TEST_START_SIZE; i++)
1032 hdr_value[i] = 'Z' - i % ('Z' - 'A' + 1); 1032 hdr_value[i] = 'Z' - (char) (unsigned char) (i % ('Z' - 'A' + 1));
1033 for (; i <= TEST_FAIL_SIZE; i++) 1033 for (; i <= TEST_FAIL_SIZE; i++)
1034 { 1034 {
1035 struct curl_slist *curl_headers; 1035 struct curl_slist *curl_headers;
@@ -1094,7 +1094,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
1094 mhdErrorExitDesc ("Detected unexpected large reply header"); 1094 mhdErrorExitDesc ("Detected unexpected large reply header");
1095 1095
1096 curl_slist_free_all (curl_headers); 1096 curl_slist_free_all (curl_headers);
1097 hdr_value[i] = 'Z' - i % ('Z' - 'A' + 1); 1097 hdr_value[i] = 'Z' - (char) (unsigned char) (i % ('Z' - 'A' + 1));
1098 } 1098 }
1099 } 1099 }
1100 else if (large_req_headers) 1100 else if (large_req_headers)
@@ -1353,7 +1353,7 @@ enum testMhdPollType
1353static unsigned int 1353static unsigned int
1354testNumThreadsForPool (enum testMhdPollType pollType) 1354testNumThreadsForPool (enum testMhdPollType pollType)
1355{ 1355{
1356 int numThreads = MHD_CPU_COUNT; 1356 unsigned int numThreads = MHD_CPU_COUNT;
1357 (void) pollType; /* Don't care about pollType for this test */ 1357 (void) pollType; /* Don't care about pollType for this test */
1358 return numThreads; /* No practical limit for non-cleanup test */ 1358 return numThreads; /* No practical limit for non-cleanup test */
1359} 1359}
@@ -1361,7 +1361,7 @@ testNumThreadsForPool (enum testMhdPollType pollType)
1361 1361
1362static struct MHD_Daemon * 1362static struct MHD_Daemon *
1363startTestMhdDaemon (enum testMhdThreadsType thrType, 1363startTestMhdDaemon (enum testMhdThreadsType thrType,
1364 enum testMhdPollType pollType, int *pport, 1364 enum testMhdPollType pollType, uint16_t *pport,
1365 struct ahc_cls_type **ahc_param, 1365 struct ahc_cls_type **ahc_param,
1366 struct check_uri_cls **uri_cb_param) 1366 struct check_uri_cls **uri_cb_param)
1367{ 1367{
@@ -1404,7 +1404,7 @@ startTestMhdDaemon (enum testMhdThreadsType thrType,
1404 } 1404 }
1405 1405
1406 if (testMhdThreadInternalPool != thrType) 1406 if (testMhdThreadInternalPool != thrType)
1407 d = MHD_start_daemon (((int) thrType) | ((int) pollType) 1407 d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType)
1408 | (verbose ? MHD_USE_ERROR_LOG : 0), 1408 | (verbose ? MHD_USE_ERROR_LOG : 0),
1409 *pport, NULL, NULL, 1409 *pport, NULL, NULL,
1410 &ahcCheck, *ahc_param, 1410 &ahcCheck, *ahc_param,
@@ -1414,7 +1414,8 @@ startTestMhdDaemon (enum testMhdThreadsType thrType,
1414 (size_t) BUFFER_SIZE, 1414 (size_t) BUFFER_SIZE,
1415 MHD_OPTION_END); 1415 MHD_OPTION_END);
1416 else 1416 else
1417 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | ((int) pollType) 1417 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD
1418 | ((unsigned int) pollType)
1418 | (verbose ? MHD_USE_ERROR_LOG : 0), 1419 | (verbose ? MHD_USE_ERROR_LOG : 0),
1419 *pport, NULL, NULL, 1420 *pport, NULL, NULL,
1420 &ahcCheck, *ahc_param, 1421 &ahcCheck, *ahc_param,
@@ -1440,7 +1441,7 @@ startTestMhdDaemon (enum testMhdThreadsType thrType,
1440 fprintf (stderr, "MHD_get_daemon_info() failed.\n"); 1441 fprintf (stderr, "MHD_get_daemon_info() failed.\n");
1441 abort (); 1442 abort ();
1442 } 1443 }
1443 *pport = (int) dinfo->port; 1444 *pport = dinfo->port;
1444 if (0 == global_port) 1445 if (0 == global_port)
1445 global_port = *pport; /* Reuse the same port for all tests */ 1446 global_port = *pport; /* Reuse the same port for all tests */
1446 } 1447 }
@@ -1452,11 +1453,11 @@ startTestMhdDaemon (enum testMhdThreadsType thrType,
1452/* Test runners */ 1453/* Test runners */
1453 1454
1454 1455
1455static int 1456static unsigned int
1456testExternalGet (void) 1457testExternalGet (void)
1457{ 1458{
1458 struct MHD_Daemon *d; 1459 struct MHD_Daemon *d;
1459 int d_port = global_port; /* Daemon's port */ 1460 uint16_t d_port = global_port; /* Daemon's port */
1460 struct ahc_cls_type *ahc_param; 1461 struct ahc_cls_type *ahc_param;
1461 struct check_uri_cls *uri_cb_param; 1462 struct check_uri_cls *uri_cb_param;
1462 1463
@@ -1467,11 +1468,11 @@ testExternalGet (void)
1467} 1468}
1468 1469
1469 1470
1470static int 1471static unsigned int
1471testInternalGet (enum testMhdPollType pollType) 1472testInternalGet (enum testMhdPollType pollType)
1472{ 1473{
1473 struct MHD_Daemon *d; 1474 struct MHD_Daemon *d;
1474 int d_port = global_port; /* Daemon's port */ 1475 uint16_t d_port = global_port; /* Daemon's port */
1475 struct ahc_cls_type *ahc_param; 1476 struct ahc_cls_type *ahc_param;
1476 struct check_uri_cls *uri_cb_param; 1477 struct check_uri_cls *uri_cb_param;
1477 1478
@@ -1482,11 +1483,11 @@ testInternalGet (enum testMhdPollType pollType)
1482} 1483}
1483 1484
1484 1485
1485static int 1486static unsigned int
1486testMultithreadedGet (enum testMhdPollType pollType) 1487testMultithreadedGet (enum testMhdPollType pollType)
1487{ 1488{
1488 struct MHD_Daemon *d; 1489 struct MHD_Daemon *d;
1489 int d_port = global_port; /* Daemon's port */ 1490 uint16_t d_port = global_port; /* Daemon's port */
1490 struct ahc_cls_type *ahc_param; 1491 struct ahc_cls_type *ahc_param;
1491 struct check_uri_cls *uri_cb_param; 1492 struct check_uri_cls *uri_cb_param;
1492 1493
@@ -1496,11 +1497,11 @@ testMultithreadedGet (enum testMhdPollType pollType)
1496} 1497}
1497 1498
1498 1499
1499static int 1500static unsigned int
1500testMultithreadedPoolGet (enum testMhdPollType pollType) 1501testMultithreadedPoolGet (enum testMhdPollType pollType)
1501{ 1502{
1502 struct MHD_Daemon *d; 1503 struct MHD_Daemon *d;
1503 int d_port = global_port; /* Daemon's port */ 1504 uint16_t d_port = global_port; /* Daemon's port */
1504 struct ahc_cls_type *ahc_param; 1505 struct ahc_cls_type *ahc_param;
1505 struct check_uri_cls *uri_cb_param; 1506 struct check_uri_cls *uri_cb_param;
1506 1507