diff options
| author | Paul Eggert | 2011-03-27 02:07:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-03-27 02:07:38 -0700 |
| commit | 3c59b4c9d671ec0298a8489eabbd09af47039852 (patch) | |
| tree | 86f4c3672868bbe316c09d598431994c6b2f4724 /src | |
| parent | 5d5d959d59d80e3beebc9788333ea5a2449a10df (diff) | |
| download | emacs-3c59b4c9d671ec0298a8489eabbd09af47039852.tar.gz emacs-3c59b4c9d671ec0298a8489eabbd09af47039852.zip | |
* callproc.c (Fcall_process, Fcall_process_region): Use SAFE_ALLOCA
instead of alloca (Bug#8344).
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/callproc.c | 58 |
2 files changed, 37 insertions, 24 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 3998d74ba0c..6cb8ad8000d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2011-03-27 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-03-27 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * callproc.c (Fcall_process, Fcall_process_region): Use SAFE_ALLOCA | ||
| 4 | instead of alloca (Bug#8344). | ||
| 5 | |||
| 3 | * eval.c (Fbacktrace): Don't assume nargs fits in int. | 6 | * eval.c (Fbacktrace): Don't assume nargs fits in int. |
| 4 | (Fbacktrace_frame): Don't assume nframes fits in int. | 7 | (Fbacktrace_frame): Don't assume nframes fits in int. |
| 5 | 8 | ||
diff --git a/src/callproc.c b/src/callproc.c index acb7a0e24b1..eb2a2268fe1 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -189,6 +189,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 189 | char buf[CALLPROC_BUFFER_SIZE_MAX]; | 189 | char buf[CALLPROC_BUFFER_SIZE_MAX]; |
| 190 | int bufsize = CALLPROC_BUFFER_SIZE_MIN; | 190 | int bufsize = CALLPROC_BUFFER_SIZE_MIN; |
| 191 | int count = SPECPDL_INDEX (); | 191 | int count = SPECPDL_INDEX (); |
| 192 | volatile USE_SAFE_ALLOCA; | ||
| 192 | 193 | ||
| 193 | const unsigned char **volatile new_argv_volatile; | 194 | const unsigned char **volatile new_argv_volatile; |
| 194 | register const unsigned char **new_argv; | 195 | register const unsigned char **new_argv; |
| @@ -242,7 +243,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 242 | val = Qraw_text; | 243 | val = Qraw_text; |
| 243 | else | 244 | else |
| 244 | { | 245 | { |
| 245 | args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); | 246 | SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); |
| 246 | args2[0] = Qcall_process; | 247 | args2[0] = Qcall_process; |
| 247 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; | 248 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
| 248 | coding_systems = Ffind_operation_coding_system (nargs + 1, args2); | 249 | coding_systems = Ffind_operation_coding_system (nargs + 1, args2); |
| @@ -372,8 +373,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 372 | && SREF (path, 1) == ':') | 373 | && SREF (path, 1) == ':') |
| 373 | path = Fsubstring (path, make_number (2), Qnil); | 374 | path = Fsubstring (path, make_number (2), Qnil); |
| 374 | 375 | ||
| 375 | new_argv_volatile = new_argv = (const unsigned char **) | 376 | SAFE_ALLOCA (new_argv, const unsigned char **, |
| 376 | alloca ((nargs > 4 ? nargs - 2 : 2) * sizeof (char *)); | 377 | (nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv); |
| 378 | new_argv_volatile = new_argv; | ||
| 377 | if (nargs > 4) | 379 | if (nargs > 4) |
| 378 | { | 380 | { |
| 379 | register size_t i; | 381 | register size_t i; |
| @@ -645,7 +647,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 645 | { | 647 | { |
| 646 | size_t i; | 648 | size_t i; |
| 647 | 649 | ||
| 648 | args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); | 650 | SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); |
| 649 | args2[0] = Qcall_process; | 651 | args2[0] = Qcall_process; |
| 650 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; | 652 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
| 651 | coding_systems | 653 | coding_systems |
| @@ -809,6 +811,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 809 | when exiting. */ | 811 | when exiting. */ |
| 810 | call_process_exited = 1; | 812 | call_process_exited = 1; |
| 811 | 813 | ||
| 814 | SAFE_FREE (); | ||
| 812 | unbind_to (count, Qnil); | 815 | unbind_to (count, Qnil); |
| 813 | 816 | ||
| 814 | if (synch_process_termsig) | 817 | if (synch_process_termsig) |
| @@ -897,30 +900,35 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r | |||
| 897 | #endif | 900 | #endif |
| 898 | } | 901 | } |
| 899 | 902 | ||
| 900 | pattern = Fexpand_file_name (Vtemp_file_name_pattern, tmpdir); | 903 | { |
| 901 | tempfile = (char *) alloca (SBYTES (pattern) + 1); | 904 | USE_SAFE_ALLOCA; |
| 902 | memcpy (tempfile, SDATA (pattern), SBYTES (pattern) + 1); | 905 | pattern = Fexpand_file_name (Vtemp_file_name_pattern, tmpdir); |
| 903 | coding_systems = Qt; | 906 | SAFE_ALLOCA (tempfile, char *, SBYTES (pattern) + 1); |
| 907 | memcpy (tempfile, SDATA (pattern), SBYTES (pattern) + 1); | ||
| 908 | coding_systems = Qt; | ||
| 904 | 909 | ||
| 905 | #ifdef HAVE_MKSTEMP | 910 | #ifdef HAVE_MKSTEMP |
| 906 | { | 911 | { |
| 907 | int fd; | 912 | int fd; |
| 908 | 913 | ||
| 909 | BLOCK_INPUT; | 914 | BLOCK_INPUT; |
| 910 | fd = mkstemp (tempfile); | 915 | fd = mkstemp (tempfile); |
| 911 | UNBLOCK_INPUT; | 916 | UNBLOCK_INPUT; |
| 912 | if (fd == -1) | 917 | if (fd == -1) |
| 913 | report_file_error ("Failed to open temporary file", | 918 | report_file_error ("Failed to open temporary file", |
| 914 | Fcons (Vtemp_file_name_pattern, Qnil)); | 919 | Fcons (Vtemp_file_name_pattern, Qnil)); |
| 915 | else | 920 | else |
| 916 | close (fd); | 921 | close (fd); |
| 917 | } | 922 | } |
| 918 | #else | 923 | #else |
| 919 | mktemp (tempfile); | 924 | mktemp (tempfile); |
| 920 | #endif | 925 | #endif |
| 921 | 926 | ||
| 922 | filename_string = build_string (tempfile); | 927 | filename_string = build_string (tempfile); |
| 923 | GCPRO1 (filename_string); | 928 | GCPRO1 (filename_string); |
| 929 | SAFE_FREE (); | ||
| 930 | } | ||
| 931 | |||
| 924 | start = args[0]; | 932 | start = args[0]; |
| 925 | end = args[1]; | 933 | end = args[1]; |
| 926 | /* Decide coding-system of the contents of the temporary file. */ | 934 | /* Decide coding-system of the contents of the temporary file. */ |
| @@ -930,11 +938,13 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r | |||
| 930 | val = Qraw_text; | 938 | val = Qraw_text; |
| 931 | else | 939 | else |
| 932 | { | 940 | { |
| 933 | args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); | 941 | USE_SAFE_ALLOCA; |
| 942 | SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); | ||
| 934 | args2[0] = Qcall_process_region; | 943 | args2[0] = Qcall_process_region; |
| 935 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; | 944 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
| 936 | coding_systems = Ffind_operation_coding_system (nargs + 1, args2); | 945 | coding_systems = Ffind_operation_coding_system (nargs + 1, args2); |
| 937 | val = CONSP (coding_systems) ? XCDR (coding_systems) : Qnil; | 946 | val = CONSP (coding_systems) ? XCDR (coding_systems) : Qnil; |
| 947 | SAFE_FREE (); | ||
| 938 | } | 948 | } |
| 939 | val = complement_process_encoding_system (val); | 949 | val = complement_process_encoding_system (val); |
| 940 | 950 | ||