diff options
| author | Paul Eggert | 2011-10-13 00:00:35 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-10-13 00:00:35 -0700 |
| commit | d83cf4ccb94a5d4ea15980d76f7b16ee19909200 (patch) | |
| tree | 89b250df6ff7ec8feea1601155f583cd7d2c0e3d /src | |
| parent | 3f4eabd19215fe1271594ac3ec81d543d2714f20 (diff) | |
| download | emacs-d83cf4ccb94a5d4ea15980d76f7b16ee19909200.tar.gz emacs-d83cf4ccb94a5d4ea15980d76f7b16ee19909200.zip | |
* process.c (Fsignal_process): Check for process-ids out of pid_t range rather than relying on undefined behavior.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/process.c | 18 |
2 files changed, 4 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5826a4bd412..9bcbc92f5a4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -562,8 +562,8 @@ | |||
| 562 | (sigchld_handler): | 562 | (sigchld_handler): |
| 563 | Check that fixnums are in proper range for system types. | 563 | Check that fixnums are in proper range for system types. |
| 564 | (Fsignal_process): Simplify by avoiding a goto. | 564 | (Fsignal_process): Simplify by avoiding a goto. |
| 565 | Treat out-of-range process numbers just like invalid numbers | 565 | Check for process-ids out of pid_t range rather than relying on |
| 566 | that fit into the pid_t range, and return -1. | 566 | undefined behavior. |
| 567 | (Fformat_network_address, read_process_output, send_process) | 567 | (Fformat_network_address, read_process_output, send_process) |
| 568 | (Fprocess_send_region, status_notify): | 568 | (Fprocess_send_region, status_notify): |
| 569 | Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. | 569 | Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. |
diff --git a/src/process.c b/src/process.c index ea433d2c373..8270a57c177 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -5976,22 +5976,8 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */) | |||
| 5976 | if (NILP (process)) | 5976 | if (NILP (process)) |
| 5977 | return process; | 5977 | return process; |
| 5978 | 5978 | ||
| 5979 | if (INTEGERP (process)) | 5979 | if (NUMBERP (process)) |
| 5980 | { | 5980 | CONS_TO_INTEGER (process, pid_t, pid); |
| 5981 | EMACS_INT v = XINT (process); | ||
| 5982 | if (! (TYPE_MINIMUM (pid_t) <= v && v <= TYPE_MAXIMUM (pid_t))) | ||
| 5983 | return make_number (-1); | ||
| 5984 | pid = v; | ||
| 5985 | } | ||
| 5986 | else if (FLOATP (process)) | ||
| 5987 | { | ||
| 5988 | double v = XFLOAT_DATA (process); | ||
| 5989 | if (! (TYPE_MINIMUM (pid_t) <= v && v < TYPE_MAXIMUM (pid_t) + 1.0)) | ||
| 5990 | return make_number (-1); | ||
| 5991 | pid = v; | ||
| 5992 | if (pid != v) | ||
| 5993 | return make_number (-1); | ||
| 5994 | } | ||
| 5995 | else | 5981 | else |
| 5996 | { | 5982 | { |
| 5997 | CHECK_PROCESS (process); | 5983 | CHECK_PROCESS (process); |