Bugzilla – Attachment 1282 Details for
Bug 1286
SFTP keeps reading input until it runs out of buffer space
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Revised diff
sftp-buf.diff (text/plain), 1.66 KB, created by
Damien Miller
on 2007-05-17 15:57:14 AEST
(
hide
)
Description:
Revised diff
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2007-05-17 15:57:14 AEST
Size:
1.66 KB
patch
obsolete
>Index: sftp-server.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/sftp-server.c,v >retrieving revision 1.72 >diff -u -p -r1.72 sftp-server.c >--- sftp-server.c 18 Apr 2007 01:12:43 -0000 1.72 >+++ sftp-server.c 17 May 2007 05:54:56 -0000 >@@ -1193,7 +1193,7 @@ main(int argc, char **argv) > int in, out, max, ch, skipargs = 0, log_stderr = 0; > ssize_t len, olen, set_size; > SyslogFacility log_facility = SYSLOG_FACILITY_AUTH; >- char *cp; >+ char *cp, buf[4*4096]; > > extern char *optarg; > extern char *__progname; >@@ -1271,7 +1271,15 @@ main(int argc, char **argv) > memset(rset, 0, set_size); > memset(wset, 0, set_size); > >- FD_SET(in, rset); >+ /* >+ * Ensure that we can read a full buffer and handle >+ * the worst-case length packet it can generate, >+ * otherwise apply backpressure by stopping reads. >+ */ >+ if (buffer_check_alloc(&iqueue, sizeof(buf)) && >+ buffer_check_alloc(&oqueue, SFTP_MAX_MSG_LENGTH + 4)) >+ FD_SET(in, rset); >+ > olen = buffer_len(&oqueue); > if (olen > 0) > FD_SET(out, wset); >@@ -1285,7 +1293,6 @@ main(int argc, char **argv) > > /* copy stdin to iqueue */ > if (FD_ISSET(in, rset)) { >- char buf[4*4096]; > len = read(in, buf, sizeof buf); > if (len == 0) { > debug("read eof"); >@@ -1307,7 +1314,13 @@ main(int argc, char **argv) > buffer_consume(&oqueue, len); > } > } >- /* process requests from client */ >- process(); >+ >+ /* >+ * Process requests from client if we can fit the results >+ * into the output buffer, otherwise stop processing input >+ * and let the output queue drain. >+ */ >+ if (buffer_check_alloc(&oqueue, SFTP_MAX_MSG_LENGTH + 4)) >+ process(); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1286
:
1238
|
1239
|
1241
| 1282