Skip to contentSkip to conversation

Add a check for readlink in mapped mode.

PATCH In review Venkateswararao Jujjuri (JV) 2 participants 2 messages Dec 22, 2010 – Dec 23, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add a check for readlink in mapped mode.

---
 hw/9pfs/virtio-9p-local.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
hw/9pfs/virtio-9p-local.c +7 -0
index a8e7525..9a106d4 100644
@@ -112,6 +112,13 @@ static ssize_t local_readlink(FsContext *fs_ctx, const char *path,
     ssize_t tsize = -1;
     if (fs_ctx->fs_sm == SM_MAPPED) {
         int fd;
+        mode_t tmp_mode;
+        /* Make sure that it is a symlink */
+        if (getxattr(rpath(fs_ctx, path), "user.virtfs.mode", &tmp_mode,
+                    sizeof(mode_t)) <= 0 || !(tmp_mode & S_IFLNK)) {
+            errno = EINVAL;
+            return -1;
+        }
         fd = open(rpath(fs_ctx, path), O_RDONLY);
         if (fd == -1) {
             return -1;
Signature · 1 line
1.6.5.2