summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2011-01-16 23:18:33 +1100
committerDamien Miller <djm@mindrot.org>2011-01-16 23:18:33 +1100
commitcfd6e4f57fc8489ed4065be06d85de3f30575fe2 (patch)
tree4ccaf98368853d997ac043d9088e85409b3e891f
parent6fb6fd566267da4f36499078caf46da5291f4b8c (diff)
- djm@cvs.openbsd.org 2011/01/16 12:05:59
[clientloop.c] a couple more tweaks to the post-close protocol 1 stderr/stdout flush: now that we use atomicio(), convert them from while loops to if statements add test and cast to compile cleanly with -Wsigned
-rw-r--r--ChangeLog5
-rw-r--r--clientloop.c20
2 files changed, 14 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index d16a9fb42..a0282b739 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,11 @@
11 [sshconnect.c] 11 [sshconnect.c]
12 reset the SIGPIPE handler when forking to execute child processes; 12 reset the SIGPIPE handler when forking to execute child processes;
13 ok dtucker@ 13 ok dtucker@
14 - djm@cvs.openbsd.org 2011/01/16 12:05:59
15 [clientloop.c]
16 a couple more tweaks to the post-close protocol 1 stderr/stdout flush:
17 now that we use atomicio(), convert them from while loops to if statements
18 add test and cast to compile cleanly with -Wsigned
14 19
1520110114 2020110114
16 - OpenBSD CVS Sync 21 - OpenBSD CVS Sync
diff --git a/clientloop.c b/clientloop.c
index 325657ba2..f6c1444a3 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.230 2011/01/16 11:50:05 djm Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.231 2011/01/16 12:05:59 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1590,25 +1590,23 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
1590 } 1590 }
1591 1591
1592 /* Output any buffered data for stdout. */ 1592 /* Output any buffered data for stdout. */
1593 while (buffer_len(&stdout_buffer) > 0) { 1593 if (buffer_len(&stdout_buffer) > 0) {
1594 len = atomicio(vwrite, fileno(stdout), 1594 len = atomicio(vwrite, fileno(stdout),
1595 buffer_ptr(&stdout_buffer), buffer_len(&stdout_buffer)); 1595 buffer_ptr(&stdout_buffer), buffer_len(&stdout_buffer));
1596 if (len != buffer_len(&stdout_buffer)) { 1596 if (len < 0 || (u_int)len != buffer_len(&stdout_buffer))
1597 error("Write failed flushing stdout buffer."); 1597 error("Write failed flushing stdout buffer.");
1598 break; 1598 else
1599 } 1599 buffer_consume(&stdout_buffer, len);
1600 buffer_consume(&stdout_buffer, len);
1601 } 1600 }
1602 1601
1603 /* Output any buffered data for stderr. */ 1602 /* Output any buffered data for stderr. */
1604 while (buffer_len(&stderr_buffer) > 0) { 1603 if (buffer_len(&stderr_buffer) > 0) {
1605 len = atomicio(vwrite, fileno(stderr), 1604 len = atomicio(vwrite, fileno(stderr),
1606 buffer_ptr(&stderr_buffer), buffer_len(&stderr_buffer)); 1605 buffer_ptr(&stderr_buffer), buffer_len(&stderr_buffer));
1607 if (len != buffer_len(&stderr_buffer)) { 1606 if (len < 0 || (u_int)len != buffer_len(&stderr_buffer))
1608 error("Write failed flushing stderr buffer."); 1607 error("Write failed flushing stderr buffer.");
1609 break; 1608 else
1610 } 1609 buffer_consume(&stderr_buffer, len);
1611 buffer_consume(&stderr_buffer, len);
1612 } 1610 }
1613 1611
1614 /* Clear and free any buffers. */ 1612 /* Clear and free any buffers. */