From 2adaf0464f96e33a69c7e598dc87e24d028bd695 Mon Sep 17 00:00:00 2001 From: rjaeckel Date: Sun, 31 Jan 2016 23:44:19 +0100 Subject: [PATCH] clear CHUNK variable to avoid infinite loops --- ocdec.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ocdec.sh b/ocdec.sh index 1d67ea7..863773f 100755 --- a/ocdec.sh +++ b/ocdec.sh @@ -130,9 +130,11 @@ function decryptFile() { # --- Decrypt the file --- # OC writes the encrypted file in 8K chunks, each containing it's own iv in the end chunkSize=8192 - while read -d '' -n $chunkSize CHUNK || [ -n "$CHUNK" ]; do + while read -d '' -n $chunkSize CHUNK || [ ! -z "$CHUNK" ]; do #split chunk into payload an iv string (strip padding from iv) read payload iv <<<`echo $CHUNK | sed -r 's/(.*)00iv00(.{16})xx/\1 \2/'` + CHUNK= + #if [ -z $CHUNK ]; then break; fi # convert base64 iv into hex iv=$(echo -n "$iv" | od -An -tx1 | tr -dc '[:xdigit:]' ) # decode chunk