summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2017-07-06 20:01:12 +0200
committerLucas Stach <l.stach@pengutronix.de>2017-07-14 16:50:44 +0200
commit59b57082ae61dca65e73dd433daabcdd0f40c094 (patch)
tree277b6c6a03282272430970f378ed2f85911256b0
parent3e5fecc0c5c470995c5f77a1dc6ef88102e85f16 (diff)
downloadbarebox-59b57082ae61dca65e73dd433daabcdd0f40c094.tar.gz
crypto: digest: Fix digesting over memory chunks > 4096 bytes
There are two different cases that are handled in digest_file_window: a) the file to digest is memmappable (e.g. /dev/mem) b) it isn't (e.g. files in /) In both cases a file is digested in hunks of (up to) 4096 bytes. After each hunk in b) the buffer that is fed to digest_update() is then overwritten using read() to get the next hunk to digest. In case a) however it was forgotten to step forward in the buffer and instead the same data was handed to digest_update() again and again. So to fix that increase buffer by the number of bytes already digested for case a) which is characterized by flags == 0. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-rw-r--r--crypto/digest.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/digest.c b/crypto/digest.c
index 7a8c3c0..bc6de0b 100644
--- a/crypto/digest.c
+++ b/crypto/digest.c
@@ -272,6 +272,9 @@ int digest_file_window(struct digest *d, const char *filename,
goto out_free;
size -= now;
len += now;
+
+ if (!flags)
+ buf += now;
}
if (sig)