Skip to content

Commit

Permalink
lib/mpi: fix off by one in mpi_read_raw_from_sgl
Browse files Browse the repository at this point in the history
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: Stephan Mueller <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
smuellerDD authored and herbertx committed Oct 20, 2015
1 parent 4a4b0ba commit 63349d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/mpi/mpicoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,11 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int len)
const u8 *buff = sg_virt(sg);
int len = sg->length;

while (len-- && !*buff++)
while (len && !*buff) {
lzeros++;
len--;
buff++;
}

if (len && *buff)
break;
Expand Down

0 comments on commit 63349d0

Please sign in to comment.