aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2014-10-08 10:30:57 +0300
committerEli Zaretskii2014-10-08 10:30:57 +0300
commita7044030f39a7351507727421308c56d7771bebf (patch)
treeb1c77c6b78f462692111dc20981da1ae9e9ff984 /src/coding.c
parente76955cbb521aee4af70a8c93d9f1be5f1d3f4a6 (diff)
downloademacs-a7044030f39a7351507727421308c56d7771bebf.tar.gz
emacs-a7044030f39a7351507727421308c56d7771bebf.zip
Fix bug #18610 with crashes when visiting files with ESC and 8-bit bytes.
src/coding.c (detect_coding_iso_2022): Set coding->rejected correctly when an invalid escape sequence is found. Backported from trunk.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/coding.c b/src/coding.c
index 31303e2ba42..b0a9f6ef4cb 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -3078,8 +3078,13 @@ detect_coding_iso_2022 (struct coding_system *coding,
3078 ONE_MORE_BYTE (c1); 3078 ONE_MORE_BYTE (c1);
3079 if (c1 < ' ' || c1 >= 0x80 3079 if (c1 < ' ' || c1 >= 0x80
3080 || (id = iso_charset_table[0][c >= ','][c1]) < 0) 3080 || (id = iso_charset_table[0][c >= ','][c1]) < 0)
3081 /* Invalid designation sequence. Just ignore. */ 3081 {
3082 break; 3082 /* Invalid designation sequence. Just ignore. */
3083 if (c1 >= 0x80)
3084 rejected |= (CATEGORY_MASK_ISO_7BIT
3085 | CATEGORY_MASK_ISO_7_ELSE);
3086 break;
3087 }
3083 } 3088 }
3084 else if (c == '$') 3089 else if (c == '$')
3085 { 3090 {
@@ -3093,16 +3098,29 @@ detect_coding_iso_2022 (struct coding_system *coding,
3093 ONE_MORE_BYTE (c1); 3098 ONE_MORE_BYTE (c1);
3094 if (c1 < ' ' || c1 >= 0x80 3099 if (c1 < ' ' || c1 >= 0x80
3095 || (id = iso_charset_table[1][c >= ','][c1]) < 0) 3100 || (id = iso_charset_table[1][c >= ','][c1]) < 0)
3096 /* Invalid designation sequence. Just ignore. */ 3101 {
3097 break; 3102 /* Invalid designation sequence. Just ignore. */
3103 if (c1 >= 0x80)
3104 rejected |= (CATEGORY_MASK_ISO_7BIT
3105 | CATEGORY_MASK_ISO_7_ELSE);
3106 break;
3107 }
3098 } 3108 }
3099 else 3109 else
3100 /* Invalid designation sequence. Just ignore it. */ 3110 {
3101 break; 3111 /* Invalid designation sequence. Just ignore it. */
3112 if (c >= 0x80)
3113 rejected |= (CATEGORY_MASK_ISO_7BIT
3114 | CATEGORY_MASK_ISO_7_ELSE);
3115 break;
3116 }
3102 } 3117 }
3103 else 3118 else
3104 { 3119 {
3105 /* Invalid escape sequence. Just ignore it. */ 3120 /* Invalid escape sequence. Just ignore it. */
3121 if (c >= 0x80)
3122 rejected |= (CATEGORY_MASK_ISO_7BIT
3123 | CATEGORY_MASK_ISO_7_ELSE);
3106 break; 3124 break;
3107 } 3125 }
3108 3126
@@ -3153,7 +3171,7 @@ detect_coding_iso_2022 (struct coding_system *coding,
3153 if (inhibit_iso_escape_detection) 3171 if (inhibit_iso_escape_detection)
3154 break; 3172 break;
3155 single_shifting = 0; 3173 single_shifting = 0;
3156 rejected |= CATEGORY_MASK_ISO_7BIT; 3174 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE;
3157 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) 3175 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
3158 & CODING_ISO_FLAG_SINGLE_SHIFT) 3176 & CODING_ISO_FLAG_SINGLE_SHIFT)
3159 { 3177 {
@@ -3180,9 +3198,9 @@ detect_coding_iso_2022 (struct coding_system *coding,
3180 single_shifting = 0; 3198 single_shifting = 0;
3181 break; 3199 break;
3182 } 3200 }
3201 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE;
3183 if (c >= 0xA0) 3202 if (c >= 0xA0)
3184 { 3203 {
3185 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE;
3186 found |= CATEGORY_MASK_ISO_8_1; 3204 found |= CATEGORY_MASK_ISO_8_1;
3187 /* Check the length of succeeding codes of the range 3205 /* Check the length of succeeding codes of the range
3188 0xA0..0FF. If the byte length is even, we include 3206 0xA0..0FF. If the byte length is even, we include