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 /src/solvers/h48/solve.h | |
| 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 'src/solvers/h48/solve.h')
| -rw-r--r-- | src/solvers/h48/solve.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 3948b15..f2babdf 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -21,7 +21,8 @@ STATIC uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint32_t); | |||
| 21 | STATIC void solve_h48_appendsolution(dfsarg_solveh48_t *); | 21 | STATIC void solve_h48_appendsolution(dfsarg_solveh48_t *); |
| 22 | STATIC_INLINE bool solve_h48_stop(dfsarg_solveh48_t *); | 22 | STATIC_INLINE bool solve_h48_stop(dfsarg_solveh48_t *); |
| 23 | STATIC int64_t solve_h48_dfs(dfsarg_solveh48_t *); | 23 | STATIC int64_t solve_h48_dfs(dfsarg_solveh48_t *); |
| 24 | STATIC int64_t solve_h48(cube_t, int8_t, int8_t, int8_t, const void *, char *); | 24 | STATIC int64_t solve_h48(cube_t, int8_t, int8_t, |
| 25 | int8_t, uint64_t, const void *, uint64_t, char *); | ||
| 25 | 26 | ||
| 26 | STATIC uint32_t | 27 | STATIC uint32_t |
| 27 | allowednextmove_h48(uint8_t *moves, uint8_t n, uint32_t h48branch) | 28 | allowednextmove_h48(uint8_t *moves, uint8_t n, uint32_t h48branch) |
| @@ -163,7 +164,9 @@ solve_h48( | |||
| 163 | int8_t minmoves, | 164 | int8_t minmoves, |
| 164 | int8_t maxmoves, | 165 | int8_t maxmoves, |
| 165 | int8_t maxsolutions, | 166 | int8_t maxsolutions, |
| 167 | uint64_t data_size, | ||
| 166 | const void *data, | 168 | const void *data, |
| 169 | uint64_t solutions_size, | ||
| 167 | char *solutions | 170 | char *solutions |
| 168 | ) | 171 | ) |
| 169 | { | 172 | { |
| @@ -171,9 +174,9 @@ solve_h48( | |||
| 171 | dfsarg_solveh48_t arg; | 174 | dfsarg_solveh48_t arg; |
| 172 | tableinfo_t info; | 175 | tableinfo_t info; |
| 173 | 176 | ||
| 174 | if(!readtableinfo_n(data, 2, &info)) { | 177 | if(readtableinfo_n(data_size, data, 2, &info) != NISSY_OK) { |
| 175 | LOG("solve_h48: error reading table\n"); | 178 | LOG("solve_h48: error reading table\n"); |
| 176 | return 0; | 179 | return NISSY_ERROR_DATA; |
| 177 | } | 180 | } |
| 178 | 181 | ||
| 179 | arg = (dfsarg_solveh48_t) { | 182 | arg = (dfsarg_solveh48_t) { |
