Skip to content

Commit 5a1545a

Browse files
committed
Ensure test buffers are always '\0' terminated
This caused spurious test failures. Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
1 parent ebfcff3 commit 5a1545a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,14 @@ static DIR *s_opendir(const char *path, char *mypath, unsigned long l)
103103
static int s_read_and_process(FILE *f, unsigned long sz, void *ctx, dir_iter_cb process)
104104
{
105105
int err = CRYPT_OK;
106-
void* buf = XMALLOC(sz);
106+
void* buf = XMALLOC(sz + 1);
107107
if (buf == NULL)
108108
return CRYPT_MEM;
109109
if (fread(buf, 1, sz, f) != sz) {
110110
err = CRYPT_ERROR;
111111
goto out;
112112
}
113+
((unsigned char *)buf)[sz] = 0x0;
113114
err = process(buf, sz, ctx);
114115
out:
115116
XFREE(buf);

0 commit comments

Comments
 (0)