Commit 8a59947bce2884b4f89eac57552d172f59ece4c0

Authored by ktaranov
1 parent de1739cc

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.
Showing 1 changed file with 18 additions and 3 deletions   Show diff stats
src/galois.c
... ... @@ -304,7 +304,12 @@ void galois_w08_region_multiply(char *region, /* Region to multiply */
304 304 if (gfp_array[8] == NULL) {
305 305 galois_init(8);
306 306 }
307   - gfp_array[8]->multiply_region.w32(gfp_array[8], region, r2, multby, nbytes, add);
  307 +
  308 + if (r2 == NULL) {
  309 + gfp_array[8]->multiply_region.w32(gfp_array[8], region, region, multby, nbytes, 0);
  310 + } else {
  311 + gfp_array[8]->multiply_region.w32(gfp_array[8], region, r2, multby, nbytes, add);
  312 + }
308 313 }
309 314  
310 315 void galois_w16_region_multiply(char *region, /* Region to multiply */
... ... @@ -316,7 +321,12 @@ void galois_w16_region_multiply(char *region, /* Region to multiply */
316 321 if (gfp_array[16] == NULL) {
317 322 galois_init(16);
318 323 }
319   - gfp_array[16]->multiply_region.w32(gfp_array[16], region, r2, multby, nbytes, add);
  324 +
  325 + if (r2 == NULL) {
  326 + gfp_array[16]->multiply_region.w32(gfp_array[16], region, region, multby, nbytes, 0);
  327 + } else {
  328 + gfp_array[16]->multiply_region.w32(gfp_array[16], region, r2, multby, nbytes, add);
  329 + }
320 330 }
321 331  
322 332  
... ... @@ -329,7 +339,12 @@ void galois_w32_region_multiply(char *region, /* Region to multiply */
329 339 if (gfp_array[32] == NULL) {
330 340 galois_init(32);
331 341 }
332   - gfp_array[32]->multiply_region.w32(gfp_array[32], region, r2, multby, nbytes, add);
  342 +
  343 + if (r2 == NULL) {
  344 + gfp_array[32]->multiply_region.w32(gfp_array[32], region, region, multby, nbytes, 0);
  345 + } else {
  346 + gfp_array[32]->multiply_region.w32(gfp_array[32], region, r2, multby, nbytes, add);
  347 + }
333 348 }
334 349  
335 350 void galois_w8_region_xor(void *src, void *dest, int nbytes)
... ...