]> git.proxmox.com Git - qemu.git/commitdiff
Fix missing strnlen problems
authorBlue Swirl <blauwirbel@gmail.com>
Wed, 1 Jul 2009 18:24:44 +0000 (18:24 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Wed, 1 Jul 2009 18:24:44 +0000 (18:24 +0000)
Fix missing strnlen (a GNU extension) problems by using qemu_strnlen
used for user emulators also for system emulators.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
block.c
bsd-user/uaccess.c
cutils.c
linux-user/uaccess.c
qemu-common.h

diff --git a/block.c b/block.c
index 3fe9317023d443c5221ccafe9c58855912a162af..c7589b1c2a7be979260e2a30b74511588b11f106 100644 (file)
--- a/block.c
+++ b/block.c
@@ -225,7 +225,7 @@ static BlockDriver *find_protocol(const char *filename)
 {
     BlockDriver *drv1;
     char protocol[128];
-    int len = strnlen(filename, 127)+1;
+    int len = qemu_strnlen(filename, 127) + 1;
     const char *p;
 
 #ifdef _WIN32
index cc51449b47e351c9e93c4bb2c05058316e8d995a..9ec1b2343744e5c3c44128f2d97240c7f0750702 100644 (file)
@@ -37,17 +37,6 @@ abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len)
     return ret;
 }
 
-/* XXX: use host strnlen if available ? */
-static int qemu_strnlen(const char *s, int max_len)
-{
-    int i;
-    for(i = 0; i < max_len; i++) {
-        if (s[i] == '\0')
-            break;
-    }
-    return i;
-}
-
 /* Return the length of a string in target memory or -TARGET_EFAULT if
    access error  */
 abi_long target_strlen(abi_ulong guest_addr1)
index 73d4e1fbbdeae18543b746abaa0ea8523059fe70..6196a9055c6351833ff2a741f94720ef2d8dcc62 100644 (file)
--- a/cutils.c
+++ b/cutils.c
@@ -109,6 +109,19 @@ int stristart(const char *str, const char *val, const char **ptr)
     return 1;
 }
 
+/* XXX: use host strnlen if available ? */
+int qemu_strnlen(const char *s, int max_len)
+{
+    int i;
+
+    for(i = 0; i < max_len; i++) {
+        if (s[i] == '\0') {
+            break;
+        }
+    }
+    return i;
+}
+
 time_t mktimegm(struct tm *tm)
 {
     time_t t;
index 4d506935f8cad50c48c6c3ee85fee40d556ba47a..a4d108c2f7a0e9afba8cb8b26b34239391f5bec1 100644 (file)
@@ -37,17 +37,6 @@ abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len)
     return ret;
 }
 
-/* XXX: use host strnlen if available ? */
-static int qemu_strnlen(const char *s, int max_len)
-{
-    int i;
-    for(i = 0; i < max_len; i++) {
-        if (s[i] == '\0')
-            break;
-    }
-    return i;
-}
-
 /* Return the length of a string in target memory or -TARGET_EFAULT if
    access error  */
 abi_long target_strlen(abi_ulong guest_addr1)
index 5b8ac77f092313245f3ae43c33891da1ddcdc545..a5d8fffb75cbcd40641f217595927cd522fbc95c 100644 (file)
@@ -109,6 +109,7 @@ void pstrcpy(char *buf, int buf_size, const char *str);
 char *pstrcat(char *buf, int buf_size, const char *s);
 int strstart(const char *str, const char *val, const char **ptr);
 int stristart(const char *str, const char *val, const char **ptr);
+int qemu_strnlen(const char *s, int max_len);
 time_t mktimegm(struct tm *tm);
 int qemu_fls(int i);