Skip to contentSkip to conversation

hw/virtio-9p-local.c: Remove unnecessary null char in symlink file

PATCH In review Harsh Prateek Bora 3 participants 3 messages Dec 21, 2010 – Dec 22, 2010

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hw/virtio-9p-local.c: Remove unnecessary null char in symlink file

This patch removes the addition of null char in symlink file which is being appended to file in case of mapped security model. Without this patch, the extra null char causes LTP testcase lstat03 to fail and hence this fix is required.

v2:
- Description updated to mention about LTP lstat testcase failure without this patch.

---
 hw/virtio-9p-local.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/virtio-9p-local.c +1 -1
index 656bfb3..3b6447d 100644
@@ -370,7 +370,7 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath,
             return fd;
         }
         /* Write the oldpath (target) to the file. */
-        oldpath_size = strlen(oldpath) + 1;
+        oldpath_size = strlen(oldpath);
         do {
             write_size = write(fd, (void *)oldpath, oldpath_size);
         } while (write_size == -1 && errno == EINTR);
Signature · 1 line
1.7.1.1
#1 lore raw
Quoted 4 lines · Harsh Prateek Bora

This patch removes the addition of null char in symlink file which is being appended to file in case of mapped security model. Without this patch, the extra null char causes LTP testcase lstat03 to fail and hence this fix is required.

Looks good.

Related note: local_readlink() with fs_sm == SM_MAPPED reads the contents of *any* file. I don't see a check that the file is actually a symlink. What if an application relies on the EINVAL return value when calling readlink() on something that is not a file (not sure how this maps through to 9p though)?

Stefan

#2 lore raw
Quoted 7 lines · Stefan Hajnoczi
Quoted 4 lines · Harsh Prateek Bora

This patch removes the addition of null char in symlink file which is being appended to file in case of mapped security model. Without this patch, the extra null char causes LTP testcase lstat03 to fail and hence this fix is required.

Quoted 7 lines

Looks good.

Related note: local_readlink() with fs_sm == SM_MAPPED reads the contents of *any* file. I don't see a check that the file is actually a symlink. What if an application relies on the EINVAL return value when calling readlink() on something that is not a file (not sure how this maps through to 9p though)?

Stefan, yes. This is a bug we realized .. fix will be on the way shortly. :)

Thanks,
JV

Quoted 3 lines

Stefan