]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
SFTP dir: increase buffer size counter
authorDaniel Stenberg <daniel@haxx.se>
Tue, 27 Dec 2011 21:58:03 +0000 (22:58 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 31 Dec 2011 22:52:15 +0000 (23:52 +0100)
When the buffer gets realloced to hold the file name in the
SSH_SFTP_READDIR_LINK state, the counter was not bumped accordingly.

Reported by: Armel Asselin
Patch by: Armel Asselin
Bug: http://curl.haxx.se/mail/lib-2011-12/0249.html

lib/ssh.c

index 23ba5f4e0afc2173d3dfd68dd6dc5f2e68e1dbaa..e92916e9d2f9c77d7641477239351ea404d95572 100644 (file)
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -1885,9 +1885,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
       Curl_safefree(sshc->readdir_linkPath);
       sshc->readdir_linkPath = NULL;
 
-      new_readdir_line = realloc(sshc->readdir_line,
-                                 sshc->readdir_totalLen + 4 +
-                                 sshc->readdir_len);
+      /* get room for the filename and extra output */
+      sshc->readdir_totalLen += 4 + sshc->readdir_len:
+      new_readdir_line = realloc(sshc->readdir_line, sshc->readdir_totalLen);
       if(!new_readdir_line) {
         Curl_safefree(sshc->readdir_line);
         sshc->readdir_line = NULL;