From a21959e7edf523e6660023851f73426d8897783a Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 16 Dec 2024 17:27:35 +0100 Subject: Fixed alignment bug --- src/nissy.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/nissy.c') 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) } else if (!strncmp(info->solver, "h48", 3)) { getdistribution_h48((uint8_t *)buf + INFOSIZE, distr, info->h48h, info->bits); + } else if (!strncmp(info->solver, "eoesep data for h48", 19)) { + return true; } else { LOG("checkdata: unknown solver %s\n", info->solver); return false; @@ -367,6 +369,11 @@ nissy_datainfo( tableinfo_t info; long long ret; + if ((size_t)data % 8 != 0) { + LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); + return NISSY_ERROR_DATA; + } + ret = readtableinfo(data_size, data, &info); if (ret != 0) return ret; @@ -439,6 +446,11 @@ nissy_gendata_unsafe( return NISSY_ERROR_NULL_POINTER; } + if ((size_t)data % 8 != 0) { + LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); + return NISSY_ERROR_DATA; + } + arg.buf_size = data_size; arg.buf = data; if (!strncmp(solver, "h48", 3)) { @@ -463,6 +475,11 @@ nissy_checkdata( tableinfo_t info; int64_t err; + if ((size_t)data % 8 != 0) { + LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); + return NISSY_ERROR_DATA; + } + for (buf = (char *)data; (err = readtableinfo(data_size, buf, &info)) == NISSY_OK; buf += info.next, data_size -= info.next) @@ -538,6 +555,11 @@ nissy_solve( return NISSY_ERROR_OPTIONS; } + if ((size_t)data % 8 != 0) { + LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); + return NISSY_ERROR_DATA; + } + if (!strncmp(solver, "h48", 3)) { parse_ret = parse_h48_solver(solver, &h, &k); if (parse_ret == NISSY_OK) -- cgit v1.3