diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-10-12 16:23:05 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-10-12 16:23:05 +0200 |
| commit | 182e2d45678d0487be71370c37b88daca3d2c54b (patch) | |
| tree | 3987ecd9bade082a7b41901c2376daa73401e548 /test/100_gendata_cocsep | |
| parent | da8fdd4955fd24666643915a6728678e9965a0d3 (diff) | |
| download | nissy-core-182e2d45678d0487be71370c37b88daca3d2c54b.tar.gz nissy-core-182e2d45678d0487be71370c37b88daca3d2c54b.zip | |
Make gendata and co safer by checking buffer size
Diffstat (limited to 'test/100_gendata_cocsep')
| -rw-r--r-- | test/100_gendata_cocsep/gendata_cocsep_tests.c | 8 |
1 files changed, 5 insertions, 3 deletions
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 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | #define BUF_SIZE 2000000 | ||
| 4 | |||
| 3 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 5 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 4 | bool readtableinfo(const void *, tableinfo_t *); | 6 | bool readtableinfo(uint64_t, const char *, tableinfo_t *); |
| 5 | 7 | ||
| 6 | void run(void) { | 8 | void run(void) { |
| 7 | char buf[2000000]; | 9 | char buf[BUF_SIZE]; |
| 8 | uint32_t i; | 10 | uint32_t i; |
| 9 | uint64_t selfsim[COCSEP_CLASSES]; | 11 | uint64_t selfsim[COCSEP_CLASSES]; |
| 10 | cube_t rep[COCSEP_CLASSES]; | 12 | cube_t rep[COCSEP_CLASSES]; |
| @@ -12,7 +14,7 @@ void run(void) { | |||
| 12 | tableinfo_t info; | 14 | tableinfo_t info; |
| 13 | 15 | ||
| 14 | result = gendata_cocsep(buf, selfsim, rep); | 16 | result = gendata_cocsep(buf, selfsim, rep); |
| 15 | if (!readtableinfo(buf, &info)) { | 17 | if (readtableinfo(BUF_SIZE, buf, &info) != NISSY_OK) { |
| 16 | printf("Error reading info from table\n"); | 18 | printf("Error reading info from table\n"); |
| 17 | return; | 19 | return; |
| 18 | } | 20 | } |
