summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-02-21 12:24:30 -0800
committerVito Caputo <vcaputo@pengaru.com>2020-02-21 12:24:30 -0800
commit1e664661cf35d22641521a1c4c22db1d071323aa (patch)
treee5cb01072992f1c17985a0d613069015320d07e1 /src
parent8ff41d060344af4d045bdd79bb826231d6739c7f (diff)
settings: fixup win32 strndup
Using strlen on the input string isn't safe; it may be unterminated
Diffstat (limited to 'src')
-rw-r--r--src/settings.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/settings.c b/src/settings.c
index 02c8e8d..aa256c5 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -13,7 +13,11 @@ char * strndup(const char *s, size_t n)
size_t len;
char *buf;
- len = MIN(strlen(s), n);
+ for (len = 0; len < n; len++) {
+ if (!s[len])
+ break;
+ }
+
buf = calloc(len + 1, sizeof(char));
if (!buf)
return NULL;
© All Rights Reserved