Skip to contentSkip to conversation

qemu_strdup() doesn't copy alast character

PATCH Applied Gleb Natapov 2 participants 2 messages Aug 25, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu_strdup() doesn't copy alast character

Because of off by one error.

qemu-malloc.c +1 -1
index 8ad6168..3bffae1 100644
@@ -60,6 +60,6 @@ char *qemu_strdup(const char *str)
     ptr = qemu_malloc(len + 1);
     if (!ptr)
         return NULL;
-    pstrcpy(ptr, len, str);
+    pstrcpy(ptr, len + 1, str);
     return ptr;
 }

--
Gleb.

Applied
#1 lore raw
Quoted 11 lines · Gleb Natapov

Because of off by one error.

diff --git a/qemu-malloc.c b/qemu-malloc.c index 8ad6168..3bffae1 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -60,6 +60,6 @@ char *qemu_strdup(const char *str)

Quoted 7 lines
     ptr = qemu_malloc(len + 1);
     if (!ptr)
         return NULL;
 -    pstrcpy(ptr, len, str);
 +    pstrcpy(ptr, len + 1, str);
     return ptr;

}

Thanks, applied. I had introduced this in the patch (r5044) where I changed some strcpys to pstrcpys. Maybe the same bug got in somewhere else too.