Skip to content

Commit b17f1d3

Browse files
committed
Fix search resume after lookup failure
1 parent d8b2e7d commit b17f1d3

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

src/rucksack.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ class Rucksack
2020
def self.offset
2121
return @@offset unless @@offset == 0
2222

23-
buf = Bytes.new((KNAUTSCHZONE.size).to_i)
2423
file = ::File.new(Process.executable_path.not_nil!)
2524

2625
loop do
26+
buf = Bytes.new((KNAUTSCHZONE.size).to_i)
2727
begin
2828
loop do
2929
bytes_read = file.read(buf)

test/test.sh

+52-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ err() {
1515
cat $to
1616
echo "-- stderr --"
1717
cat $te
18-
echo "-- stderr --"
18+
echo "--"
1919
echo "ERROR: ${0}:${1} ${ERR}"
2020
exit 1
2121
}
@@ -60,5 +60,56 @@ RUCKSACK_MODE=1 $tb >$to 2>$te
6060
RUCKSACK_MODE=2 $tb >$to 2>$te
6161
.
6262

63+
### crystal build with phony padding
64+
65+
#### case A: extra nulls before Knautschzone
66+
crystal build test/test.cr -o ${tb}
67+
head -c 17042 /dev/zero >>${tb}
68+
cat .rucksack >>$tb
69+
RUCKSACK_MODE=0 $tb >$to 2>$te
70+
.
71+
RUCKSACK_MODE=1 $tb >$to 2>$te
72+
.
73+
RUCKSACK_MODE=2 $tb >$to 2>$te
74+
.
75+
76+
#### case B: duplicate padding
77+
78+
crystal build test/test.cr -o ${tb}
79+
head -c 16397 /dev/zero >>${tb}
80+
cat .rucksack >>$tb
81+
RUCKSACK_MODE=0 $tb >$to 2>$te
82+
.
83+
RUCKSACK_MODE=1 $tb >$to 2>$te
84+
.
85+
RUCKSACK_MODE=2 $tb >$to 2>$te
86+
.
87+
88+
#### case C: extra nulls and truncated header
89+
90+
crystal build test/test.cr -o ${tb}
91+
head -c 16397 /dev/zero >>${tb}
92+
echo = >>${tb}
93+
cat .rucksack >>$tb
94+
RUCKSACK_MODE=0 $tb >$to 2>$te
95+
.
96+
RUCKSACK_MODE=1 $tb >$to 2>$te
97+
.
98+
RUCKSACK_MODE=2 $tb >$to 2>$te
99+
.
100+
101+
#### case D: extra nulls and longer truncated header
102+
103+
crystal build test/test.cr -o ${tb}
104+
head -c 16397 /dev/zero >>${tb}
105+
echo ==RUCK >>${tb}
106+
cat .rucksack >>$tb
107+
RUCKSACK_MODE=0 $tb >$to 2>$te
108+
.
109+
RUCKSACK_MODE=1 $tb >$to 2>$te
110+
.
111+
RUCKSACK_MODE=2 $tb >$to 2>$te
112+
.
113+
63114
echo
64115

0 commit comments

Comments
 (0)