From 182e2d45678d0487be71370c37b88daca3d2c54b Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 12 Oct 2024 16:23:05 +0200 Subject: Make gendata and co safer by checking buffer size --- test/100_gendata_cocsep/gendata_cocsep_tests.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'test/100_gendata_cocsep') diff --git a/test/100_gendata_cocsep/gendata_cocsep_tests.c b/test/100_gendata_cocsep/gendata_cocsep_tests.c index 296df28..91ebb52 100644 --- a/test/100_gendata_cocsep/gendata_cocsep_tests.c +++ b/test/100_gendata_cocsep/gendata_cocsep_tests.c @@ -1,10 +1,12 @@ #include "../test.h" +#define BUF_SIZE 2000000 + size_t gendata_cocsep(void *, uint64_t *, cube_t *); -bool readtableinfo(const void *, tableinfo_t *); +bool readtableinfo(uint64_t, const char *, tableinfo_t *); void run(void) { - char buf[2000000]; + char buf[BUF_SIZE]; uint32_t i; uint64_t selfsim[COCSEP_CLASSES]; cube_t rep[COCSEP_CLASSES]; @@ -12,7 +14,7 @@ void run(void) { tableinfo_t info; result = gendata_cocsep(buf, selfsim, rep); - if (!readtableinfo(buf, &info)) { + if (readtableinfo(BUF_SIZE, buf, &info) != NISSY_OK) { printf("Error reading info from table\n"); return; } -- cgit v1.3