comparison src/core/ngx_string.c @ 526:0161f3197817 NGINX_0_8_15

nginx 0.8.15 *) Security: a segmentation fault might occur in worker process while specially crafted request handling. Thanks to Chris Ries. *) Bugfix: if names .domain.tld, .sub.domain.tld, and .domain-some.tld were defined, then the name .sub.domain.tld was matched by .domain.tld. *) Bugfix: in transparency support in the ngx_http_image_filter_module. *) Bugfix: in file AIO. *) Bugfix: in X-Accel-Redirect usage; the bug had appeared in 0.8.11. *) Bugfix: in embedded perl module; the bug had appeared in 0.8.11.
author Igor Sysoev <http://sysoev.ru>
date Mon, 14 Sep 2009 00:00:00 +0400
parents 86dad910eeb6
children c04fa65fe604
comparison
equal deleted inserted replaced
525:1b64f9884263 526:0161f3197817
566 566
567 for ( ;; ) { 567 for ( ;; ) {
568 c1 = (ngx_uint_t) *s1++; 568 c1 = (ngx_uint_t) *s1++;
569 c2 = (ngx_uint_t) *s2++; 569 c2 = (ngx_uint_t) *s2++;
570 570
571 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; 571 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1;
572 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; 572 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2;
573 573
574 if (c1 == c2) { 574 if (c1 == c2) {
575 575
576 if (c1) { 576 if (c1) {
577 continue; 577 continue;
592 592
593 while (n) { 593 while (n) {
594 c1 = (ngx_uint_t) *s1++; 594 c1 = (ngx_uint_t) *s1++;
595 c2 = (ngx_uint_t) *s2++; 595 c2 = (ngx_uint_t) *s2++;
596 596
597 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; 597 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1;
598 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; 598 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2;
599 599
600 if (c1 == c2) { 600 if (c1 == c2) {
601 601
602 if (c1) { 602 if (c1) {
603 n--; 603 n--;
681 ngx_strcasestrn(u_char *s1, char *s2, size_t n) 681 ngx_strcasestrn(u_char *s1, char *s2, size_t n)
682 { 682 {
683 ngx_uint_t c1, c2; 683 ngx_uint_t c1, c2;
684 684
685 c2 = (ngx_uint_t) *s2++; 685 c2 = (ngx_uint_t) *s2++;
686 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; 686 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2;
687 687
688 do { 688 do {
689 do { 689 do {
690 c1 = (ngx_uint_t) *s1++; 690 c1 = (ngx_uint_t) *s1++;
691 691
692 if (c1 == 0) { 692 if (c1 == 0) {
693 return NULL; 693 return NULL;
694 } 694 }
695 695
696 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; 696 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1;
697 697
698 } while (c1 != c2); 698 } while (c1 != c2);
699 699
700 } while (ngx_strncasecmp(s1, (u_char *) s2, n) != 0); 700 } while (ngx_strncasecmp(s1, (u_char *) s2, n) != 0);
701 701
713 ngx_strlcasestrn(u_char *s1, u_char *last, u_char *s2, size_t n) 713 ngx_strlcasestrn(u_char *s1, u_char *last, u_char *s2, size_t n)
714 { 714 {
715 ngx_uint_t c1, c2; 715 ngx_uint_t c1, c2;
716 716
717 c2 = (ngx_uint_t) *s2++; 717 c2 = (ngx_uint_t) *s2++;
718 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; 718 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2;
719 last -= n; 719 last -= n;
720 720
721 do { 721 do {
722 do { 722 do {
723 if (s1 >= last) { 723 if (s1 >= last) {
724 return NULL; 724 return NULL;
725 } 725 }
726 726
727 c1 = (ngx_uint_t) *s1++; 727 c1 = (ngx_uint_t) *s1++;
728 728
729 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; 729 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1;
730 730
731 } while (c1 != c2); 731 } while (c1 != c2);
732 732
733 } while (ngx_strncasecmp(s1, s2, n) != 0); 733 } while (ngx_strncasecmp(s1, s2, n) != 0);
734 734
814 if (m || n1 == n2) { 814 if (m || n1 == n2) {
815 return m; 815 return m;
816 } 816 }
817 817
818 return z; 818 return z;
819 }
820
821
822 ngx_int_t
823 ngx_dns_strcmp(u_char *s1, u_char *s2)
824 {
825 ngx_uint_t c1, c2;
826
827 for ( ;; ) {
828 c1 = (ngx_uint_t) *s1++;
829 c2 = (ngx_uint_t) *s2++;
830
831 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1;
832 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2;
833
834 if (c1 == c2) {
835
836 if (c1) {
837 continue;
838 }
839
840 return 0;
841 }
842
843 /* in ASCII '.' > '-', but we need '.' to be the lowest character */
844
845 c1 = (c1 == '.') ? ' ' : c1;
846 c2 = (c2 == '.') ? ' ' : c2;
847
848 return c1 - c2;
849 }
819 } 850 }
820 851
821 852
822 ngx_int_t 853 ngx_int_t
823 ngx_atoi(u_char *line, size_t n) 854 ngx_atoi(u_char *line, size_t n)
1338 1369
1339 if (dst == NULL) { 1370 if (dst == NULL) {
1340 1371
1341 /* find the number of the characters to be escaped */ 1372 /* find the number of the characters to be escaped */
1342 1373
1343 n = 0; 1374 n = 0;
1344 1375
1345 for (i = 0; i < size; i++) { 1376 for (i = 0; i < size; i++) {
1346 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { 1377 if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
1347 n++; 1378 n++;
1348 } 1379 }