aboutsummaryrefslogtreecommitdiff
path: root/src/nissy.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-12-16 17:27:35 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2024-12-16 17:27:35 +0100
commita21959e7edf523e6660023851f73426d8897783a (patch)
tree82d7bb3fa87493b2aa8c827c122bbe49745773fd /src/nissy.c
parent99b746a01c11e061c4bd42cf096d27be9507ae21 (diff)
downloadnissy-core-a21959e7edf523e6660023851f73426d8897783a.tar.gz
nissy-core-a21959e7edf523e6660023851f73426d8897783a.zip
Fixed alignment bug
Diffstat (limited to 'src/nissy.c')
-rw-r--r--src/nissy.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/nissy.c b/src/nissy.c
index c21abc0..ffda4b3 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -79,6 +79,8 @@ checkdata(const char *buf, const tableinfo_t *info)
79 } else if (!strncmp(info->solver, "h48", 3)) { 79 } else if (!strncmp(info->solver, "h48", 3)) {
80 getdistribution_h48((uint8_t *)buf + INFOSIZE, distr, 80 getdistribution_h48((uint8_t *)buf + INFOSIZE, distr,
81 info->h48h, info->bits); 81 info->h48h, info->bits);
82 } else if (!strncmp(info->solver, "eoesep data for h48", 19)) {
83 return true;
82 } else { 84 } else {
83 LOG("checkdata: unknown solver %s\n", info->solver); 85 LOG("checkdata: unknown solver %s\n", info->solver);
84 return false; 86 return false;
@@ -367,6 +369,11 @@ nissy_datainfo(
367 tableinfo_t info; 369 tableinfo_t info;
368 long long ret; 370 long long ret;
369 371
372 if ((size_t)data % 8 != 0) {
373 LOG("nissy_datainfo: buffere is not 8-byte aligned\n");
374 return NISSY_ERROR_DATA;
375 }
376
370 ret = readtableinfo(data_size, data, &info); 377 ret = readtableinfo(data_size, data, &info);
371 if (ret != 0) 378 if (ret != 0)
372 return ret; 379 return ret;
@@ -439,6 +446,11 @@ nissy_gendata_unsafe(
439 return NISSY_ERROR_NULL_POINTER; 446 return NISSY_ERROR_NULL_POINTER;
440 } 447 }
441 448
449 if ((size_t)data % 8 != 0) {
450 LOG("nissy_datainfo: buffere is not 8-byte aligned\n");
451 return NISSY_ERROR_DATA;
452 }
453
442 arg.buf_size = data_size; 454 arg.buf_size = data_size;
443 arg.buf = data; 455 arg.buf = data;
444 if (!strncmp(solver, "h48", 3)) { 456 if (!strncmp(solver, "h48", 3)) {
@@ -463,6 +475,11 @@ nissy_checkdata(
463 tableinfo_t info; 475 tableinfo_t info;
464 int64_t err; 476 int64_t err;
465 477
478 if ((size_t)data % 8 != 0) {
479 LOG("nissy_datainfo: buffere is not 8-byte aligned\n");
480 return NISSY_ERROR_DATA;
481 }
482
466 for (buf = (char *)data; 483 for (buf = (char *)data;
467 (err = readtableinfo(data_size, buf, &info)) == NISSY_OK; 484 (err = readtableinfo(data_size, buf, &info)) == NISSY_OK;
468 buf += info.next, data_size -= info.next) 485 buf += info.next, data_size -= info.next)
@@ -538,6 +555,11 @@ nissy_solve(
538 return NISSY_ERROR_OPTIONS; 555 return NISSY_ERROR_OPTIONS;
539 } 556 }
540 557
558 if ((size_t)data % 8 != 0) {
559 LOG("nissy_datainfo: buffere is not 8-byte aligned\n");
560 return NISSY_ERROR_DATA;
561 }
562
541 if (!strncmp(solver, "h48", 3)) { 563 if (!strncmp(solver, "h48", 3)) {
542 parse_ret = parse_h48_solver(solver, &h, &k); 564 parse_ret = parse_h48_solver(solver, &h, &k);
543 if (parse_ret == NISSY_OK) 565 if (parse_ret == NISSY_OK)

Generated with cgit - Back to sebastiano.tronto.net