diff options
Diffstat (limited to 'support')
-rw-r--r-- | support/ChangeLog | 4 | ||||
-rw-r--r-- | support/serial.c | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/support/ChangeLog b/support/ChangeLog index 1b719cb6d07..424d27243fa 100644 --- a/support/ChangeLog +++ b/support/ChangeLog @@ -1,3 +1,7 @@ +2008-03-31 Miguel de Icaza <miguel@novell.com> + + * serial.c (write_serial): Avoid infinite loops, see #375580. + 2008-02-12 Jonathan Pryor <jpryor@novell.com> * signal.c: SLES9 has glib 2.2, so we can't rely on g_atomic_int_*(). diff --git a/support/serial.c b/support/serial.c index 9443e0bb923..4775805aaf5 100644 --- a/support/serial.c +++ b/support/serial.c @@ -95,7 +95,7 @@ write_serial (int fd, guchar *buffer, int offset, int count, int timeout) fd_set writefs; guint32 n; - n = count - offset; + n = count; FD_SET(fd, &writefs); tmval.tv_sec = timeout / 1000; @@ -113,7 +113,12 @@ write_serial (int fd, guchar *buffer, int offset, int count, int timeout) } } - t = write(fd, buffer + offset, count); + do { + t = write (fd, buffer + offset, n); + } while (t == -1 && errno == EINTR); + + if (t < 0) + return -1; if (timeout > 0) { @@ -121,7 +126,7 @@ write_serial (int fd, guchar *buffer, int offset, int count, int timeout) { return -1; } - } + } offset += t; n -= t; |