From 94bae4dd18432528b7864f0df91d9b81aad11c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= <tim.ruehsen@gmx.de> Date: Thu, 13 Feb 2020 20:11:45 +0100 Subject: [PATCH] * src/ftp.c (ftp_retrieve_list): Remove use of alloca --- src/ftp.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ftp.c b/src/ftp.c index 73d3cb1d..d8d36d0f 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -2335,10 +2335,22 @@ The sizes do not match (local %s) -- retrieving.\n\n"), size_t len = strlen (f->linkto) + 1; if (S_ISLNK (st.st_mode)) { - char *link_target = (char *)alloca (len); - size_t n = readlink (con->target, link_target, len); - if ((n == len - 1) - && (memcmp (link_target, f->linkto, n) == 0)) + char buf[1024], *link_target; + size_t n; + bool res; + + if (len < sizeof (buf)) + link_target = buf; + else + link_target = xmalloc (len); + + n = readlink (con->target, link_target, len); + res = (n == len - 1) && (memcmp (link_target, f->linkto, n) == 0); + + if (link_target != buf) + xfree (link_target); + + if (res) { logprintf (LOG_VERBOSE, _("\ Already have correct symlink %s -> %s\n\n"),