aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2008-01-31 11:27:46 +0000
committerKenichi Handa2008-01-31 11:27:46 +0000
commit8d99a0b354137e307fc729ec31cd65088e324adf (patch)
treefa5d5cea5b0412a6e75e3553972c7d98bb238829
parent08cf830bbd55a241619a6d0a4b53ad44c8d187c6 (diff)
downloademacs-8d99a0b354137e307fc729ec31cd65088e324adf.tar.gz
emacs-8d99a0b354137e307fc729ec31cd65088e324adf.zip
(CCL_WRITE_CHAR): Increment extra_bytes only when
ccl->eight_bit_control. Fix check for buffer overflow. (CCL_WRITE_MULTIBYTE_CHAR): Fix check for buffer overflow. (ccl_driver): Initialize extra_bytes to 0.
-rw-r--r--src/ccl.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/ccl.c b/src/ccl.c
index 0b0439933f9..9f7baf0b4ff 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -748,16 +748,13 @@ while(0)
748 int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \ 748 int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \
749 if (!dst) \ 749 if (!dst) \
750 CCL_INVALID_CMD; \ 750 CCL_INVALID_CMD; \
751 else if (dst + bytes + extra_bytes < (dst_bytes ? dst_end : src)) \ 751 if (ccl->eight_bit_control \
752 && bytes == 1 && (ch) >= 0x80 && (ch) < 0xA0) \
753 extra_bytes++; \
754 if (dst + bytes + extra_bytes <= (dst_bytes ? dst_end : src)) \
752 { \ 755 { \
753 if (bytes == 1) \ 756 if (bytes == 1) \
754 { \ 757 *dst++ = (ch); \
755 *dst++ = (ch); \
756 if (extra_bytes && (ch) >= 0x80 && (ch) < 0xA0) \
757 /* We may have to convert this eight-bit char to \
758 multibyte form later. */ \
759 extra_bytes++; \
760 } \
761 else if (CHAR_VALID_P (ch, 0)) \ 758 else if (CHAR_VALID_P (ch, 0)) \
762 dst += CHAR_STRING (ch, dst); \ 759 dst += CHAR_STRING (ch, dst); \
763 else \ 760 else \
@@ -775,7 +772,7 @@ while(0)
775 int bytes = CHAR_BYTES (ch); \ 772 int bytes = CHAR_BYTES (ch); \
776 if (!dst) \ 773 if (!dst) \
777 CCL_INVALID_CMD; \ 774 CCL_INVALID_CMD; \
778 else if (dst + bytes + extra_bytes < (dst_bytes ? dst_end : src)) \ 775 else if (dst + bytes + extra_bytes <= (dst_bytes ? dst_end : src)) \
779 { \ 776 { \
780 if (CHAR_VALID_P ((ch), 0)) \ 777 if (CHAR_VALID_P ((ch), 0)) \
781 dst += CHAR_STRING ((ch), dst); \ 778 dst += CHAR_STRING ((ch), dst); \
@@ -919,7 +916,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
919 each of them will be converted to multibyte form of 2-byte 916 each of them will be converted to multibyte form of 2-byte
920 sequence. For that conversion, we remember how many more bytes 917 sequence. For that conversion, we remember how many more bytes
921 we must keep in DESTINATION in this variable. */ 918 we must keep in DESTINATION in this variable. */
922 int extra_bytes = ccl->eight_bit_control; 919 int extra_bytes = 0;
923 int eof_ic = ccl->eof_ic; 920 int eof_ic = ccl->eof_ic;
924 int eof_hit = 0; 921 int eof_hit = 0;
925 922