-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check for impossible conditions when using uint() operators. #1918
Comments
I'm not sure I like this. So just because I want to check that a 32bit value is zero I have to specify it as 0x00000000? Seems excessive and not how other languages work. |
I think @wxsBSD is right. Why
|
I can see the warning you describe here as being useful. I'll add that soon. |
Related: VirusTotal/yara-x#23 |
I hadn't realised that uint32(x) = 0x00 checked all four bytes were null (it makes sense now that you say it , I just hadn't realised it). |
When reading an integer of a specific size and comparing it to an integer of a larger size where any of the upper bits are set we will now emit a warning because the comparison is always false. These will always evaluate to false because the "extra" bytes are non-zero: uint8(0) == 0x1100 uint16(0) == 0x110000 uint32(0) == 0x1100000000 While I'm here, move a test into a better place for it. I added it in the wrong place in ccbc405. Fixes VirusTotal#1918.
Is your feature request related to a problem? Please describe.
Sometimes when writing rules I'll use the wrong value of x for uintx type rules meaning the condition will never match. For example
Describe the solution you'd like
Troubleshooting a condition like this is relatively easy once you figure out what is going on but it can be easy to gloss over. It would be useful if when compiling rules the compiler checked that the right handside contained a number of bytes that could plausibly match the left hand side,
Describe alternatives you've considered
I could just write better rules I guess :(
The text was updated successfully, but these errors were encountered: