Skip to content
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

Parsing binary includes is broken #24

Open
fraove opened this issue Jan 22, 2024 · 1 comment
Open

Parsing binary includes is broken #24

fraove opened this issue Jan 22, 2024 · 1 comment

Comments

@fraove
Copy link

fraove commented Jan 22, 2024

Parsing a dts containing a binary include (/incbin/) gives me the following exception using python 3.7 and pyFDT 0.3.3:

Traceback (most recent call last):
  File "./test.py", line 9, in <module>
    tree = fdt.parse_dts(dts)
  File "<...>/python3.7/site-packages/fdt/__init__.py", line 505, in parse_dts
    prop_obj = PropIncBin(prop_name, prop_data, os.path.split(file_path)[1])
  File "<...>/python3.7/site-packages/fdt/items.py", line 469, in __init__
    super().__init__(name, data)
  File "<...>/site-packages/fdt/items.py", line 378, in __init__
    self.data = bytearray(args)
TypeError: 'bytes' object cannot be interpreted as an integer

Code to reproduce:

import fdt

dts = """/dts-v1/;

/ {
  data = /incbin/("data.bin");
};
"""

tree = fdt.parse_dts(dts)
@fraove
Copy link
Author

fraove commented Jan 22, 2024

I believe this is broken in this commit: bcf94d9

Since this change the PropBytes's initializer takes *args in addition to data:

-    def __init__(self, name, data=None):
+    def __init__(self, name, *args, data=None):

Test code is adjusted accordingly:

-    prop1 = fdt.PropBytes('prop', [0x10, 0x50, 0x00])
+    prop1 = fdt.PropBytes('prop', data=b"\x10\x50\x00")

But there is no corresponding change in the initializer of PropIncBin:

super().__init__(name, data)

(And apparently no test coverage for PropIncBin ;))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant