From 71eed75a9f49bdb9079599efab1fe1c50b11b68c Mon Sep 17 00:00:00 2001 From: merces Date: Wed, 27 Nov 2024 22:33:04 -0300 Subject: [PATCH] Fix: a string couldn't be at offset 0 --- src/reversing/bh_zerostring.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/reversing/bh_zerostring.sh b/src/reversing/bh_zerostring.sh index 9bfe68b..3b8d945 100644 --- a/src/reversing/bh_zerostring.sh +++ b/src/reversing/bh_zerostring.sh @@ -4,13 +4,12 @@ bh_zerostring() { local fil="$1" local search="$2" - # 'tr' is needed here because strings command outputs lines - # starting with two space characters in some systems - local pos=$(strings -t d "$fil" | grep -F "$search" | tr -s ' ' ' ' | cut -d' ' -f2) + # 'tr' is needed here because the strings command + # might output lines starting with two spaces + local pos=$(strings -t d "$fil" | grep -F "$search" | tr -s ' ' ' ' | cut -d' ' -f1) - siz=${#search} + local siz=${#search} for i in $pos; do - [[ $i -gt 0 ]] || continue dd conv=notrunc bs=1 count=$siz seek=$i if=/dev/zero of="$fil" done }