commit bdc50082a5c948ca6ce5e9835ea638a303d9b2bd
parent d6019316d35a75a2bbdb94fbb8d615c6fd8fd08b
Author: bsandro <brian.drosan@gmail.com>
Date: Wed, 15 Dec 2021 02:43:41 +0200
strlcat/strlcpy -> strncpy (portability effort)
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/day14/puzzle.c b/day14/puzzle.c
@@ -64,7 +64,8 @@ void puzzle(const char *filename, unsigned long long *result1, unsigned long lon
assert(str == NULL);
size_t len = strlen(buf);
str = malloc(len);
- strlcat(str, buf, len); // losing last symbol \n
+ bzero(str, len);
+ strncpy(str, buf, len-1); // losing last symbol \n
}
++line_num;
bzero(buf, STR_LEN);
@@ -210,7 +211,7 @@ long long parse_rule(struct array_t *rules, const char *str) {
assert(n < 2);
if (n == 0) {
assert(strlen(token) == 2);
- strlcpy(rule.name, token, 3);
+ strncpy(rule.name, token, 3);
rule.score = rule.name[0] * 1000 + rule.name[1];
} else {
assert(strlen(token) == 1);