Now stopping scanning the video directory if there are too many levels of symbolic links

This commit is contained in:
Klaus Schmidinger 2006-02-12 11:46:44 +01:00
parent c9b5fd6588
commit 23d7402c00
4 changed files with 18 additions and 5 deletions

View File

@ -552,6 +552,8 @@ Helmut Auer <vdr@helmutauer.de>
for separating the 'install' target into several individual targets for separating the 'install' target into several individual targets
for reporting a problem with scrolling with Up/Down in case there are non-selectable for reporting a problem with scrolling with Up/Down in case there are non-selectable
items at the beginning of the menu items at the beginning of the menu
for a patch that was used to implement stopping scanning the video directory if
there are too many levels of symbolic links
Jeremy Hall <jhall@UU.NET> Jeremy Hall <jhall@UU.NET>
for fixing an incomplete initialization of the filter parameters in eit.c for fixing an incomplete initialization of the filter parameters in eit.c

View File

@ -4323,3 +4323,6 @@ Video Disk Recorder Revision History
Skawina). Skawina).
- The "Back" key now restores the original string when pressed while editing a - The "Back" key now restores the original string when pressed while editing a
string item (suggested by Markus Hahn). string item (suggested by Markus Hahn).
- Now stopping scanning the video directory if there are too many levels of
symbolic links, which might indicate a recursive link loop (based on a patch
from Helmut Auer).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: recording.c 1.134 2006/02/05 12:34:08 kls Exp $ * $Id: recording.c 1.135 2006/02/12 11:34:19 kls Exp $
*/ */
#include "recording.h" #include "recording.h"
@ -58,6 +58,8 @@
#define MAX_SUBTITLE_LENGTH 40 #define MAX_SUBTITLE_LENGTH 40
#define MAX_LINK_LEVEL 6
bool VfatFileSystem = false; bool VfatFileSystem = false;
cRecordings DeletedRecordings(true); cRecordings DeletedRecordings(true);
@ -811,7 +813,7 @@ void cRecordings::Refresh(bool Foreground)
ScanVideoDir(VideoDirectory, Foreground); ScanVideoDir(VideoDirectory, Foreground);
} }
void cRecordings::ScanVideoDir(const char *DirName, bool Foreground) void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLevel)
{ {
cReadDir d(DirName); cReadDir d(DirName);
struct dirent *e; struct dirent *e;
@ -821,7 +823,13 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground)
asprintf(&buffer, "%s/%s", DirName, e->d_name); asprintf(&buffer, "%s/%s", DirName, e->d_name);
struct stat st; struct stat st;
if (stat(buffer, &st) == 0) { if (stat(buffer, &st) == 0) {
int Link = 0;
if (S_ISLNK(st.st_mode)) { if (S_ISLNK(st.st_mode)) {
if (LinkLevel > MAX_LINK_LEVEL) {
isyslog("max link level exceeded - not scanning %s", buffer);
continue;
}
Link = 1;
char *old = buffer; char *old = buffer;
buffer = ReadLink(old); buffer = ReadLink(old);
free(old); free(old);
@ -849,7 +857,7 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground)
delete r; delete r;
} }
else else
ScanVideoDir(buffer, Foreground); ScanVideoDir(buffer, Foreground, LinkLevel + Link);
} }
} }
free(buffer); free(buffer);

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: recording.h 1.49 2006/01/20 17:18:28 kls Exp $ * $Id: recording.h 1.50 2006/02/12 11:34:34 kls Exp $
*/ */
#ifndef __RECORDING_H #ifndef __RECORDING_H
@ -104,7 +104,7 @@ private:
int state; int state;
const char *UpdateFileName(void); const char *UpdateFileName(void);
void Refresh(bool Foreground = false); void Refresh(bool Foreground = false);
void ScanVideoDir(const char *DirName, bool Foreground = false); void ScanVideoDir(const char *DirName, bool Foreground = false, int LinkLevel = 0);
protected: protected:
void Action(void); void Action(void);
public: public: