diff options
author | Max Kellermann <max@duempel.org> | 2012-09-04 11:28:13 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-09-04 11:28:13 +0200 |
commit | 2a4c7994715f2b995b3ec7587f24eb0855209983 (patch) | |
tree | 4b29f97155b6ac6c35453e0937204cd9ca123007 /src/update_walk.c | |
parent | 333d226ed0044cf6a6387e03805be2d7f6dac6f2 (diff) | |
parent | 41487426f5fb19c963e5f94e8c4f791637e2da03 (diff) |
Merge branch 'v0.17.x'
Diffstat (limited to 'src/update_walk.c')
-rw-r--r-- | src/update_walk.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/update_walk.c b/src/update_walk.c index 615bf41a..8554e8f3 100644 --- a/src/update_walk.c +++ b/src/update_walk.c @@ -283,12 +283,20 @@ skip_symlink(const struct directory *directory, const char *utf8_name) return true; char buffer[MPD_PATH_MAX]; - ssize_t ret = readlink(path_fs, buffer, sizeof(buffer)); + ssize_t length = readlink(path_fs, buffer, sizeof(buffer)); g_free(path_fs); - if (ret < 0) + if (length < 0) /* don't skip if this is not a symlink */ return errno != EINVAL; + if ((size_t)length >= sizeof(buffer)) + /* skip symlinks when the buffer is too small for the + link target */ + return true; + + /* null-terminate the buffer, because readlink() will not */ + buffer[length] = 0; + if (!follow_inside_symlinks && !follow_outside_symlinks) { /* ignore all symlinks */ return true; |