File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -91,18 +91,18 @@ uint32_t Interpret(const std::vector<bool> &asmap, const std::vector<bool> &ip)
91
91
} else if (opcode == Instruction::JUMP) {
92
92
jump = DecodeJump (pos, endpos);
93
93
if (jump == INVALID) break ; // Jump offset straddles EOF
94
- if (bits == 0 ) break ;
94
+ if (bits == 0 ) break ; // No input bits left
95
+ if (jump >= endpos - pos) break ; // Jumping past EOF
95
96
if (ip[ip.size () - bits]) {
96
- if (jump >= endpos - pos) break ;
97
97
pos += jump;
98
98
}
99
99
bits--;
100
100
} else if (opcode == Instruction::MATCH) {
101
101
match = DecodeMatch (pos, endpos);
102
102
if (match == INVALID) break ; // Match bits straddle EOF
103
103
matchlen = CountBits (match) - 1 ;
104
+ if (bits < matchlen) break ; // Not enough input bits
104
105
for (uint32_t bit = 0 ; bit < matchlen; bit++) {
105
- if (bits == 0 ) break ;
106
106
if ((ip[ip.size () - bits]) != ((match >> (matchlen - 1 - bit)) & 1 )) {
107
107
return default_asn;
108
108
}
@@ -115,5 +115,6 @@ uint32_t Interpret(const std::vector<bool> &asmap, const std::vector<bool> &ip)
115
115
break ; // Instruction straddles EOF
116
116
}
117
117
}
118
+ // Reached EOF without RETURN, or aborted (see any of the breaks above).
118
119
return 0 ; // 0 is not a valid ASN
119
120
}
You can’t perform that action at this time.
0 commit comments