vdr-1.4.1: bug report and fix: ReadLink with relative targets

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

 



Patrick Cernko wrote:
> Hi again,
> 
> Patrick Cernko wrote:
>> Hi Klaus, hi list,
>>
>> today I discovered that the ReadLink function (used in e.g. cSafeFile)
>> does not handle relative links correctly. I used a symlinked
>> channels.conf like that:
>>
>> errror@ds9:/var/lib/vdr> ll channels.conf
>> lrwxrwxrwx  1 errror vdr 20 2006-06-12 00:03 channels.conf ->
>> channels.conf.normal
>>
>> but vdr tried to write to channels.conf.$$$ in its current working
>> directory ("/") which failed. :-(
>>
>> The bug is caused by the ReadLink function which always took the
>> unchanged value of the found link as target (without prepending the
>> links path for relative links).
>>
>> As a fix, I added a check for relative links (== not starting with a
>> '/') and prepend the directory of the symlink. For that purpose I use
>> some small parts from the coreutils "dirname" program as I learned for a
>> long time that doing something so easy as computing the directory part
>> of a path can lead to several errors if not done right. :-)
>>
>> Appended you find the patch, which makes vdr handle relative symlinks
>> correctly.
>>
>> @Klaus: Feel free to review/reduce the code but pay attention to the
>> special cases! ;-)

Well, your patch looks like overkill to me ;-)

What about using 'canonicalize_file_name()' instead?

See the attached patch.

Klaus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vdr-1.4.1-readlink.diff
Type: text/x-patch
Size: 988 bytes
Desc: not available
Url : http://www.linuxtv.org/pipermail/vdr/attachments/20060617/da40788c/vdr-1.4.1-readlink.bin

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux