RemoveFileOrDir in tools.c

  • Hello,
    First of all, excuse me for posting in English, but I've not seen nothing related to patches in international forums. Feel free to reply in German.


    In tools.c, when removing a file that is a symlink, the buffer size allocated for the target file path is twice the size of the link path. Under certain circumstances the supposition this is enough is wrong.


    In countries like mine (allow me to omit which one it is...) there are many TV stations which have serious problems with the quality of the EPG they provide. In particular, they don't seem to understand the difference between the "short description" and "description" fields and are prone to fill the first one with the second one. If you are recording a series episode you may end with a filename which contains as much of the description as possible. When you change the name of the recording for a more reasonable one, the problem is served.


    I think that a call to stat, should be done instead. This patch is for an old vdr, but I think with minor changes it still applies:


  • I agree that this is a bug, though it does not apply to vanilla VDR, since VDR itself cannot rename a recording, and the symlink always has the same name as the recording itself. Unless you have very different path lengths to your recording directories.


    However, IMHO this patch misses a test whether the stated file actually IS an symbolic link. If the name refers to a real file, a filename buffer of the size of the file will be allocated, which may be several gigabytes. Just add a test to S_ISLNK(st2.st_mode).



    Cheers,


    Udo

  • Please test the following patch, which also includes Udo's suggestion (I hope I've put it at the right place ;-):



    BTW: I would need your real name and email address if you want to be mentioned in VDR's CONTRIBUTORS file.


    Klaus