diff options
| author | Chong Yidong | 2010-05-18 14:01:10 -0400 |
|---|---|---|
| committer | Chong Yidong | 2010-05-18 14:01:10 -0400 |
| commit | 754790b6c5a0ebe9cc1f2463d9446c5cb19b4264 (patch) | |
| tree | 9a013184548245cf9c4dac6b77db81d927d2d6bd /src | |
| parent | dc9ed7949681bcb29cf151c5183efcc50260fa00 (diff) | |
| download | emacs-754790b6c5a0ebe9cc1f2463d9446c5cb19b4264.tar.gz emacs-754790b6c5a0ebe9cc1f2463d9446c5cb19b4264.zip | |
* character.c (Fstring, Funibyte_string): Use SAFE_ALLOCA to
prevent stack overflow if number of arguments is too large
(Bug#6214).
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/character.c | 30 |
2 files changed, 26 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8e2774f2a03..557cda8d4f9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2010-05-18 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * character.c (Fstring, Funibyte_string): Use SAFE_ALLOCA to | ||
| 4 | prevent stack overflow if number of arguments is too large | ||
| 5 | (Bug#6214). | ||
| 6 | |||
| 1 | 2010-05-11 Eli Zaretskii <eliz@gnu.org> | 7 | 2010-05-11 Eli Zaretskii <eliz@gnu.org> |
| 2 | 8 | ||
| 3 | * makefile.w32-in ($(BLD)/w32fns.$(O)): Depend on $(SRC)/w32.h. | 9 | * makefile.w32-in ($(BLD)/w32fns.$(O)): Depend on $(SRC)/w32.h. |
diff --git a/src/character.c b/src/character.c index 5912a70d0ce..7cd1eedcef4 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -961,10 +961,13 @@ usage: (string &rest CHARACTERS) */) | |||
| 961 | int n; | 961 | int n; |
| 962 | Lisp_Object *args; | 962 | Lisp_Object *args; |
| 963 | { | 963 | { |
| 964 | int i; | 964 | int i, c; |
| 965 | unsigned char *buf = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH * n); | 965 | unsigned char *buf, *p; |
| 966 | unsigned char *p = buf; | 966 | Lisp_Object str; |
| 967 | int c; | 967 | USE_SAFE_ALLOCA; |
| 968 | |||
| 969 | SAFE_ALLOCA (buf, unsigned char *, MAX_MULTIBYTE_LENGTH * n); | ||
| 970 | p = buf; | ||
| 968 | 971 | ||
| 969 | for (i = 0; i < n; i++) | 972 | for (i = 0; i < n; i++) |
| 970 | { | 973 | { |
| @@ -973,7 +976,9 @@ usage: (string &rest CHARACTERS) */) | |||
| 973 | p += CHAR_STRING (c, p); | 976 | p += CHAR_STRING (c, p); |
| 974 | } | 977 | } |
| 975 | 978 | ||
| 976 | return make_string_from_bytes ((char *) buf, n, p - buf); | 979 | str = make_string_from_bytes ((char *) buf, n, p - buf); |
| 980 | SAFE_FREE (); | ||
| 981 | return str; | ||
| 977 | } | 982 | } |
| 978 | 983 | ||
| 979 | DEFUN ("unibyte-string", Funibyte_string, Sunibyte_string, 0, MANY, 0, | 984 | DEFUN ("unibyte-string", Funibyte_string, Sunibyte_string, 0, MANY, 0, |
| @@ -983,10 +988,13 @@ usage: (unibyte-string &rest BYTES) */) | |||
| 983 | int n; | 988 | int n; |
| 984 | Lisp_Object *args; | 989 | Lisp_Object *args; |
| 985 | { | 990 | { |
| 986 | int i; | 991 | int i, c; |
| 987 | unsigned char *buf = (unsigned char *) alloca (n); | 992 | unsigned char *buf, *p; |
| 988 | unsigned char *p = buf; | 993 | Lisp_Object str; |
| 989 | unsigned c; | 994 | USE_SAFE_ALLOCA; |
| 995 | |||
| 996 | SAFE_ALLOCA (buf, unsigned char *, n); | ||
| 997 | p = buf; | ||
| 990 | 998 | ||
| 991 | for (i = 0; i < n; i++) | 999 | for (i = 0; i < n; i++) |
| 992 | { | 1000 | { |
| @@ -997,7 +1005,9 @@ usage: (unibyte-string &rest BYTES) */) | |||
| 997 | *p++ = c; | 1005 | *p++ = c; |
| 998 | } | 1006 | } |
| 999 | 1007 | ||
| 1000 | return make_string_from_bytes ((char *) buf, n, p - buf); | 1008 | str = make_string_from_bytes ((char *) buf, n, p - buf); |
| 1009 | SAFE_FREE (); | ||
| 1010 | return str; | ||
| 1001 | } | 1011 | } |
| 1002 | 1012 | ||
| 1003 | DEFUN ("char-resolve-modifiers", Fchar_resolve_modifiers, | 1013 | DEFUN ("char-resolve-modifiers", Fchar_resolve_modifiers, |