Commit 63349d02 authored by Stephan Mueller's avatar Stephan Mueller Committed by Herbert Xu

lib/mpi: fix off by one in mpi_read_raw_from_sgl

The patch fixes the analysis of the input data which contains an off
by one.

The issue is visible when the SGL contains one byte per SG entry.
The code for checking for zero bytes does not operate on the data byte.
Signed-off-by: default avatarStephan Mueller <smueller@chronox.de>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 4a4b0bad
...@@ -446,8 +446,11 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int len) ...@@ -446,8 +446,11 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int len)
const u8 *buff = sg_virt(sg); const u8 *buff = sg_virt(sg);
int len = sg->length; int len = sg->length;
while (len-- && !*buff++) while (len && !*buff) {
lzeros++; lzeros++;
len--;
buff++;
}
if (len && *buff) if (len && *buff)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment