Thread (30 messages) 30 messages, 5 authors, 2015-12-14
STALE3877d
Revisions (3)
  1. v2 current
  2. v3 [diff vs current]
  3. v8 [diff vs current]

[PATCH v2 1/5] MPI: fix off by one in mpi_read_raw_from_sgl

From: Stephan Mueller <hidden>
Date: 2015-10-18 22:05:46
Also in: linux-crypto, lkml
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

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 <redacted>
---
 lib/mpi/mpicoder.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
index c20ef27..c7e0a70 100644
--- a/lib/mpi/mpicoder.c
+++ b/lib/mpi/mpicoder.c
@@ -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;
-- 
2.5.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help