diff options
| author | is <is@NetBSD.org> | 2001-05-03 20:43:16 +0000 |
|---|---|---|
| committer | is <is@NetBSD.org> | 2001-05-03 20:43:16 +0000 |
| commit | 2afc3dfa0d67d92a23a30d189fd97e57c983f2bc (patch) | |
| tree | 1733b4b2da6fbaf5ac8fcc3cdbcfd56a18e46e2d /gnu/libexec | |
| parent | e3f2f91bfbcada18109a68c361552394c62c9fae (diff) | |
Don't divide by zero when computing timeout values, else we SIGFPE when
sending "long" files over pipe links.
This fix closely follows the one suggested by <felix@subnet.sub.net> in
an email to Ian Lance Tailor years ago.
Diffstat (limited to 'gnu/libexec')
| -rw-r--r-- | gnu/libexec/uucp/libunix/serial.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gnu/libexec/uucp/libunix/serial.c b/gnu/libexec/uucp/libunix/serial.c index 3978c84e2de..7bf299208d1 100644 --- a/gnu/libexec/uucp/libunix/serial.c +++ b/gnu/libexec/uucp/libunix/serial.c @@ -26,7 +26,7 @@ #include "uucp.h" #if USE_RCS_ID -const char serial_rcsid[] = "$Id: serial.c,v 1.5 1998/02/14 07:25:55 mycroft Exp $"; +const char serial_rcsid[] = "$Id: serial.c,v 1.6 2001/05/03 20:43:16 is Exp $"; #endif #include "uudefs.h" @@ -2376,7 +2376,8 @@ fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport) else csleepchars = MAX_INPUT - 10; - isleep = (int) (((long) csleepchars * 10000L) / q->ibaud); + isleep = q->ibaud ? (int) (((long) csleepchars * 10000L) / q->ibaud) + : 1000; isleep -= 10; if (isleep > 10) @@ -2778,9 +2779,14 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread) / baud bits/sec) * 10 bits/byte) */ - stime.tv_sec = (long) 10240 / q->ibaud; - stime.tv_usec = ((((long) 1024000000 / q->ibaud) * (long) 10) - % (long) 1000000); + if (q->ibaud) { + stime.tv_sec = (long) 10240 / q->ibaud; + stime.tv_usec = ((((long) 1024000000 / q->ibaud) * (long) 10) + % (long) 1000000); + } else { + stime.tv_sec = 1; + stime.tv_usec = 0; + } imask = 1 << q->o; if (imask == 0) @@ -2851,7 +2857,7 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread) we don't need to use the catch stuff, since we know that HAVE_RESTARTABLE_SYSCALLS is 0. */ usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); - alarm ((int) ((long) 10240 / q->ibaud) + 1); + alarm ( q->ibaud ? (int) ((long) 10240 / q->ibaud) + 1 : 1); /* There is a race condition here: on a severely loaded system, we could get the alarm before we start the |
