aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-12-22 20:17:55 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-12-22 20:17:55 +0300
commit4dadf8ec97d74ab2034452833067ee5e7a6ee25f (patch)
treeabdc238333377de03a5e66923822f6e542cc2015
parent012ae6c1c7e2f56ff9379df47005e5b5777e6c8c (diff)
downloadlibmicrohttpd-4dadf8ec97d74ab2034452833067ee5e7a6ee25f.tar.gz
libmicrohttpd-4dadf8ec97d74ab2034452833067ee5e7a6ee25f.zip
Updated parsing of cookies, reject cookie completely if discipline is very strict
-rw-r--r--src/microhttpd/connection.c25
-rw-r--r--src/testcurl/Makefile.am24
-rw-r--r--src/testcurl/test_parse_cookies.c157
3 files changed, 156 insertions, 50 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 1c6070e8..b983e7ed 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2850,7 +2850,7 @@ parse_cookies_string (char *str,
2850 /* Allow whitespaces around '=' character */ 2850 /* Allow whitespaces around '=' character */
2851 const bool wsp_around_eq = (-3 >= connection->daemon->client_discipline); 2851 const bool wsp_around_eq = (-3 >= connection->daemon->client_discipline);
2852 /* Allow whitespaces in quoted cookie value */ 2852 /* Allow whitespaces in quoted cookie value */
2853 const bool wsp_in_quoted = (0 >= connection->daemon->client_discipline); 2853 const bool wsp_in_quoted = (-2 >= connection->daemon->client_discipline);
2854 /* Allow tab as space after semicolon between cookies */ 2854 /* Allow tab as space after semicolon between cookies */
2855 const bool tab_as_sp = (0 >= connection->daemon->client_discipline); 2855 const bool tab_as_sp = (0 >= connection->daemon->client_discipline);
2856 /* Allow no space after semicolon between cookies */ 2856 /* Allow no space after semicolon between cookies */
@@ -3048,8 +3048,10 @@ parse_cookie_header (struct MHD_Connection *connection)
3048 char *cpy; 3048 char *cpy;
3049 size_t i; 3049 size_t i;
3050 enum _MHD_ParseCookie parse_res; 3050 enum _MHD_ParseCookie parse_res;
3051 const struct MHD_HTTP_Req_Header *const saved_tail = 3051 struct MHD_HTTP_Req_Header *const saved_tail =
3052 connection->rq.headers_received_tail; 3052 connection->rq.headers_received_tail;
3053 const bool allow_partially_correct_cookie =
3054 (1 >= connection->daemon->client_discipline);
3053 3055
3054 if (MHD_NO == 3056 if (MHD_NO ==
3055 MHD_lookup_connection_value_n (connection, 3057 MHD_lookup_connection_value_n (connection,
@@ -3097,9 +3099,22 @@ parse_cookie_header (struct MHD_Connection *connection)
3097 case MHD_PARSE_COOKIE_MALFORMED: 3099 case MHD_PARSE_COOKIE_MALFORMED:
3098#ifdef HAVE_MESSAGES 3100#ifdef HAVE_MESSAGES
3099 if (saved_tail != connection->rq.headers_received_tail) 3101 if (saved_tail != connection->rq.headers_received_tail)
3100 MHD_DLOG (connection->daemon, 3102 {
3101 _ ("The Cookie header has been only partially parsed as it " 3103 if (allow_partially_correct_cookie)
3102 "contains malformed data.\n")); 3104 MHD_DLOG (connection->daemon,
3105 _ ("The Cookie header has been only partially parsed as it "
3106 "contains malformed data.\n"));
3107 else
3108 {
3109 /* Remove extracted values from partially broken cookie */
3110 /* Memory remains allocated until the end of the request processing */
3111 connection->rq.headers_received_tail = saved_tail;
3112 saved_tail->next = NULL;
3113 MHD_DLOG (connection->daemon,
3114 _ ("The Cookie header has been ignored as it contains "
3115 "malformed data.\n"));
3116 }
3117 }
3103 else 3118 else
3104 MHD_DLOG (connection->daemon, 3119 MHD_DLOG (connection->daemon,
3105 _ ("The Cookie header has malformed data.\n")); 3120 _ ("The Cookie header has malformed data.\n"));
diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am
index 0d190f9d..74583ff6 100644
--- a/src/testcurl/Makefile.am
+++ b/src/testcurl/Makefile.am
@@ -144,9 +144,11 @@ check_PROGRAMS = \
144 144
145if ENABLE_COOKIE 145if ENABLE_COOKIE
146check_PROGRAMS += \ 146check_PROGRAMS += \
147 test_parse_cookies_strict_p1 \ 147 test_parse_cookies_discp_p2 \
148 test_parse_cookies_strict_zero \ 148 test_parse_cookies_discp_p1 \
149 test_parse_cookies_strict_n1 149 test_parse_cookies_discp_zero \
150 test_parse_cookies_discp_n2 \
151 test_parse_cookies_discp_n3
150endif 152endif
151 153
152if HEAVY_TESTS 154if HEAVY_TESTS
@@ -468,14 +470,20 @@ test_post_SOURCES = \
468test_process_headers_SOURCES = \ 470test_process_headers_SOURCES = \
469 test_process_headers.c mhd_has_in_name.h 471 test_process_headers.c mhd_has_in_name.h
470 472
471test_parse_cookies_strict_zero_SOURCES = \ 473test_parse_cookies_discp_zero_SOURCES = \
472 test_parse_cookies.c mhd_has_in_name.h mhd_has_param.h 474 test_parse_cookies.c mhd_has_in_name.h mhd_has_param.h
473 475
474test_parse_cookies_strict_p1_SOURCES = \ 476test_parse_cookies_discp_p2_SOURCES = \
475 $(test_parse_cookies_strict_zero_SOURCES) 477 $(test_parse_cookies_discp_zero_SOURCES)
476 478
477test_parse_cookies_strict_n1_SOURCES = \ 479test_parse_cookies_discp_p1_SOURCES = \
478 $(test_parse_cookies_strict_zero_SOURCES) 480 $(test_parse_cookies_discp_zero_SOURCES)
481
482test_parse_cookies_discp_n2_SOURCES = \
483 $(test_parse_cookies_discp_zero_SOURCES)
484
485test_parse_cookies_discp_n3_SOURCES = \
486 $(test_parse_cookies_discp_zero_SOURCES)
479 487
480test_process_arguments_SOURCES = \ 488test_process_arguments_SOURCES = \
481 test_process_arguments.c mhd_has_in_name.h 489 test_process_arguments.c mhd_has_in_name.h
diff --git a/src/testcurl/test_parse_cookies.c b/src/testcurl/test_parse_cookies.c
index 308b751e..a7c57611 100644
--- a/src/testcurl/test_parse_cookies.c
+++ b/src/testcurl/test_parse_cookies.c
@@ -237,10 +237,11 @@ struct strct_test_data
237{ 237{
238 unsigned int line_num; 238 unsigned int line_num;
239 const char *header_str; 239 const char *header_str;
240 unsigned int num_cookies_strict_p2; /* Reserved */ 240 unsigned int num_cookies_strict_p2;
241 unsigned int num_cookies_strict_p1; 241 unsigned int num_cookies_strict_p1;
242 unsigned int num_cookies_strict_zero; 242 unsigned int num_cookies_strict_zero;
243 unsigned int num_cookies_strict_n1; 243 unsigned int num_cookies_strict_n2;
244 unsigned int num_cookies_strict_n3;
244 struct strct_cookie cookies[5]; 245 struct strct_cookie cookies[5];
245}; 246};
246 247
@@ -252,6 +253,7 @@ static const struct strct_test_data test_data[] = {
252 1, 253 1,
253 1, 254 1,
254 1, 255 1,
256 1,
255 { 257 {
256 COOKIE_ ("name1", "value1"), 258 COOKIE_ ("name1", "value1"),
257 COOKIE_NULL, 259 COOKIE_NULL,
@@ -263,6 +265,7 @@ static const struct strct_test_data test_data[] = {
263 { 265 {
264 __LINE__, 266 __LINE__,
265 "name1=value1;", 267 "name1=value1;",
268 0,
266 1, 269 1,
267 1, 270 1,
268 1, 271 1,
@@ -282,6 +285,7 @@ static const struct strct_test_data test_data[] = {
282 1, 285 1,
283 1, 286 1,
284 1, 287 1,
288 1,
285 { 289 {
286 COOKIE_ ("name1", "value1"), 290 COOKIE_ ("name1", "value1"),
287 COOKIE_NULL, 291 COOKIE_NULL,
@@ -297,6 +301,7 @@ static const struct strct_test_data test_data[] = {
297 0, 301 0,
298 1, 302 1,
299 1, 303 1,
304 1,
300 { 305 {
301 COOKIE_ ("name1", "value1"), 306 COOKIE_ ("name1", "value1"),
302 COOKIE_NULL, 307 COOKIE_NULL,
@@ -312,6 +317,7 @@ static const struct strct_test_data test_data[] = {
312 0, 317 0,
313 1, 318 1,
314 1, 319 1,
320 1,
315 { 321 {
316 COOKIE_ ("name1", "value1"), 322 COOKIE_ ("name1", "value1"),
317 COOKIE_NULL, 323 COOKIE_NULL,
@@ -327,6 +333,7 @@ static const struct strct_test_data test_data[] = {
327 1, 333 1,
328 1, 334 1,
329 1, 335 1,
336 1,
330 { 337 {
331 COOKIE_ ("name1", "value1"), 338 COOKIE_ ("name1", "value1"),
332 COOKIE_NULL, 339 COOKIE_NULL,
@@ -342,6 +349,7 @@ static const struct strct_test_data test_data[] = {
342 0, 349 0,
343 1, 350 1,
344 1, 351 1,
352 1,
345 { 353 {
346 COOKIE_ ("name1", "value1"), 354 COOKIE_ ("name1", "value1"),
347 COOKIE_NULL, 355 COOKIE_NULL,
@@ -357,6 +365,7 @@ static const struct strct_test_data test_data[] = {
357 0, 365 0,
358 1, 366 1,
359 1, 367 1,
368 1,
360 { 369 {
361 COOKIE_ ("name1", "value1"), 370 COOKIE_ ("name1", "value1"),
362 COOKIE_NULL, 371 COOKIE_NULL,
@@ -370,6 +379,7 @@ static const struct strct_test_data test_data[] = {
370 "name2=\"value 2\"", 379 "name2=\"value 2\"",
371 0, 380 0,
372 0, 381 0,
382 0,
373 1, 383 1,
374 1, 384 1,
375 { 385 {
@@ -387,6 +397,7 @@ static const struct strct_test_data test_data[] = {
387 1, 397 1,
388 2, 398 2,
389 2, 399 2,
400 2,
390 { 401 {
391 COOKIE_ ("name1", "value1"), 402 COOKIE_ ("name1", "value1"),
392 COOKIE_ ("name2", "value2"), 403 COOKIE_ ("name2", "value2"),
@@ -402,9 +413,10 @@ static const struct strct_test_data test_data[] = {
402 2, 413 2,
403 2, 414 2,
404 2, 415 2,
416 2,
405 { 417 {
406 COOKIE_ ("name1", "value1"), 418 COOKIE_ ("name1", "value1"),
407 COOKIE_ ("name1", "value1"), 419 COOKIE_ ("name1", "value1"), /* The second value is not checked actually */
408 COOKIE_NULL, 420 COOKIE_NULL,
409 COOKIE_NULL, 421 COOKIE_NULL,
410 COOKIE_NULL 422 COOKIE_NULL
@@ -417,6 +429,7 @@ static const struct strct_test_data test_data[] = {
417 2, 429 2,
418 2, 430 2,
419 2, 431 2,
432 2,
420 { 433 {
421 COOKIE_ ("name1", "value1"), 434 COOKIE_ ("name1", "value1"),
422 COOKIE_ ("name2", "value2"), 435 COOKIE_ ("name2", "value2"),
@@ -427,7 +440,8 @@ static const struct strct_test_data test_data[] = {
427 }, 440 },
428 { 441 {
429 __LINE__, 442 __LINE__,
430 "name1=value1; name2=value2", 443 "name1=value1; name2=value2 ",
444 2,
431 2, 445 2,
432 2, 446 2,
433 2, 447 2,
@@ -442,8 +456,9 @@ static const struct strct_test_data test_data[] = {
442 }, 456 },
443 { 457 {
444 __LINE__, 458 __LINE__,
445 "name1=value1; name2=value2", 459 "name1=value1; name2=value2",
446 2, 460 0,
461 1,
447 2, 462 2,
448 2, 463 2,
449 2, 464 2,
@@ -457,8 +472,9 @@ static const struct strct_test_data test_data[] = {
457 }, 472 },
458 { 473 {
459 __LINE__, 474 __LINE__,
460 "name1=value1; name2=value2", 475 "name1=value1;name2=value2",
461 2, 476 0,
477 1,
462 2, 478 2,
463 2, 479 2,
464 2, 480 2,
@@ -472,8 +488,9 @@ static const struct strct_test_data test_data[] = {
472 }, 488 },
473 { 489 {
474 __LINE__, 490 __LINE__,
475 "name1=value1; name2=value2", 491 "name1=value1;\tname2=value2",
476 2, 492 0,
493 1,
477 2, 494 2,
478 2, 495 2,
479 2, 496 2,
@@ -487,8 +504,9 @@ static const struct strct_test_data test_data[] = {
487 }, 504 },
488 { 505 {
489 __LINE__, 506 __LINE__,
490 "name1=value1; name2=value2", 507 "name1=value1 ; name2=value2",
491 2, 508 0,
509 0,
492 2, 510 2,
493 2, 511 2,
494 2, 512 2,
@@ -502,7 +520,8 @@ static const struct strct_test_data test_data[] = {
502 }, 520 },
503 { 521 {
504 __LINE__, 522 __LINE__,
505 "name1=value1; name2=value2", 523 " name1=value1; name2=value2",
524 2,
506 2, 525 2,
507 2, 526 2,
508 2, 527 2,
@@ -522,6 +541,7 @@ static const struct strct_test_data test_data[] = {
522 "name5=var_with_=_char", 541 "name5=var_with_=_char",
523 0, 542 0,
524 3, 543 3,
544 3,
525 5, 545 5,
526 5, 546 5,
527 { 547 {
@@ -539,6 +559,7 @@ static const struct strct_test_data test_data[] = {
539 "name5=var_with_=_char", 559 "name5=var_with_=_char",
540 0, 560 0,
541 1, 561 1,
562 3,
542 5, 563 5,
543 5, 564 5,
544 { 565 {
@@ -556,6 +577,7 @@ static const struct strct_test_data test_data[] = {
556 "name5=var_with_=_char\t \t", 577 "name5=var_with_=_char\t \t",
557 0, 578 0,
558 1, 579 1,
580 3,
559 5, 581 5,
560 5, 582 5,
561 { 583 {
@@ -573,6 +595,7 @@ static const struct strct_test_data test_data[] = {
573 "name5=var_with_=_char;\t \t", 595 "name5=var_with_=_char;\t \t",
574 0, 596 0,
575 1, 597 1,
598 3,
576 5, 599 5,
577 5, 600 5,
578 { 601 {
@@ -590,6 +613,7 @@ static const struct strct_test_data test_data[] = {
590 "name4=\"var4 with spaces\"", 613 "name4=\"var4 with spaces\"",
591 0, 614 0,
592 4, 615 4,
616 4,
593 5, 617 5,
594 5, 618 5,
595 { 619 {
@@ -607,6 +631,7 @@ static const struct strct_test_data test_data[] = {
607 "name4=\"var4 with spaces\";", 631 "name4=\"var4 with spaces\";",
608 0, 632 0,
609 4, 633 4,
634 4,
610 5, 635 5,
611 5, 636 5,
612 { 637 {
@@ -624,6 +649,7 @@ static const struct strct_test_data test_data[] = {
624 "name4=\"var4 with spaces\"; name3=", 649 "name4=\"var4 with spaces\"; name3=",
625 0, 650 0,
626 3, 651 3,
652 3,
627 5, 653 5,
628 5, 654 5,
629 { 655 {
@@ -641,6 +667,7 @@ static const struct strct_test_data test_data[] = {
641 "name5=var_with_=_char; name3=;", 667 "name5=var_with_=_char; name3=;",
642 0, 668 0,
643 2, 669 2,
670 2,
644 5, 671 5,
645 5, 672 5,
646 { 673 {
@@ -658,6 +685,7 @@ static const struct strct_test_data test_data[] = {
658 "name5=var_with_=_char", 685 "name5=var_with_=_char",
659 0, 686 0,
660 0, 687 0,
688 3,
661 5, 689 5,
662 5, 690 5,
663 { 691 {
@@ -675,6 +703,7 @@ static const struct strct_test_data test_data[] = {
675 "name5=var_with_=_char", 703 "name5=var_with_=_char",
676 0, 704 0,
677 3, 705 3,
706 3,
678 5, 707 5,
679 5, 708 5,
680 { 709 {
@@ -692,6 +721,7 @@ static const struct strct_test_data test_data[] = {
692 "name5=var_with_=_char;;;;;;;;", 721 "name5=var_with_=_char;;;;;;;;",
693 0, 722 0,
694 3, 723 3,
724 3,
695 5, 725 5,
696 5, 726 5,
697 { 727 {
@@ -709,6 +739,7 @@ static const struct strct_test_data test_data[] = {
709 "name5=var_with_=_char; ; ; ; ; name3=", 739 "name5=var_with_=_char; ; ; ; ; name3=",
710 0, 740 0,
711 2, 741 2,
742 2,
712 5, 743 5,
713 5, 744 5,
714 { 745 {
@@ -726,14 +757,15 @@ static const struct strct_test_data test_data[] = {
726 "name4=\"var4 with spaces\" ", 757 "name4=\"var4 with spaces\" ",
727 0, 758 0,
728 0, 759 0,
760 4,
729 5, 761 5,
730 5, 762 5,
731 { 763 {
732 COOKIE_ ("name1", "var1"), 764 COOKIE_ ("name1", "var1"),
733 COOKIE_ ("name2", "var2"), 765 COOKIE_ ("name2", "var2"),
734 COOKIE_ ("name3", ""), 766 COOKIE_ ("name3", ""),
735 COOKIE_ ("name4", "var4 with spaces"), 767 COOKIE_ ("name5", "var_with_=_char"),
736 COOKIE_ ("name5", "var_with_=_char") 768 COOKIE_ ("name4", "var4 with spaces")
737 } 769 }
738 }, 770 },
739 { 771 {
@@ -742,6 +774,7 @@ static const struct strct_test_data test_data[] = {
742 "name1=var1; name2=var2; name3=", 774 "name1=var1; name2=var2; name3=",
743 0, 775 0,
744 1, 776 1,
777 1,
745 5, 778 5,
746 5, 779 5,
747 { 780 {
@@ -754,10 +787,28 @@ static const struct strct_test_data test_data[] = {
754 }, 787 },
755 { 788 {
756 __LINE__, 789 __LINE__,
790 "name5=var_with_=_char; name4=\"var4_without_spaces\"; " \
791 "name1=var1; name2=var2; name3=",
792 5,
793 5,
794 5,
795 5,
796 5,
797 {
798 COOKIE_ ("name5", "var_with_=_char"),
799 COOKIE_ ("name1", "var1"),
800 COOKIE_ ("name2", "var2"),
801 COOKIE_ ("name3", ""),
802 COOKIE_ ("name4", "var4_without_spaces")
803 }
804 },
805 {
806 __LINE__,
757 "name1 = value1", 807 "name1 = value1",
758 0, 808 0,
759 0, 809 0,
760 0, 810 0,
811 0,
761 1, 812 1,
762 { 813 {
763 COOKIE_ ("name1", "value1"), 814 COOKIE_ ("name1", "value1"),
@@ -773,6 +824,7 @@ static const struct strct_test_data test_data[] = {
773 0, 824 0,
774 0, 825 0,
775 0, 826 0,
827 0,
776 1, 828 1,
777 { 829 {
778 COOKIE_ ("name1", "value1"), 830 COOKIE_ ("name1", "value1"),
@@ -788,6 +840,7 @@ static const struct strct_test_data test_data[] = {
788 0, 840 0,
789 0, 841 0,
790 0, 842 0,
843 0,
791 1, 844 1,
792 { 845 {
793 COOKIE_ ("name1", "value1"), 846 COOKIE_ ("name1", "value1"),
@@ -803,6 +856,7 @@ static const struct strct_test_data test_data[] = {
803 0, 856 0,
804 0, 857 0,
805 0, 858 0,
859 0,
806 2, 860 2,
807 { 861 {
808 COOKIE_ ("name1", "value1"), 862 COOKIE_ ("name1", "value1"),
@@ -818,6 +872,7 @@ static const struct strct_test_data test_data[] = {
818 0, 872 0,
819 1, 873 1,
820 1, 874 1,
875 1,
821 2, 876 2,
822 { 877 {
823 COOKIE_ ("name1", "value1"), 878 COOKIE_ ("name1", "value1"),
@@ -833,6 +888,7 @@ static const struct strct_test_data test_data[] = {
833 0, 888 0,
834 0, 889 0,
835 0, 890 0,
891 0,
836 2, 892 2,
837 { 893 {
838 COOKIE_ ("name1", "value1"), 894 COOKIE_ ("name1", "value1"),
@@ -849,6 +905,7 @@ static const struct strct_test_data test_data[] = {
849 0, 905 0,
850 0, 906 0,
851 0, 907 0,
908 0,
852 { 909 {
853 COOKIE_NULL, 910 COOKIE_NULL,
854 COOKIE_NULL, 911 COOKIE_NULL,
@@ -864,6 +921,7 @@ static const struct strct_test_data test_data[] = {
864 0, 921 0,
865 0, 922 0,
866 0, 923 0,
924 0,
867 { 925 {
868 COOKIE_NULL, 926 COOKIE_NULL,
869 COOKIE_NULL, 927 COOKIE_NULL,
@@ -879,6 +937,7 @@ static const struct strct_test_data test_data[] = {
879 0, 937 0,
880 0, 938 0,
881 0, 939 0,
940 0,
882 { 941 {
883 COOKIE_NULL, 942 COOKIE_NULL,
884 COOKIE_NULL, 943 COOKIE_NULL,
@@ -894,6 +953,7 @@ static const struct strct_test_data test_data[] = {
894 0, 953 0,
895 0, 954 0,
896 0, 955 0,
956 0,
897 { 957 {
898 COOKIE_NULL, 958 COOKIE_NULL,
899 COOKIE_NULL, 959 COOKIE_NULL,
@@ -909,6 +969,7 @@ static const struct strct_test_data test_data[] = {
909 0, 969 0,
910 0, 970 0,
911 0, 971 0,
972 0,
912 { 973 {
913 COOKIE_NULL, 974 COOKIE_NULL,
914 COOKIE_NULL, 975 COOKIE_NULL,
@@ -924,6 +985,7 @@ static const struct strct_test_data test_data[] = {
924 0, 985 0,
925 0, 986 0,
926 0, 987 0,
988 0,
927 { 989 {
928 COOKIE_NULL, 990 COOKIE_NULL,
929 COOKIE_NULL, 991 COOKIE_NULL,
@@ -939,6 +1001,7 @@ static const struct strct_test_data test_data[] = {
939 0, 1001 0,
940 0, 1002 0,
941 0, 1003 0,
1004 0,
942 { 1005 {
943 COOKIE_NULL, 1006 COOKIE_NULL,
944 COOKIE_NULL, 1007 COOKIE_NULL,
@@ -954,6 +1017,7 @@ static const struct strct_test_data test_data[] = {
954 0, 1017 0,
955 0, 1018 0,
956 0, 1019 0,
1020 0,
957 { 1021 {
958 COOKIE_NULL, 1022 COOKIE_NULL,
959 COOKIE_NULL, 1023 COOKIE_NULL,
@@ -969,6 +1033,7 @@ static const struct strct_test_data test_data[] = {
969 0, 1033 0,
970 0, 1034 0,
971 0, 1035 0,
1036 0,
972 { 1037 {
973 COOKIE_NULL, 1038 COOKIE_NULL,
974 COOKIE_NULL, 1039 COOKIE_NULL,
@@ -984,6 +1049,7 @@ static const struct strct_test_data test_data[] = {
984 0, 1049 0,
985 0, 1050 0,
986 0, 1051 0,
1052 0,
987 { 1053 {
988 COOKIE_NULL, 1054 COOKIE_NULL,
989 COOKIE_NULL, 1055 COOKIE_NULL,
@@ -999,6 +1065,7 @@ static const struct strct_test_data test_data[] = {
999 0, 1065 0,
1000 0, 1066 0,
1001 0, 1067 0,
1068 0,
1002 { 1069 {
1003 COOKIE_NULL, 1070 COOKIE_NULL,
1004 COOKIE_NULL, 1071 COOKIE_NULL,
@@ -1014,6 +1081,7 @@ static const struct strct_test_data test_data[] = {
1014 0, 1081 0,
1015 0, 1082 0,
1016 0, 1083 0,
1084 0,
1017 { 1085 {
1018 COOKIE_NULL, 1086 COOKIE_NULL,
1019 COOKIE_NULL, 1087 COOKIE_NULL,
@@ -1029,6 +1097,7 @@ static const struct strct_test_data test_data[] = {
1029 0, 1097 0,
1030 0, 1098 0,
1031 0, 1099 0,
1100 0,
1032 { 1101 {
1033 COOKIE_NULL, 1102 COOKIE_NULL,
1034 COOKIE_NULL, 1103 COOKIE_NULL,
@@ -1044,6 +1113,7 @@ static const struct strct_test_data test_data[] = {
1044 0, 1113 0,
1045 0, 1114 0,
1046 0, 1115 0,
1116 0,
1047 { 1117 {
1048 COOKIE_NULL, 1118 COOKIE_NULL,
1049 COOKIE_NULL, 1119 COOKIE_NULL,
@@ -1057,10 +1127,12 @@ static const struct strct_test_data test_data[] = {
1057/* Global parameters */ 1127/* Global parameters */
1058static int verbose; 1128static int verbose;
1059static int oneone; /**< If false use HTTP/1.0 for requests*/ 1129static int oneone; /**< If false use HTTP/1.0 for requests*/
1060static int use_strict_n1; 1130static int use_discp_n3;
1061static int use_strict_zero; 1131static int use_discp_n2;
1062static int use_strict_p1; 1132static int use_discp_zero;
1063static int strict_level; 1133static int use_discp_p1;
1134static int use_discp_p2;
1135static int discp_level;
1064 1136
1065static void 1137static void
1066test_global_init (void) 1138test_global_init (void)
@@ -1128,12 +1200,16 @@ ahcCheck (void *cls,
1128 unsigned int i; 1200 unsigned int i;
1129 int cookie_failed; 1201 int cookie_failed;
1130 1202
1131 if (use_strict_p1) 1203 if (use_discp_p2)
1204 expected_num_cookies = param->check->num_cookies_strict_p2;
1205 else if (use_discp_p1)
1132 expected_num_cookies = param->check->num_cookies_strict_p1; 1206 expected_num_cookies = param->check->num_cookies_strict_p1;
1133 else if (use_strict_zero) 1207 else if (use_discp_zero)
1134 expected_num_cookies = param->check->num_cookies_strict_zero; 1208 expected_num_cookies = param->check->num_cookies_strict_zero;
1135 else if (use_strict_n1) 1209 else if (use_discp_n2)
1136 expected_num_cookies = param->check->num_cookies_strict_n1; 1210 expected_num_cookies = param->check->num_cookies_strict_n2;
1211 else if (use_discp_n3)
1212 expected_num_cookies = param->check->num_cookies_strict_n3;
1137 else 1213 else
1138 externalErrorExit (); 1214 externalErrorExit ();
1139 1215
@@ -1565,13 +1641,13 @@ testExternalPolling (void)
1565 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 1641 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
1566 port = 0; 1642 port = 0;
1567 else 1643 else
1568 port = 1340 + oneone ? 0 : 6 + (uint16_t) (1 + strict_level); 1644 port = 1340 + oneone ? 0 : 6 + (uint16_t) (1 + discp_level);
1569 1645
1570 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 1646 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
1571 port, NULL, NULL, 1647 port, NULL, NULL,
1572 &ahcCheck, &ahc_param, 1648 &ahcCheck, &ahc_param,
1573 MHD_OPTION_STRICT_FOR_CLIENT, 1649 MHD_OPTION_CLIENT_DISCIPLINE_LVL,
1574 (int) (strict_level), 1650 (int) (discp_level),
1575 MHD_OPTION_END); 1651 MHD_OPTION_END);
1576 if (d == NULL) 1652 if (d == NULL)
1577 return 1; 1653 return 1;
@@ -1640,19 +1716,26 @@ main (int argc, char *const *argv)
1640 has_param (argc, argv, "-s") || 1716 has_param (argc, argv, "-s") ||
1641 has_param (argc, argv, "--silent")); 1717 has_param (argc, argv, "--silent"));
1642 oneone = ! has_in_name (argv[0], "10"); 1718 oneone = ! has_in_name (argv[0], "10");
1643 use_strict_n1 = has_in_name (argv[0], "_strict_n1"); 1719 use_discp_n3 = has_in_name (argv[0], "_discp_n3");
1644 use_strict_zero = has_in_name (argv[0], "_strict_zero"); 1720 use_discp_n2 = has_in_name (argv[0], "_discp_n2");
1645 use_strict_p1 = has_in_name (argv[0], "_strict_p1"); 1721 use_discp_zero = has_in_name (argv[0], "_discp_zero");
1646 if (1 != ((use_strict_n1 ? 1 : 0) + (use_strict_zero ? 1 : 0) 1722 use_discp_p1 = has_in_name (argv[0], "_discp_p1");
1647 + (use_strict_p1 ? 1 : 0))) 1723 use_discp_p2 = has_in_name (argv[0], "_discp_p2");
1724 if (1 != ((use_discp_n3 ? 1 : 0) + (use_discp_n2 ? 1 : 0)
1725 + (use_discp_zero ? 1 : 0)
1726 + (use_discp_p1 ? 1 : 0) + (use_discp_p2 ? 1 : 0)))
1648 return 99; 1727 return 99;
1649 1728
1650 if (use_strict_n1) 1729 if (use_discp_n3)
1651 strict_level = -1; 1730 discp_level = -3;
1652 else if (use_strict_zero) 1731 else if (use_discp_n2)
1653 strict_level = 0; 1732 discp_level = -2;
1654 else if (use_strict_p1) 1733 else if (use_discp_zero)
1655 strict_level = 1; 1734 discp_level = 0;
1735 else if (use_discp_p1)
1736 discp_level = 1;
1737 else if (use_discp_p2)
1738 discp_level = 2;
1656 1739
1657 test_global_init (); 1740 test_global_init ();
1658 1741