drill icon indicating copy to clipboard operation
drill copied to clipboard

Code contains multiple always true `byte <` checks

Open Marcono1234 opened this issue 2 years ago • 0 comments

Describe the bug The code contains multiple x < ... checks where x is a byte and the right-hand side is > 127 (= max byte value), so these conditions are always true:

  • https://github.com/apache/drill/blob/5f8cdda2ac001d4267c3c903f3e92b9bf24e8713/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CharSubstring.java#L92
  • https://github.com/apache/drill/blob/5f8cdda2ac001d4267c3c903f3e92b9bf24e8713/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CharSubstring.java#L116
  • https://github.com/apache/drill/blob/5f8cdda2ac001d4267c3c903f3e92b9bf24e8713/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CharSubstring.java#L127
  • https://github.com/apache/drill/blob/5f8cdda2ac001d4267c3c903f3e92b9bf24e8713/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctions.java#L1111
  • https://github.com/apache/drill/blob/5f8cdda2ac001d4267c3c903f3e92b9bf24e8713/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctions.java#L1260

Not completely sure what the fix here is, maybe (byte & 0xFF) < .... And also for StringFunctions maybe it should be 128 (decimal) instead of 0x128 (hex, = 296 decimal); at least the 0x128 looks a bit suspicious.

Marcono1234 avatar May 07 '23 01:05 Marcono1234