TypeError when using String-Field with value parameter
lukaspanni opened this issue · 1 comments
lukaspanni commented
Checklist
- I have included the [relevant portions of the] grammar used that caused the bug
- I have filled out the environment section
Environment
Platform
- Windows
- Mac
- Linux
- Other (please specify)
Python Version
- Python 2.7
- Python 3.4
- Python 3.5
- Python 3.6
- Python 3.7
- Python 3.8
- Other (please specify)
Describe the bug
When using a String-Field with predefined value and min/max this error randomly occurs:
TypeError: 'bytes' object cannot be interpreted as an integer
gramfuzz tries to use the value of the String-Field as length which fails because the value is a string.
To Reproduce
Grammar:
class TRef(Ref):
cat = "test_string_error"
class TDef(Def):
cat = "test_string_error"
Def("error_test", TRef("field"), cat="transport_header")
TDef("field", String("TEST", min=0, max=8))
Execute
fuzzer = gramfuzz.GramFuzzer()
gramfuzz.rand.seed(2)
fuzzer.load_grammar("grammar.py")
# will trigger the error, if 2 instead of 3 is used no error occurs
data = fuzzer.gen(3, cat="test_string_error")
Expected Behavior
gramfuzz generates multiple strings with different lengths as stated in the grammar.
d0c-s4vage commented
I should be able to get to these this weekend. Thank you for reporting the issue!