Dear visitor, welcome to VDR Portal. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
--- VDR-ori/tools.c 2010-06-20 00:37:37.000000000 +0200
+++ VDR-bui/tools.c 2010-06-20 01:01:18.000000000 +0200
@@ -374,22 +374,29 @@
char *buffer;
asprintf(&buffer, "%s/%s", FileName, e->d_name);
if (FollowSymlinks) {
- int size = strlen(buffer) * 2; // should be large enough
- char *l = MALLOC(char, size);
- int n = readlink(buffer, l, size);
- if (n < 0) {
- if (errno != EINVAL)
- LOG_ERROR_STR(buffer);
+ struct stat st2;
+ if (stat(buffer, &st2) == 0) {
+ int size = st2.st_size + 1;
+ char *l = MALLOC(char, size);
+ int n = readlink(buffer, l, st2.st_size);
+ if (n < 0) {
+ if (errno != EINVAL)
+ LOG_ERROR_STR(buffer);
+ }
+ else if (n < size) {
+ l[n] = 0;
+ dsyslog("removing %s", l);
+ if (remove(l) < 0)
+ LOG_ERROR_STR(l);
+ }
+ else
+ esyslog("ERROR: symlink name length (%d) exceeded anticipated buffer size (%d)", n, size);
+ free(l);
}
- else if (n < size) {
- l[n] = 0;
- dsyslog("removing %s", l);
- if (remove(l) < 0)
- LOG_ERROR_STR(l);
+ else if (errno != ENOENT) {
+ LOG_ERROR_STR(FileName);
+ return false;
}
- else
- esyslog("ERROR: symlink name length (%d) exceeded anticipated buffer size (%d)", n, size);
- free(l);
}
dsyslog("removing %s", buffer);
if (remove(buffer) < 0)
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
--- tools.c 2010/02/28 13:31:46 2.7
+++ tools.c 2010/08/29 14:50:28
@@ -367,22 +367,31 @@
if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) {
cString buffer = AddDirectory(FileName, e->d_name);
if (FollowSymlinks) {
- int size = strlen(buffer) * 2; // should be large enough
- char *l = MALLOC(char, size);
- int n = readlink(buffer, l, size);
- if (n < 0) {
- if (errno != EINVAL)
- LOG_ERROR_STR(*buffer);
+ struct stat st2;
+ if (stat(buffer, &st2) == 0) {
+ if (S_ISLNK(st2.st_mode)) {
+ int size = st2.st_size + 1;
+ char *l = MALLOC(char, size);
+ int n = readlink(buffer, l, st2.st_size);
+ if (n < 0) {
+ if (errno != EINVAL)
+ LOG_ERROR_STR(*buffer);
+ }
+ else if (n < size) {
+ l[n] = 0;
+ dsyslog("removing %s", l);
+ if (remove(l) < 0)
+ LOG_ERROR_STR(l);
+ }
+ else
+ esyslog("ERROR: symlink name length (%d) exceeded anticipated buffer size (%d)", n, size);
+ free(l);
+ }
}
- else if (n < size) {
- l[n] = 0;
- dsyslog("removing %s", l);
- if (remove(l) < 0)
- LOG_ERROR_STR(l);
+ else if (errno != ENOENT) {
+ LOG_ERROR_STR(FileName);
+ return false;
}
- else
- esyslog("ERROR: symlink name length (%d) exceeded anticipated buffer size (%d)", n, size);
- free(l);
}
dsyslog("removing %s", *buffer);
if (remove(buffer) < 0)
|