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_multithread.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_multithread.h')
| -rw-r--r-- | src/solvers/h48/solve_multithread.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/solvers/h48/solve_multithread.h b/src/solvers/h48/solve_multithread.h index 766d84a..3ba914a 100644 --- a/src/solvers/h48/solve_multithread.h +++ b/src/solvers/h48/solve_multithread.h | |||
| @@ -20,7 +20,8 @@ STATIC void copy_queue(task_queue_t *, task_queue_t *, int, _Atomic int64_t *); | |||
| 20 | STATIC void *start_thread(void *); | 20 | STATIC void *start_thread(void *); |
| 21 | STATIC int64_t solve_h48_bfs(dfsarg_solveh48_t *, task_queue_t *, int8_t); | 21 | STATIC int64_t solve_h48_bfs(dfsarg_solveh48_t *, task_queue_t *, int8_t); |
| 22 | STATIC int64_t solve_h48_single(dfsarg_solveh48_t *, task_queue_t *); | 22 | STATIC int64_t solve_h48_single(dfsarg_solveh48_t *, task_queue_t *); |
| 23 | STATIC int64_t solve_h48_multithread(cube_t, int8_t, int8_t, int8_t, const void *, char *); | 23 | STATIC int64_t solve_h48_multithread(cube_t, int8_t, int8_t, int8_t, |
| 24 | uint64_t, const void *, uint64_t, char *); | ||
| 24 | 25 | ||
| 25 | STATIC void | 26 | STATIC void |
| 26 | solve_h48_appendsolution_thread(dfsarg_solveh48_t *arg, task_queue_t *tq) | 27 | solve_h48_appendsolution_thread(dfsarg_solveh48_t *arg, task_queue_t *tq) |
| @@ -236,8 +237,11 @@ solve_h48_multithread( | |||
| 236 | int8_t minmoves, | 237 | int8_t minmoves, |
| 237 | int8_t maxmoves, | 238 | int8_t maxmoves, |
| 238 | int8_t maxsolutions, | 239 | int8_t maxsolutions, |
| 240 | uint64_t data_size, | ||
| 239 | const void *data, | 241 | const void *data, |
| 240 | char *solutions) | 242 | uint64_t solutions_size, |
| 243 | char *solutions | ||
| 244 | ) | ||
| 241 | { | 245 | { |
| 242 | _Atomic int64_t nsols = 0; | 246 | _Atomic int64_t nsols = 0; |
| 243 | int p_depth = 0; | 247 | int p_depth = 0; |
| @@ -245,9 +249,9 @@ solve_h48_multithread( | |||
| 245 | tableinfo_t info; | 249 | tableinfo_t info; |
| 246 | pthread_t threads[THREADS]; | 250 | pthread_t threads[THREADS]; |
| 247 | 251 | ||
| 248 | if (!readtableinfo_n(data, 2, &info)){ | 252 | if (readtableinfo_n(data_size, data, 2, &info) != NISSY_OK) { |
| 249 | LOG("solve_h48: error reading table\n"); | 253 | LOG("solve_h48: error reading table\n"); |
| 250 | return 0; | 254 | return NISSY_ERROR_DATA; |
| 251 | } | 255 | } |
| 252 | 256 | ||
| 253 | arg = (dfsarg_solveh48_t){ | 257 | arg = (dfsarg_solveh48_t){ |
