]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
libssh: get rid of PATH_MAX
authorEmil Engler <me@emilengler.com>
Thu, 1 Apr 2021 16:24:53 +0000 (18:24 +0200)
committerJay Satiro <raysatiro@yahoo.com>
Tue, 6 Apr 2021 03:21:19 +0000 (23:21 -0400)
This removes the last occurrence of PATH_MAX inside our libssh
implementation by calculating the path length from the string length of
the two components.

Closes #6829

lib/vssh/libssh.c

index 1bb644eedd4c3429d42f506811e19aac80ee287f..4644f4cb96e5ec559dae9bcb6ba0511679fddb82 100644 (file)
@@ -1453,16 +1453,15 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
           if((sshc->readdir_attrs->flags & SSH_FILEXFER_ATTR_PERMISSIONS) &&
              ((sshc->readdir_attrs->permissions & S_IFMT) ==
               S_IFLNK)) {
-            sshc->readdir_linkPath = malloc(PATH_MAX + 1);
+            sshc->readdir_linkPath = aprintf("%s%s", protop->path,
+                                             sshc->readdir_filename);
+
             if(sshc->readdir_linkPath == NULL) {
               state(data, SSH_SFTP_CLOSE);
               sshc->actualcode = CURLE_OUT_OF_MEMORY;
               break;
             }
 
-            msnprintf(sshc->readdir_linkPath, PATH_MAX, "%s%s", protop->path,
-                      sshc->readdir_filename);
-
             state(data, SSH_SFTP_READDIR_LINK);
             break;
           }