]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
lib/mpi: mpi_write_sgl(): fix skipping of leading zero limbs
authorNicolai Stange <nicstange@gmail.com>
Tue, 22 Mar 2016 12:12:35 +0000 (13:12 +0100)
committerKamal Mostafa <kamal@canonical.com>
Thu, 15 Sep 2016 17:37:36 +0000 (10:37 -0700)
commit66c95e6942e32dc8dec116e17df1e09f4e48df10
treedb913a09c239af7bc7a229ae004e17cbe0bf74c9
parent7fc5c1c51dedf4b2ad35b1f238c73e35c99ef77f
lib/mpi: mpi_write_sgl(): fix skipping of leading zero limbs

BugLink: http://bugs.launchpad.net/bugs/1624037
commit f2d1362ff7d266b3d2b1c764d6c2ef4a3b457f23 upstream.

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: 2d4d1eea540b ("lib/mpi: Add mpi sgl helpers")
Signed-off-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
lib/mpi/mpicoder.c