Skip to content

Commit 86e74fa

Browse files
asterite3Felipe Zimmerle
authored andcommitted
validateByteRange: correctly handle bytes > 127
ValidateByteRange::evaluate compared bytes with values in range [0-255], but acquired bytes by indexing std::string, which gave type char, which is signed. So bytes with values more than 127 were treated as negative, resulting in being incorrectly classified as out-of-range. This commit adds casting byte values to unsigned char before validating range.
1 parent 7665d96 commit 86e74fa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/operators/validate_byte_range.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ bool ValidateByteRange::evaluate(Transaction *transaction, Rule *rule,
116116

117117
size_t count = 0;
118118
for (int i = 0; i < input.length(); i++) {
119-
int x = input.at(i);
119+
int x = (unsigned char) input.at(i);
120120
if (!(table[x >> 3] & (1 << (x & 0x7)))) {
121121
// debug(9, "Value " + std::to_string(x) + " in " +
122122
// input + " ouside range: " + param);

0 commit comments

Comments
 (0)