diff options
author | Lwisce Zeng <Lwisce.Zeng@garmin.com> | 2024-04-01 15:55:13 +0800 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2024-04-01 11:49:05 -0700 |
commit | 2ba25b2ddab9aa939c321d087fcfca573a9cca55 (patch) | |
tree | be7fc649f72cf901225a4a3e6d3c53c6e82d8f41 /inflate.c | |
parent | c5e87dcdef72abfb599579bb1b8176948be979c9 (diff) | |
download | zlib-2ba25b2ddab9aa939c321d087fcfca573a9cca55.tar.gz zlib-2ba25b2ddab9aa939c321d087fcfca573a9cca55.tar.bz2 zlib-2ba25b2ddab9aa939c321d087fcfca573a9cca55.zip |
Use z_const for setting msg to literal strings.
Diffstat (limited to 'inflate.c')
-rw-r--r-- | inflate.c | 42 |
1 files changed, 21 insertions, 21 deletions
@@ -642,12 +642,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
642 | if ( | 642 | if ( |
643 | #endif | 643 | #endif |
644 | ((BITS(8) << 8) + (hold >> 8)) % 31) { | 644 | ((BITS(8) << 8) + (hold >> 8)) % 31) { |
645 | strm->msg = (char *)"incorrect header check"; | 645 | strm->msg = (z_const char *)"incorrect header check"; |
646 | state->mode = BAD; | 646 | state->mode = BAD; |
647 | break; | 647 | break; |
648 | } | 648 | } |
649 | if (BITS(4) != Z_DEFLATED) { | 649 | if (BITS(4) != Z_DEFLATED) { |
650 | strm->msg = (char *)"unknown compression method"; | 650 | strm->msg = (z_const char *)"unknown compression method"; |
651 | state->mode = BAD; | 651 | state->mode = BAD; |
652 | break; | 652 | break; |
653 | } | 653 | } |
@@ -656,7 +656,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
656 | if (state->wbits == 0) | 656 | if (state->wbits == 0) |
657 | state->wbits = len; | 657 | state->wbits = len; |
658 | if (len > 15 || len > state->wbits) { | 658 | if (len > 15 || len > state->wbits) { |
659 | strm->msg = (char *)"invalid window size"; | 659 | strm->msg = (z_const char *)"invalid window size"; |
660 | state->mode = BAD; | 660 | state->mode = BAD; |
661 | break; | 661 | break; |
662 | } | 662 | } |
@@ -672,12 +672,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
672 | NEEDBITS(16); | 672 | NEEDBITS(16); |
673 | state->flags = (int)(hold); | 673 | state->flags = (int)(hold); |
674 | if ((state->flags & 0xff) != Z_DEFLATED) { | 674 | if ((state->flags & 0xff) != Z_DEFLATED) { |
675 | strm->msg = (char *)"unknown compression method"; | 675 | strm->msg = (z_const char *)"unknown compression method"; |
676 | state->mode = BAD; | 676 | state->mode = BAD; |
677 | break; | 677 | break; |
678 | } | 678 | } |
679 | if (state->flags & 0xe000) { | 679 | if (state->flags & 0xe000) { |
680 | strm->msg = (char *)"unknown header flags set"; | 680 | strm->msg = (z_const char *)"unknown header flags set"; |
681 | state->mode = BAD; | 681 | state->mode = BAD; |
682 | break; | 682 | break; |
683 | } | 683 | } |
@@ -793,7 +793,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
793 | if (state->flags & 0x0200) { | 793 | if (state->flags & 0x0200) { |
794 | NEEDBITS(16); | 794 | NEEDBITS(16); |
795 | if ((state->wrap & 4) && hold != (state->check & 0xffff)) { | 795 | if ((state->wrap & 4) && hold != (state->check & 0xffff)) { |
796 | strm->msg = (char *)"header crc mismatch"; | 796 | strm->msg = (z_const char *)"header crc mismatch"; |
797 | state->mode = BAD; | 797 | state->mode = BAD; |
798 | break; | 798 | break; |
799 | } | 799 | } |
@@ -855,7 +855,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
855 | state->mode = TABLE; | 855 | state->mode = TABLE; |
856 | break; | 856 | break; |
857 | case 3: | 857 | case 3: |
858 | strm->msg = (char *)"invalid block type"; | 858 | strm->msg = (z_const char *)"invalid block type"; |
859 | state->mode = BAD; | 859 | state->mode = BAD; |
860 | } | 860 | } |
861 | DROPBITS(2); | 861 | DROPBITS(2); |
@@ -864,7 +864,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
864 | BYTEBITS(); /* go to byte boundary */ | 864 | BYTEBITS(); /* go to byte boundary */ |
865 | NEEDBITS(32); | 865 | NEEDBITS(32); |
866 | if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { | 866 | if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { |
867 | strm->msg = (char *)"invalid stored block lengths"; | 867 | strm->msg = (z_const char *)"invalid stored block lengths"; |
868 | state->mode = BAD; | 868 | state->mode = BAD; |
869 | break; | 869 | break; |
870 | } | 870 | } |
@@ -905,7 +905,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
905 | DROPBITS(4); | 905 | DROPBITS(4); |
906 | #ifndef PKZIP_BUG_WORKAROUND | 906 | #ifndef PKZIP_BUG_WORKAROUND |
907 | if (state->nlen > 286 || state->ndist > 30) { | 907 | if (state->nlen > 286 || state->ndist > 30) { |
908 | strm->msg = (char *)"too many length or distance symbols"; | 908 | strm->msg = (z_const char *)"too many length or distance symbols"; |
909 | state->mode = BAD; | 909 | state->mode = BAD; |
910 | break; | 910 | break; |
911 | } | 911 | } |
@@ -928,7 +928,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
928 | ret = inflate_table(CODES, state->lens, 19, &(state->next), | 928 | ret = inflate_table(CODES, state->lens, 19, &(state->next), |
929 | &(state->lenbits), state->work); | 929 | &(state->lenbits), state->work); |
930 | if (ret) { | 930 | if (ret) { |
931 | strm->msg = (char *)"invalid code lengths set"; | 931 | strm->msg = (z_const char *)"invalid code lengths set"; |
932 | state->mode = BAD; | 932 | state->mode = BAD; |
933 | break; | 933 | break; |
934 | } | 934 | } |
@@ -952,7 +952,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
952 | NEEDBITS(here.bits + 2); | 952 | NEEDBITS(here.bits + 2); |
953 | DROPBITS(here.bits); | 953 | DROPBITS(here.bits); |
954 | if (state->have == 0) { | 954 | if (state->have == 0) { |
955 | strm->msg = (char *)"invalid bit length repeat"; | 955 | strm->msg = (z_const char *)"invalid bit length repeat"; |
956 | state->mode = BAD; | 956 | state->mode = BAD; |
957 | break; | 957 | break; |
958 | } | 958 | } |
@@ -975,7 +975,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
975 | DROPBITS(7); | 975 | DROPBITS(7); |
976 | } | 976 | } |
977 | if (state->have + copy > state->nlen + state->ndist) { | 977 | if (state->have + copy > state->nlen + state->ndist) { |
978 | strm->msg = (char *)"invalid bit length repeat"; | 978 | strm->msg = (z_const char *)"invalid bit length repeat"; |
979 | state->mode = BAD; | 979 | state->mode = BAD; |
980 | break; | 980 | break; |
981 | } | 981 | } |
@@ -989,7 +989,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
989 | 989 | ||
990 | /* check for end-of-block code (better have one) */ | 990 | /* check for end-of-block code (better have one) */ |
991 | if (state->lens[256] == 0) { | 991 | if (state->lens[256] == 0) { |
992 | strm->msg = (char *)"invalid code -- missing end-of-block"; | 992 | strm->msg = (z_const char *)"invalid code -- missing end-of-block"; |
993 | state->mode = BAD; | 993 | state->mode = BAD; |
994 | break; | 994 | break; |
995 | } | 995 | } |
@@ -1003,7 +1003,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
1003 | ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), | 1003 | ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), |
1004 | &(state->lenbits), state->work); | 1004 | &(state->lenbits), state->work); |
1005 | if (ret) { | 1005 | if (ret) { |
1006 | strm->msg = (char *)"invalid literal/lengths set"; | 1006 | strm->msg = (z_const char *)"invalid literal/lengths set"; |
1007 | state->mode = BAD; | 1007 | state->mode = BAD; |
1008 | break; | 1008 | break; |
1009 | } | 1009 | } |
@@ -1012,7 +1012,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
1012 | ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, | 1012 | ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, |
1013 | &(state->next), &(state->distbits), state->work); | 1013 | &(state->next), &(state->distbits), state->work); |
1014 | if (ret) { | 1014 | if (ret) { |
1015 | strm->msg = (char *)"invalid distances set"; | 1015 | strm->msg = (z_const char *)"invalid distances set"; |
1016 | state->mode = BAD; | 1016 | state->mode = BAD; |
1017 | break; | 1017 | break; |
1018 | } | 1018 | } |
@@ -1066,7 +1066,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
1066 | break; | 1066 | break; |
1067 | } | 1067 | } |
1068 | if (here.op & 64) { | 1068 | if (here.op & 64) { |
1069 | strm->msg = (char *)"invalid literal/length code"; | 1069 | strm->msg = (z_const char *)"invalid literal/length code"; |
1070 | state->mode = BAD; | 1070 | state->mode = BAD; |
1071 | break; | 1071 | break; |
1072 | } | 1072 | } |
@@ -1104,7 +1104,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
1104 | DROPBITS(here.bits); | 1104 | DROPBITS(here.bits); |
1105 | state->back += here.bits; | 1105 | state->back += here.bits; |
1106 | if (here.op & 64) { | 1106 | if (here.op & 64) { |
1107 | strm->msg = (char *)"invalid distance code"; | 1107 | strm->msg = (z_const char *)"invalid distance code"; |
1108 | state->mode = BAD; | 1108 | state->mode = BAD; |
1109 | break; | 1109 | break; |
1110 | } | 1110 | } |
@@ -1121,7 +1121,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
1121 | } | 1121 | } |
1122 | #ifdef INFLATE_STRICT | 1122 | #ifdef INFLATE_STRICT |
1123 | if (state->offset > state->dmax) { | 1123 | if (state->offset > state->dmax) { |
1124 | strm->msg = (char *)"invalid distance too far back"; | 1124 | strm->msg = (z_const char *)"invalid distance too far back"; |
1125 | state->mode = BAD; | 1125 | state->mode = BAD; |
1126 | break; | 1126 | break; |
1127 | } | 1127 | } |
@@ -1136,7 +1136,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
1136 | copy = state->offset - copy; | 1136 | copy = state->offset - copy; |
1137 | if (copy > state->whave) { | 1137 | if (copy > state->whave) { |
1138 | if (state->sane) { | 1138 | if (state->sane) { |
1139 | strm->msg = (char *)"invalid distance too far back"; | 1139 | strm->msg = (z_const char *)"invalid distance too far back"; |
1140 | state->mode = BAD; | 1140 | state->mode = BAD; |
1141 | break; | 1141 | break; |
1142 | } | 1142 | } |
@@ -1195,7 +1195,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
1195 | state->flags ? hold : | 1195 | state->flags ? hold : |
1196 | #endif | 1196 | #endif |
1197 | ZSWAP32(hold)) != state->check) { | 1197 | ZSWAP32(hold)) != state->check) { |
1198 | strm->msg = (char *)"incorrect data check"; | 1198 | strm->msg = (z_const char *)"incorrect data check"; |
1199 | state->mode = BAD; | 1199 | state->mode = BAD; |
1200 | break; | 1200 | break; |
1201 | } | 1201 | } |
@@ -1209,7 +1209,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { | |||
1209 | if (state->wrap && state->flags) { | 1209 | if (state->wrap && state->flags) { |
1210 | NEEDBITS(32); | 1210 | NEEDBITS(32); |
1211 | if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) { | 1211 | if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) { |
1212 | strm->msg = (char *)"incorrect length check"; | 1212 | strm->msg = (z_const char *)"incorrect length check"; |
1213 | state->mode = BAD; | 1213 | state->mode = BAD; |
1214 | break; | 1214 | break; |
1215 | } | 1215 | } |