Nicolai Stange f2d1362ff7 lib/mpi: mpi_write_sgl(): fix skipping of leading zero limbs
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>
2016-04-05 20:35:46 +08:00
..
2014-10-09 11:35:48 +03:00
2015-07-27 14:06:24 +02:00
2015-11-23 09:44:58 +01:00
2016-03-17 15:09:34 -07:00
2016-02-29 09:35:20 +01:00
2016-02-07 23:17:59 -08:00
2016-03-02 17:01:55 +02:00
2014-04-30 19:49:37 +01:00
2012-10-06 03:04:57 +09:00
2014-08-06 18:01:25 -07:00
2014-05-05 09:09:14 +02:00
2016-01-19 15:26:55 -05:00
2014-08-08 15:57:25 -07:00
2016-03-09 15:43:42 -08:00
2015-02-12 18:54:15 -08:00
2014-06-25 17:45:43 -07:00
2015-09-08 14:35:59 -07:00
2015-02-12 18:54:16 -08:00
2016-03-17 15:09:34 -07:00
2015-03-23 22:12:08 -04:00
2015-06-25 17:00:40 -07:00
2016-03-17 15:09:34 -07:00
2015-12-18 16:04:51 -05:00
2013-04-29 18:28:42 -07:00