Mercurial > emacs
changeset 23685:14c75dfaaa44
(str_cmpchar_id): Check the byte sequence for
composition more rigidly.
(Fcompose_string): Allow DEL to be composed. Signal error if STR
contains an invalid multibyte sequence.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 11 Nov 1998 03:36:15 +0000 |
parents | 25077ab7295c |
children | 29fd5e07b576 |
files | src/charset.c |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/charset.c Wed Nov 11 03:36:15 1998 +0000 +++ b/src/charset.c Wed Nov 11 03:36:15 1998 +0000 @@ -1417,7 +1417,12 @@ p = str + 1; while (p < endp) { - if (embedded_rule) p++; + if (embedded_rule) + { + p++; + if (p >= endp) + return -1; + } /* No need of checking if *P is 0xA0 because BYTES_BY_CHAR_HEAD (0x80) surely returns 2. */ p += BYTES_BY_CHAR_HEAD (*p - 0x20); @@ -1719,7 +1724,7 @@ i = 1; while (p < pend) { - if (*p < 0x20 || *p == 127) /* control code */ + if (*p < 0x20) /* control code */ error ("Invalid component character: %d", *p); else if (*p < 0x80) /* ASCII */ { @@ -1740,6 +1745,8 @@ error ("Can't compose a rule-based composition character"); ptemp = p; while (! CHAR_HEAD_P (*p)) p++; + if (str_cmpchar_id (ptemp - 1, p - ptemp + 1) < 0) + error ("Can't compose an invalid composition character"); if (i + (p - ptemp) >= MAX_LENGTH_OF_MULTI_BYTE_FORM) error ("Too long string to be composed: %s", XSTRING (str)->data); bcopy (ptemp, buf + i, p - ptemp); @@ -1749,7 +1756,10 @@ { /* Add 0x20 to the base leading-code, keep the remaining bytes unchanged. */ - len = BYTES_BY_CHAR_HEAD (*p); + int c = STRING_CHAR_AND_CHAR_LENGTH (p, pend - p, len); + + if (len <= 1 || ! CHAR_VALID_P (c, 0)) + error ("Can't compose an invalid character"); if (i + len >= MAX_LENGTH_OF_MULTI_BYTE_FORM) error ("Too long string to be composed: %s", XSTRING (str)->data); bcopy (p, buf + i, len);