• Nicolai Stange's avatar
    lib/mpi: mpi_write_sgl(): fix skipping of leading zero limbs · f2d1362f
    Nicolai Stange authored
    Currently, if the number of leading zeros is greater than fits into a
    complete limb, mpi_write_sgl() skips them by iterating over them limb-wise.
    
    However, it fails to adjust its internal leading zeros tracking variable,
    lzeros, accordingly: it does a
    
      p -= sizeof(alimb);
      continue;
    
    which should really have been a
    
      lzeros -= sizeof(alimb);
      continue;
    
    Since lzeros never decreases if its initial value >= sizeof(alimb), nothing
    gets copied by mpi_write_sgl() in that case.
    
    Instead of skipping the high order zero limbs within the loop as shown
    above, fix the issue by adjusting the copying loop's bounds.
    
    Fixes: 2d4d1eea ("lib/mpi: Add mpi sgl helpers")
    Signed-off-by: default avatarNicolai Stange <nicstange@gmail.com>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    f2d1362f
Name
Last commit
Last update
..
Makefile Loading commit data...
generic_mpih-add1.c Loading commit data...
generic_mpih-lshift.c Loading commit data...
generic_mpih-mul1.c Loading commit data...
generic_mpih-mul2.c Loading commit data...
generic_mpih-mul3.c Loading commit data...
generic_mpih-rshift.c Loading commit data...
generic_mpih-sub1.c Loading commit data...
longlong.h Loading commit data...
mpi-bit.c Loading commit data...
mpi-cmp.c Loading commit data...
mpi-inline.h Loading commit data...
mpi-internal.h Loading commit data...
mpi-pow.c Loading commit data...
mpicoder.c Loading commit data...
mpih-cmp.c Loading commit data...
mpih-div.c Loading commit data...
mpih-mul.c Loading commit data...
mpiutil.c Loading commit data...