joey@darkstar:~/tmp/y>ln -s /etc/passwd README
joey@darkstar:~/tmp/y>ls
README@
joey@darkstar:~/tmp/y>wget -O foo
ftp://ftp.funet.fi/pub/Linux/mirrors/debian/README
--2015-05-05 13:17:22--  ftp://ftp.funet.fi/pub/Linux/mirrors/debian/README
          => ‘foo’
Resolving ftp.funet.fi (ftp.funet.fi)... 193.166.3.2, 2001:708:10:9::20:2
Connecting to ftp.funet.fi (ftp.funet.fi)|193.166.3.2|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /pub/Linux/mirrors/debian ... done.
==> SIZE README ... 1495
==> PASV ... done.    ==> RETR README ... done.
Length: 1495 (1.5K) (unauthoritative)

README              100%[=====================>]   1.46K  5.45KB/s   in 0.3s


2015-05-05 13:17:28 (5.45 KB/s) - ‘foo’ saved [1495]

joey@darkstar:~/tmp/y>ls
foo

Doesn't happen if README is a file rather than a symlink, doesn't happen when
using http. The ftp downloader apparently has a bug..

This definitely is a bug. I've attached a small fix for this particular issue. If no one has any issues with it, I'll push it in a day.

Although, I think we should also look into the issue Giuseppe found, and also the point that Angel raised about compatibility with shell like redirection.

--
Thanking You,
Darshit Shah
From 7537c7e341948ee6e0ff5170a5a056d80a82cfde Mon Sep 17 00:00:00 2001
From: Darshit Shah <dar...@reniac.com>
Date: Thu, 7 May 2015 09:59:25 +0530
Subject: [PATCH] Fix #45037: Wget deletes wrong Symlink in ftp

    * ftp.c (ftp_loop_internal): Call remove_link() on the actual file
    name to be retrieved, not the filename in .LISTING.

    Reported-by: Joey Hess <i...@joeyh.name>
                 Noel Koethe <n...@debian.org>
---
 src/ftp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ftp.c b/src/ftp.c
index 68f1a33..0abd543 100644
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -1589,7 +1589,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi
     }
 
   /* Remove it if it's a link.  */
-  remove_link (con->target);
+  remove_link (locf);
 
   count = 0;
 
-- 
2.3.7

Attachment: pgp_wSkhCb6C0.pgp
Description: PGP signature

Reply via email to