aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48/solve.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-12 16:23:05 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-12 16:23:05 +0200
commit182e2d45678d0487be71370c37b88daca3d2c54b (patch)
tree3987ecd9bade082a7b41901c2376daa73401e548 /src/solvers/h48/solve.h
parentda8fdd4955fd24666643915a6728678e9965a0d3 (diff)
downloadnissy-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.h9
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);
21STATIC void solve_h48_appendsolution(dfsarg_solveh48_t *); 21STATIC void solve_h48_appendsolution(dfsarg_solveh48_t *);
22STATIC_INLINE bool solve_h48_stop(dfsarg_solveh48_t *); 22STATIC_INLINE bool solve_h48_stop(dfsarg_solveh48_t *);
23STATIC int64_t solve_h48_dfs(dfsarg_solveh48_t *); 23STATIC int64_t solve_h48_dfs(dfsarg_solveh48_t *);
24STATIC int64_t solve_h48(cube_t, int8_t, int8_t, int8_t, const void *, char *); 24STATIC int64_t solve_h48(cube_t, int8_t, int8_t,
25 int8_t, uint64_t, const void *, uint64_t, char *);
25 26
26STATIC uint32_t 27STATIC uint32_t
27allowednextmove_h48(uint8_t *moves, uint8_t n, uint32_t h48branch) 28allowednextmove_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) {

Generated with cgit - Back to sebastiano.tronto.net