diff options
author | Andrii Kalinich (GitHub) <AKalinich@luxoft.com> | 2021-08-25 09:47:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 09:47:45 -0400 |
commit | e75bd4f3131b63e7e7f805bc36eb70c758c37640 (patch) | |
tree | 3c2c54b09110d69858cd8a784105109c71019888 /tools/InterfaceGenerator | |
parent | 90879643717a1f8fef5061345e5e9b279329619f (diff) | |
download | sdl_core-e75bd4f3131b63e7e7f805bc36eb70c758c37640.tar.gz |
Fix SDL crash on validation of numeric schemas with type overflow (#3750)
* Added handling of cases with type overflow
* Update generator logic and schema validation
* Add validation info
Co-authored-by: Jacob Keeler <jacob.keeler@livioradio.com>
Diffstat (limited to 'tools/InterfaceGenerator')
-rwxr-xr-x | tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py index 69e8d71428..dffaa6c1b5 100755 --- a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py +++ b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py @@ -840,22 +840,37 @@ class CodeGenerator(object): [[u"bool", None if param.default_value is None else u"true" if param.default_value is True else u"false"]])) elif type(param) is Integer: - if not param.max_value or param.max_value and param.max_value < 2 ** 31: + if param.min_value is not None and param.min_value >= 0: + if param.max_value is None or param.max_value >= 2 ** 32: + code = self._impl_code_integer_item_template.substitute( + type=u"uint64_t", + params=self._gen_schema_item_param_values( + [[u"uint64_t", param.min_value], + [u"uint64_t", param.max_value], + [u"uint64_t", param.default_value]])) + else: + code = self._impl_code_integer_item_template.substitute( + type=u"uint32_t", + params=self._gen_schema_item_param_values( + [[u"uint32_t", param.min_value], + [u"uint32_t", param.max_value], + [u"uint32_t", param.default_value]])) + elif (param.min_value is not None and param.min_value >= -(2 ** 31)) and (param.max_value is not None and param.max_value < 2 ** 31): code = self._impl_code_integer_item_template.substitute( type=u"int32_t", params=self._gen_schema_item_param_values( [[u"int32_t", param.min_value], [u"int32_t", param.max_value], [u"int32_t", param.default_value]])) - elif param.max_value < 2 ** 63: + elif (param.min_value is None or param.min_value >= -(2 ** 63)) and (param.max_value is None or param.max_value < 2 ** 63): code = self._impl_code_integer_item_template.substitute( type=u"int64_t", params=self._gen_schema_item_param_values( [[u"int64_t", param.min_value], - [u"int64_t", str(param.max_value) + u"LL"], + [u"int64_t", param.max_value], [u"int64_t", param.default_value]])) else: - raise GenerateError("Parameter value too large: " + str(param.max_value)) + raise GenerateError("Parameter value too large/small: " + str(param.min_value) + "/" + str(param.max_value)) elif type(param) is Float: code = self._impl_code_integer_item_template.substitute( type=u"double", |