tests: remove strncpy() use

`checkpatch` has sufficiently annoyed me to fix this.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2024-10-17 14:26:29 +02:00
parent fd6f46e9fd
commit 84fd92c80e
2 changed files with 6 additions and 5 deletions

View file

@ -49,16 +49,17 @@ const char *prng_fuzz(struct prng *prng, const char *string,
const char *charset, unsigned int operations)
{
static char buf[256];
unsigned int charset_len;
size_t charset_len = strlen(charset);
size_t str_len = strlen(string);
unsigned int i;
unsigned int offset;
unsigned int op;
unsigned int character;
assert(strlen(string) < sizeof(buf));
assert(str_len < sizeof(buf));
strncpy(buf, string, sizeof(buf));
charset_len = strlen(charset);
memset(buf, 0, sizeof(buf));
memcpy(buf, string, str_len);
for (i = 0; i < operations; i++) {
offset = prng_rand(prng) % strlen(buf);

View file

@ -43,7 +43,7 @@ static char *sortlines(char *in)
}
if (line_count == 1) {
strncpy(rv, in, rv_len);
memcpy(rv, in, rv_len);
return rv;
}