From: Paul Eggert Date: Thu, 13 Oct 2011 07:00:35 +0000 (-0700) Subject: * process.c (Fsignal_process): Check for process-ids out of pid_t range rather than... X-Git-Tag: emacs-24.2.90~471^2~6^2~153 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d83cf4ccb94a5d4ea15980d76f7b16ee19909200;p=emacs.git * process.c (Fsignal_process): Check for process-ids out of pid_t range rather than relying on undefined behavior. --- diff --git a/src/ChangeLog b/src/ChangeLog index 5826a4bd412..9bcbc92f5a4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -562,8 +562,8 @@ (sigchld_handler): Check that fixnums are in proper range for system types. (Fsignal_process): Simplify by avoiding a goto. - Treat out-of-range process numbers just like invalid numbers - that fit into the pid_t range, and return -1. + Check for process-ids out of pid_t range rather than relying on + undefined behavior. (Fformat_network_address, read_process_output, send_process) (Fprocess_send_region, status_notify): 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. */) if (NILP (process)) return process; - if (INTEGERP (process)) - { - EMACS_INT v = XINT (process); - if (! (TYPE_MINIMUM (pid_t) <= v && v <= TYPE_MAXIMUM (pid_t))) - return make_number (-1); - pid = v; - } - else if (FLOATP (process)) - { - double v = XFLOAT_DATA (process); - if (! (TYPE_MINIMUM (pid_t) <= v && v < TYPE_MAXIMUM (pid_t) + 1.0)) - return make_number (-1); - pid = v; - if (pid != v) - return make_number (-1); - } + if (NUMBERP (process)) + CONS_TO_INTEGER (process, pid_t, pid); else { CHECK_PROCESS (process);