diff options
| author | Eli Zaretskii | 2013-02-01 12:15:36 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2013-02-01 12:15:36 +0200 |
| commit | e7c3fb0624a88210f3a95adb103eba274b0fdba7 (patch) | |
| tree | 28687fc2f236f4d4a369ebe8376892d3c69ff241 /src/callproc.c | |
| parent | 18a80473ed3fd815d99e64a8e7392066125a7e3c (diff) | |
| download | emacs-e7c3fb0624a88210f3a95adb103eba274b0fdba7.tar.gz emacs-e7c3fb0624a88210f3a95adb103eba274b0fdba7.zip | |
Make sure program names are encoded before using them to invoke subprocesses.
src/callproc.c (Fcall_process): Make sure program name in PATH and
new_argv[0] is encoded, if needed. Otherwise, un-encoded string
is passed to exec/spawnve, which fails unless the file-name
encoding is UTF-8.
Diffstat (limited to 'src/callproc.c')
| -rw-r--r-- | src/callproc.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/src/callproc.c b/src/callproc.c index d152da19f7b..c4177d5044c 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -416,28 +416,34 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 416 | path = Fsubstring (path, make_number (2), Qnil); | 416 | path = Fsubstring (path, make_number (2), Qnil); |
| 417 | 417 | ||
| 418 | new_argv = SAFE_ALLOCA ((nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv); | 418 | new_argv = SAFE_ALLOCA ((nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv); |
| 419 | if (nargs > 4) | ||
| 420 | { | ||
| 421 | ptrdiff_t i; | ||
| 422 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | ||
| 423 | 419 | ||
| 424 | GCPRO5 (infile, buffer, current_dir, path, error_file); | 420 | { |
| 425 | argument_coding.dst_multibyte = 0; | 421 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 426 | for (i = 4; i < nargs; i++) | 422 | |
| 427 | { | 423 | GCPRO5 (infile, buffer, current_dir, path, error_file); |
| 428 | argument_coding.src_multibyte = STRING_MULTIBYTE (args[i]); | 424 | if (nargs > 4) |
| 429 | if (CODING_REQUIRE_ENCODING (&argument_coding)) | 425 | { |
| 430 | /* We must encode this argument. */ | 426 | ptrdiff_t i; |
| 431 | args[i] = encode_coding_string (&argument_coding, args[i], 1); | 427 | |
| 432 | } | 428 | argument_coding.dst_multibyte = 0; |
| 433 | UNGCPRO; | 429 | for (i = 4; i < nargs; i++) |
| 434 | for (i = 4; i < nargs; i++) | 430 | { |
| 435 | new_argv[i - 3] = SDATA (args[i]); | 431 | argument_coding.src_multibyte = STRING_MULTIBYTE (args[i]); |
| 436 | new_argv[i - 3] = 0; | 432 | if (CODING_REQUIRE_ENCODING (&argument_coding)) |
| 437 | } | 433 | /* We must encode this argument. */ |
| 438 | else | 434 | args[i] = encode_coding_string (&argument_coding, args[i], 1); |
| 439 | new_argv[1] = 0; | 435 | } |
| 440 | new_argv[0] = SDATA (path); | 436 | for (i = 4; i < nargs; i++) |
| 437 | new_argv[i - 3] = SDATA (args[i]); | ||
| 438 | new_argv[i - 3] = 0; | ||
| 439 | } | ||
| 440 | else | ||
| 441 | new_argv[1] = 0; | ||
| 442 | if (STRING_MULTIBYTE (path)) | ||
| 443 | path = ENCODE_FILE (path); | ||
| 444 | new_argv[0] = SDATA (path); | ||
| 445 | UNGCPRO; | ||
| 446 | } | ||
| 441 | 447 | ||
| 442 | #ifdef MSDOS /* MW, July 1993 */ | 448 | #ifdef MSDOS /* MW, July 1993 */ |
| 443 | 449 | ||