Commit d43277c534904dc31d14bfb0dc934f3cfbe2dab5
1 parent
57a943c4
Fix missing strnlen problems
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>
Showing
5 changed files
with
15 additions
and
23 deletions
block.c
... | ... | @@ -225,7 +225,7 @@ static BlockDriver *find_protocol(const char *filename) |
225 | 225 | { |
226 | 226 | BlockDriver *drv1; |
227 | 227 | char protocol[128]; |
228 | - int len = strnlen(filename, 127)+1; | |
228 | + int len = qemu_strnlen(filename, 127) + 1; | |
229 | 229 | const char *p; |
230 | 230 | |
231 | 231 | #ifdef _WIN32 | ... | ... |
bsd-user/uaccess.c
... | ... | @@ -37,17 +37,6 @@ abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len) |
37 | 37 | return ret; |
38 | 38 | } |
39 | 39 | |
40 | -/* XXX: use host strnlen if available ? */ | |
41 | -static int qemu_strnlen(const char *s, int max_len) | |
42 | -{ | |
43 | - int i; | |
44 | - for(i = 0; i < max_len; i++) { | |
45 | - if (s[i] == '\0') | |
46 | - break; | |
47 | - } | |
48 | - return i; | |
49 | -} | |
50 | - | |
51 | 40 | /* Return the length of a string in target memory or -TARGET_EFAULT if |
52 | 41 | access error */ |
53 | 42 | abi_long target_strlen(abi_ulong guest_addr1) | ... | ... |
cutils.c
... | ... | @@ -109,6 +109,19 @@ int stristart(const char *str, const char *val, const char **ptr) |
109 | 109 | return 1; |
110 | 110 | } |
111 | 111 | |
112 | +/* XXX: use host strnlen if available ? */ | |
113 | +int qemu_strnlen(const char *s, int max_len) | |
114 | +{ | |
115 | + int i; | |
116 | + | |
117 | + for(i = 0; i < max_len; i++) { | |
118 | + if (s[i] == '\0') { | |
119 | + break; | |
120 | + } | |
121 | + } | |
122 | + return i; | |
123 | +} | |
124 | + | |
112 | 125 | time_t mktimegm(struct tm *tm) |
113 | 126 | { |
114 | 127 | time_t t; | ... | ... |
linux-user/uaccess.c
... | ... | @@ -37,17 +37,6 @@ abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len) |
37 | 37 | return ret; |
38 | 38 | } |
39 | 39 | |
40 | -/* XXX: use host strnlen if available ? */ | |
41 | -static int qemu_strnlen(const char *s, int max_len) | |
42 | -{ | |
43 | - int i; | |
44 | - for(i = 0; i < max_len; i++) { | |
45 | - if (s[i] == '\0') | |
46 | - break; | |
47 | - } | |
48 | - return i; | |
49 | -} | |
50 | - | |
51 | 40 | /* Return the length of a string in target memory or -TARGET_EFAULT if |
52 | 41 | access error */ |
53 | 42 | abi_long target_strlen(abi_ulong guest_addr1) | ... | ... |
qemu-common.h
... | ... | @@ -109,6 +109,7 @@ void pstrcpy(char *buf, int buf_size, const char *str); |
109 | 109 | char *pstrcat(char *buf, int buf_size, const char *s); |
110 | 110 | int strstart(const char *str, const char *val, const char **ptr); |
111 | 111 | int stristart(const char *str, const char *val, const char **ptr); |
112 | +int qemu_strnlen(const char *s, int max_len); | |
112 | 113 | time_t mktimegm(struct tm *tm); |
113 | 114 | int qemu_fls(int i); |
114 | 115 | ... | ... |