diff options
| author | Andreas Schwab | 2009-04-28 19:02:26 +0000 |
|---|---|---|
| committer | Andreas Schwab | 2009-04-28 19:02:26 +0000 |
| commit | 77bf07e14ef041325679bc274f912b5e9977eb25 (patch) | |
| tree | a33270f5c27f175d5e26c65070e81c823d1663b5 /src | |
| parent | 0a56bf8c52c6f6448a0ee97cab75a0b6fafca5ca (diff) | |
| download | emacs-77bf07e14ef041325679bc274f912b5e9977eb25.tar.gz emacs-77bf07e14ef041325679bc274f912b5e9977eb25.zip | |
* fns.c (Flocale_info): Protect vector from GC during decoding.
* process.c (Fstart_process): Protect argv strings from GC during
encoding.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/fns.c | 21 | ||||
| -rw-r--r-- | src/process.c | 50 |
3 files changed, 52 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 69b4d082416..5a8df8f5408 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2009-04-28 Andreas Schwab <schwab@linux-m68k.org> | ||
| 2 | |||
| 3 | * fns.c (Flocale_info): Protect vector from GC during decoding. | ||
| 4 | |||
| 5 | * process.c (Fstart_process): Protect argv strings from GC during | ||
| 6 | encoding. | ||
| 7 | |||
| 1 | 2009-04-27 Andreas Schwab <schwab@linux-m68k.org> | 8 | 2009-04-27 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 9 | ||
| 3 | * sysdep.c: Include <ctype.h>. | 10 | * sysdep.c: Include <ctype.h>. |
| @@ -3135,8 +3135,10 @@ The data read from the system are decoded using `locale-coding-system'. */) | |||
| 3135 | else if (EQ (item, Qdays)) /* e.g. for calendar-day-name-array */ | 3135 | else if (EQ (item, Qdays)) /* e.g. for calendar-day-name-array */ |
| 3136 | { | 3136 | { |
| 3137 | Lisp_Object v = Fmake_vector (make_number (7), Qnil); | 3137 | Lisp_Object v = Fmake_vector (make_number (7), Qnil); |
| 3138 | int days[7] = {DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7}; | 3138 | const int days[7] = {DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7}; |
| 3139 | int i; | 3139 | int i; |
| 3140 | struct gcpro gcpro1; | ||
| 3141 | GCPRO1 (v); | ||
| 3140 | synchronize_system_time_locale (); | 3142 | synchronize_system_time_locale (); |
| 3141 | for (i = 0; i < 7; i++) | 3143 | for (i = 0; i < 7; i++) |
| 3142 | { | 3144 | { |
| @@ -3148,26 +3150,29 @@ The data read from the system are decoded using `locale-coding-system'. */) | |||
| 3148 | code_convert_string_norecord (val, Vlocale_coding_system, | 3150 | code_convert_string_norecord (val, Vlocale_coding_system, |
| 3149 | 0)); | 3151 | 0)); |
| 3150 | } | 3152 | } |
| 3153 | UNGCPRO; | ||
| 3151 | return v; | 3154 | return v; |
| 3152 | } | 3155 | } |
| 3153 | #endif /* DAY_1 */ | 3156 | #endif /* DAY_1 */ |
| 3154 | #ifdef MON_1 | 3157 | #ifdef MON_1 |
| 3155 | else if (EQ (item, Qmonths)) /* e.g. for calendar-month-name-array */ | 3158 | else if (EQ (item, Qmonths)) /* e.g. for calendar-month-name-array */ |
| 3156 | { | 3159 | { |
| 3157 | struct Lisp_Vector *p = allocate_vector (12); | 3160 | Lisp_Object v = Fmake_vector (make_number (12), Qnil); |
| 3158 | int months[12] = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7, | 3161 | const int months[12] = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7, |
| 3159 | MON_8, MON_9, MON_10, MON_11, MON_12}; | 3162 | MON_8, MON_9, MON_10, MON_11, MON_12}; |
| 3160 | int i; | 3163 | int i; |
| 3164 | struct gcpro gcpro1; | ||
| 3165 | GCPRO1 (v); | ||
| 3161 | synchronize_system_time_locale (); | 3166 | synchronize_system_time_locale (); |
| 3162 | for (i = 0; i < 12; i++) | 3167 | for (i = 0; i < 12; i++) |
| 3163 | { | 3168 | { |
| 3164 | str = nl_langinfo (months[i]); | 3169 | str = nl_langinfo (months[i]); |
| 3165 | val = make_unibyte_string (str, strlen (str)); | 3170 | val = make_unibyte_string (str, strlen (str)); |
| 3166 | p->contents[i] = | 3171 | Faset (v, make_number (i), |
| 3167 | code_convert_string_norecord (val, Vlocale_coding_system, 0); | 3172 | code_convert_string_norecord (val, Vlocale_coding_system, 0)); |
| 3168 | } | 3173 | } |
| 3169 | XSETVECTOR (val, p); | 3174 | UNGCPRO; |
| 3170 | return val; | 3175 | return v; |
| 3171 | } | 3176 | } |
| 3172 | #endif /* MON_1 */ | 3177 | #endif /* MON_1 */ |
| 3173 | /* LC_PAPER stuff isn't defined as accessible in glibc as of 2.3.1, | 3178 | /* LC_PAPER stuff isn't defined as accessible in glibc as of 2.3.1, |
diff --git a/src/process.c b/src/process.c index 143c58030c1..3e06b4d5fdb 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1698,8 +1698,6 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) | |||
| 1698 | XPROCESS (proc)->encode_coding_system = val; | 1698 | XPROCESS (proc)->encode_coding_system = val; |
| 1699 | } | 1699 | } |
| 1700 | 1700 | ||
| 1701 | new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *)); | ||
| 1702 | |||
| 1703 | /* If program file name is not absolute, search our path for it. | 1701 | /* If program file name is not absolute, search our path for it. |
| 1704 | Put the name we will really use in TEM. */ | 1702 | Put the name we will really use in TEM. */ |
| 1705 | if (!IS_DIRECTORY_SEP (SREF (program, 0)) | 1703 | if (!IS_DIRECTORY_SEP (SREF (program, 0)) |
| @@ -1729,26 +1727,42 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) | |||
| 1729 | && SREF (tem, 1) == ':') | 1727 | && SREF (tem, 1) == ':') |
| 1730 | tem = Fsubstring (tem, make_number (2), Qnil); | 1728 | tem = Fsubstring (tem, make_number (2), Qnil); |
| 1731 | 1729 | ||
| 1732 | /* Encode the file name and put it in NEW_ARGV. | 1730 | { |
| 1733 | That's where the child will use it to execute the program. */ | 1731 | struct gcpro gcpro1; |
| 1734 | tem = ENCODE_FILE (tem); | 1732 | GCPRO1 (tem); |
| 1735 | new_argv[0] = SDATA (tem); | 1733 | |
| 1734 | /* Encode the file name and put it in NEW_ARGV. | ||
| 1735 | That's where the child will use it to execute the program. */ | ||
| 1736 | tem = Fcons (ENCODE_FILE (tem), Qnil); | ||
| 1737 | |||
| 1738 | /* Here we encode arguments by the coding system used for sending | ||
| 1739 | data to the process. We don't support using different coding | ||
| 1740 | systems for encoding arguments and for encoding data sent to the | ||
| 1741 | process. */ | ||
| 1742 | |||
| 1743 | for (i = 3; i < nargs; i++) | ||
| 1744 | { | ||
| 1745 | tem = Fcons (args[i], tem); | ||
| 1746 | CHECK_STRING (XCAR (tem)); | ||
| 1747 | if (STRING_MULTIBYTE (XCAR (tem))) | ||
| 1748 | XSETCAR (tem, | ||
| 1749 | code_convert_string_norecord | ||
| 1750 | (XCAR (tem), XPROCESS (proc)->encode_coding_system, 1)); | ||
| 1751 | } | ||
| 1736 | 1752 | ||
| 1737 | /* Here we encode arguments by the coding system used for sending | 1753 | UNGCPRO; |
| 1738 | data to the process. We don't support using different coding | 1754 | } |
| 1739 | systems for encoding arguments and for encoding data sent to the | ||
| 1740 | process. */ | ||
| 1741 | 1755 | ||
| 1742 | for (i = 3; i < nargs; i++) | 1756 | /* Now that everything is encoded we can collect the strings into |
| 1757 | NEW_ARGV. */ | ||
| 1758 | new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *)); | ||
| 1759 | new_argv[nargs - 2] = 0; | ||
| 1760 | |||
| 1761 | for (i = nargs - 3; i >= 0; i--) | ||
| 1743 | { | 1762 | { |
| 1744 | tem = args[i]; | 1763 | new_argv[i] = SDATA (XCAR (tem)); |
| 1745 | CHECK_STRING (tem); | 1764 | tem = XCDR (tem); |
| 1746 | if (STRING_MULTIBYTE (tem)) | ||
| 1747 | tem = (code_convert_string_norecord | ||
| 1748 | (tem, XPROCESS (proc)->encode_coding_system, 1)); | ||
| 1749 | new_argv[i - 2] = SDATA (tem); | ||
| 1750 | } | 1765 | } |
| 1751 | new_argv[i - 2] = 0; | ||
| 1752 | 1766 | ||
| 1753 | XPROCESS (proc)->decoding_buf = make_uninit_string (0); | 1767 | XPROCESS (proc)->decoding_buf = make_uninit_string (0); |
| 1754 | XPROCESS (proc)->decoding_carryover = 0; | 1768 | XPROCESS (proc)->decoding_carryover = 0; |