Skip to content

Commit

Permalink
Fix: a string couldn't be at offset 0
Browse files Browse the repository at this point in the history
  • Loading branch information
merces committed Nov 28, 2024
1 parent c1a551b commit 71eed75
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/reversing/bh_zerostring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 71eed75

Please sign in to comment.