diff options
| author | Eli Zaretskii | 2011-04-29 22:47:29 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2011-04-29 22:47:29 +0300 |
| commit | 15cbd324fd48e47abd57b8d92c3406c866169d21 (patch) | |
| tree | aa05b809dcec4391837ac2f4a41d1b8fdc93cbc2 /src/coding.c | |
| parent | ae940ccad19a554e1134b7ae443716e46c72366d (diff) | |
| download | emacs-15cbd324fd48e47abd57b8d92c3406c866169d21.tar.gz emacs-15cbd324fd48e47abd57b8d92c3406c866169d21.zip | |
Lift the MOST_POSITIVE_FIXNUM/4 limitation on visited files (bug#8528).
src/fileio.c (Finsert_file_contents): Don't limit file size to 1/4
of MOST_POSITIVE_FIXNUM.
src/coding.c (coding_alloc_by_realloc): Error out if destination
will grow beyond MOST_POSITIVE_FIXNUM.
(decode_coding_emacs_mule): Abort if there isn't enough place in
charbuf for the composition carryover bytes. Reserve an extra
space for up to 2 characters produced in a loop.
(decode_coding_iso_2022): Abort if there isn't enough place in
charbuf for the composition carryover bytes.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/coding.c b/src/coding.c index c129c94203c..d17346efdcb 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -1071,6 +1071,8 @@ coding_set_destination (struct coding_system *coding) | |||
| 1071 | static void | 1071 | static void |
| 1072 | coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) | 1072 | coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) |
| 1073 | { | 1073 | { |
| 1074 | if (coding->dst_bytes >= MOST_POSITIVE_FIXNUM - bytes) | ||
| 1075 | error ("Maximum size of buffer or string exceeded"); | ||
| 1074 | coding->destination = (unsigned char *) xrealloc (coding->destination, | 1076 | coding->destination = (unsigned char *) xrealloc (coding->destination, |
| 1075 | coding->dst_bytes + bytes); | 1077 | coding->dst_bytes + bytes); |
| 1076 | coding->dst_bytes += bytes; | 1078 | coding->dst_bytes += bytes; |
| @@ -2333,7 +2335,9 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2333 | /* We may produce two annotations (charset and composition) in one | 2335 | /* We may produce two annotations (charset and composition) in one |
| 2334 | loop and one more charset annotation at the end. */ | 2336 | loop and one more charset annotation at the end. */ |
| 2335 | int *charbuf_end | 2337 | int *charbuf_end |
| 2336 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); | 2338 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3) |
| 2339 | /* We can produce up to 2 characters in a loop. */ | ||
| 2340 | - 1; | ||
| 2337 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 2341 | EMACS_INT consumed_chars = 0, consumed_chars_base; |
| 2338 | int multibytep = coding->src_multibyte; | 2342 | int multibytep = coding->src_multibyte; |
| 2339 | EMACS_INT char_offset = coding->produced_char; | 2343 | EMACS_INT char_offset = coding->produced_char; |
| @@ -2348,6 +2352,8 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2348 | { | 2352 | { |
| 2349 | int i; | 2353 | int i; |
| 2350 | 2354 | ||
| 2355 | if (charbuf_end - charbuf < cmp_status->length) | ||
| 2356 | abort (); | ||
| 2351 | for (i = 0; i < cmp_status->length; i++) | 2357 | for (i = 0; i < cmp_status->length; i++) |
| 2352 | *charbuf++ = cmp_status->carryover[i]; | 2358 | *charbuf++ = cmp_status->carryover[i]; |
| 2353 | coding->annotated = 1; | 2359 | coding->annotated = 1; |
| @@ -3479,6 +3485,8 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3479 | 3485 | ||
| 3480 | if (cmp_status->state != COMPOSING_NO) | 3486 | if (cmp_status->state != COMPOSING_NO) |
| 3481 | { | 3487 | { |
| 3488 | if (charbuf_end - charbuf < cmp_status->length) | ||
| 3489 | abort (); | ||
| 3482 | for (i = 0; i < cmp_status->length; i++) | 3490 | for (i = 0; i < cmp_status->length; i++) |
| 3483 | *charbuf++ = cmp_status->carryover[i]; | 3491 | *charbuf++ = cmp_status->carryover[i]; |
| 3484 | coding->annotated = 1; | 3492 | coding->annotated = 1; |