From 71874c45d9067b12f7f427f046f5992f71a7aa44 Mon Sep 17 00:00:00 2001 From: ktaranov Date: Mon, 22 Jan 2018 00:08:42 +0100 Subject: [PATCH] [FIX] destination buffer of galois_wxx_region_multiply The manual says that if the dest buffer is NULL, then the result of multiplication will go to the source region buffer. However, multiply_region.w32 function, which is called by galois_wxx_region_multiply, assumes that the destination buffer is not NULL. The proposed fix assigns destination buffer to source buffer if destination buffer is NULL. --- src/galois.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/galois.c b/src/galois.c index cd9faa8..8f7697c 100644 --- a/src/galois.c +++ b/src/galois.c @@ -304,6 +304,10 @@ void galois_w08_region_multiply(char *region, /* Region to multiply */ if (gfp_array[8] == NULL) { galois_init(8); } + if (r2 == NULL) { + r2 = region; + add = 0; + } gfp_array[8]->multiply_region.w32(gfp_array[8], region, r2, multby, nbytes, add); } @@ -316,6 +320,10 @@ void galois_w16_region_multiply(char *region, /* Region to multiply */ if (gfp_array[16] == NULL) { galois_init(16); } + if (r2 == NULL) { + r2 = region; + add = 0; + } gfp_array[16]->multiply_region.w32(gfp_array[16], region, r2, multby, nbytes, add); } @@ -329,6 +337,10 @@ void galois_w32_region_multiply(char *region, /* Region to multiply */ if (gfp_array[32] == NULL) { galois_init(32); } + if (r2 == NULL) { + r2 = region; + add = 0; + } gfp_array[32]->multiply_region.w32(gfp_array[32], region, r2, multby, nbytes, add); }