Skip to content

Commit

Permalink
Ensure test buffers are always '\0' terminated
Browse files Browse the repository at this point in the history
This caused spurious test failures.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
  • Loading branch information
sjaeckel committed Oct 12, 2024
1 parent ebfcff3 commit 5a1545a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ static DIR *s_opendir(const char *path, char *mypath, unsigned long l)
static int s_read_and_process(FILE *f, unsigned long sz, void *ctx, dir_iter_cb process)
{
int err = CRYPT_OK;
void* buf = XMALLOC(sz);
void* buf = XMALLOC(sz + 1);
if (buf == NULL)
return CRYPT_MEM;
if (fread(buf, 1, sz, f) != sz) {
err = CRYPT_ERROR;
goto out;
}
((unsigned char *)buf)[sz] = 0x0;
err = process(buf, sz, ctx);
out:
XFREE(buf);
Expand Down

0 comments on commit 5a1545a

Please sign in to comment.