[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-xen master] 9pfs: fix name_to_path assertion in v9fs_complete_rename()



commit d13a0bde83d216ec07d2fe6e54fe1bab34643db1
Author:     Jan Dakinevich <jan.dakinevich@xxxxxxxxx>
AuthorDate: Wed Sep 20 08:48:52 2017 +0200
Commit:     Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
CommitDate: Fri Sep 22 18:23:11 2017 -0500

    9pfs: fix name_to_path assertion in v9fs_complete_rename()
    
    The third parameter of v9fs_co_name_to_path() must not contain `/'
    character.
    
    The issue is most likely related to 9p2000.u protocol only.
    
    Signed-off-by: Jan Dakinevich <jan.dakinevich@xxxxxxxxx>
    [groug, regression caused by commit f57f5878578a # 2.10]
    Signed-off-by: Greg Kurz <groug@xxxxxxxx>
    
    (cherry picked from commit 4d8bc7334b06ef01a21cad3d1eb8dc183037a06b)
    Signed-off-by: Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
---
 hw/9pfs/9p.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 6d68db0..db9ec59 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -2555,13 +2555,11 @@ static int coroutine_fn v9fs_complete_rename(V9fsPDU 
*pdu, V9fsFidState *fidp,
                                              int32_t newdirfid,
                                              V9fsString *name)
 {
-    char *end;
     int err = 0;
     V9fsPath new_path;
     V9fsFidState *tfidp;
     V9fsState *s = pdu->s;
     V9fsFidState *dirfidp = NULL;
-    char *old_name, *new_name;
 
     v9fs_path_init(&new_path);
     if (newdirfid != -1) {
@@ -2579,18 +2577,15 @@ static int coroutine_fn v9fs_complete_rename(V9fsPDU 
*pdu, V9fsFidState *fidp,
             goto out;
         }
     } else {
-        old_name = fidp->path.data;
-        end = strrchr(old_name, '/');
-        if (end) {
-            end++;
-        } else {
-            end = old_name;
-        }
-        new_name = g_malloc0(end - old_name + name->size + 1);
-        strncat(new_name, old_name, end - old_name);
-        strncat(new_name + (end - old_name), name->data, name->size);
-        err = v9fs_co_name_to_path(pdu, NULL, new_name, &new_path);
-        g_free(new_name);
+        char *dir_name = g_path_get_dirname(fidp->path.data);
+        V9fsPath dir_path;
+
+        v9fs_path_init(&dir_path);
+        v9fs_path_sprintf(&dir_path, "%s", dir_name);
+        g_free(dir_name);
+
+        err = v9fs_co_name_to_path(pdu, &dir_path, name->data, &new_path);
+        v9fs_path_free(&dir_path);
         if (err < 0) {
             goto out;
         }
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.