Stefan Weil wrote:
strnlen is a GNU extension which is missing in mingw32
and perhaps other build environments.
So we should avoid it and replace it by standard functions.
Signed-off-by: Stefan Weil <address@hidden>
---
block.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/block.c b/block.c
index c66c031..79b3313 100644
--- a/block.c
+++ b/block.c
@@ -225,9 +225,14 @@ static BlockDriver *find_protocol(const char
*filename)
{
BlockDriver *drv1;
char protocol[128];
- int len = strnlen(filename, 127)+1;
+ int len;
const char *p;
+ len = strlen(filename) + 1;
+ if (len > sizeof(protocol)) {
+ len = sizeof(protocol);
+ }
+
#ifdef _WIN32
if (is_windows_drive(filename) ||
is_windows_drive_prefix(filename))
Or something like this?
#ifdef __MINGW32__
size_t strnlen (const char *string, size_t maxlen)
{
const char *end = memchr (string, '\0', maxlen);
return end ? (size_t) (end - string) : maxlen;
};
#endif