[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] Contribution on bug #45037

From: Ander Juaristi Alamos
Subject: Re: [Bug-wget] Contribution on bug #45037
Date: Sat, 16 May 2015 22:10:20 +0200

> Hello,
> I found another task where I want to contribute, the issue with 45037.
> For what I understand, and read in the mailling list, the problem occur in 
> ftp.c
> ftp_loop_internal -> remove_link.
> But what I don't understand, is why each time he try to remove
> the symbolic link. What is the purpose of this statement, in overall context 
> of code.

As Tim pointed out, the purpose is not to overwrite the content of the file the 
link points to.
If README was a regular file and then you passed "-O README", it's okay to 
overwrite it (I don't
know what's Wget default behavior here, if it prompts the user or whatever), 
because the user is supposed
to be aware of such action. But if README was a symlink, passing "-O README" 
could be a malicious
action, as Angel said. If you want an example of such an action and its 
google for "Symlink race".

> That was here, because that was a feature, and now a bug, because some others 
> statements was removed ?
> If for example I have a symbolic link README in local, and try to download 
> another file, with the
> same name README remotely, with -O foo, normally, my symbolic link README 
> should not be modified.

Exactly. Looking at the code, my guess is that the person who wrote it didn't 
take into account that
the user could have passed the "-O" option (or maybe it wasn't yet implemented 
then, who knows). He or she
just picked the name of the downloaded file.

> But now if I pass -O README, the symbolic link will be removed because it's a 
> redirection ?
> so It's not possible to just renamed it ?

It sounds like that's exactly what should be done. Treat the symlink as if it 
was a local file: if a symlink
exists with the same name as the downloaded file, rename the downloaded file to 
README.1, for instance.

> Sorry if my questions are silly, but I'am starting in the code of wget, and 
> my knowledge are weak.

Something this project has taught me is that there's no silly question. It's 
better to ask even though you're
not really sure (and you've made some research on your own before :D) than keep 
quiet and make wrong assumptions by yourself.

> Thank you
> Best
> Loic Maury

reply via email to

[Prev in Thread] Current Thread [Next in Thread]