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

RuntimeError: version info string is not terminated by zero #10

Open
Napo2k opened this issue Aug 1, 2022 · 6 comments
Open

RuntimeError: version info string is not terminated by zero #10

Napo2k opened this issue Aug 1, 2022 · 6 comments

Comments

@Napo2k
Copy link

Napo2k commented Aug 1, 2022

In the version info parser (this line), it seems that it is not possible for a file to have the last number on the version be anything other than zero, and I was wondering why is that a problem?

@avakar
Copy link
Contributor

avakar commented Aug 1, 2022

That line is a check that UTF-16-encoded strings in the version info blob are terminated by the U+0000 character. It's a check on the validity of serialization, not on the validity of contents. Versions can end in "0" just fine.

@Napo2k
Copy link
Author

Napo2k commented Aug 18, 2022

I keep getting that error and I have no idea how to fix it😅 I am using pe_tools as part of our binary info stamping. The version to be stamped has four fields ('XX.YY.ZZ.PP')

@avakar
Copy link
Contributor

avakar commented Aug 18, 2022

I can have a look if you link the binary and provide the command line you're using.

@Napo2k
Copy link
Author

Napo2k commented Aug 19, 2022

Thank you for the response. Let me ask if that is possible.

@Napo2k
Copy link
Author

Napo2k commented Aug 19, 2022

In the meantime, I have added a print in my local copy of pe_tools, and this is what I can see

b'3\x002\x00.\x000\x00.\x004\x003\x009\x00.\x008\x002\x005\x001\x00'
32.0.439.8251
(...)
│ W:\gitlab\build_tool\.env\lib\site-packages\pe_tools\version_info.py:238 in _parse_one           │
│                                                                                                  │
│   235 │   │   │   if bytes(value[-2:]) != b'\0\0':                                               │
│   236 │   │   │   │   print(bytes(value))                                                        │
│   237 │   │   │   │   print(bytes(value).decode('utf-16le'))                                     │
│ ❱ 238 │   │   │   │   raise RuntimeError('version info string is not terminated by zero')        │
│   239 │   │   │   value = bytes(value[:-2]).decode('utf-16le')                                   │
│   240 │                                                                                          │
│   241 │   children = []                                                                          │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │      blob = rope()                                                                           │ │
│ │       hdr = _NODE_HEADER(wLength=60, wValueLength=13, wType=1)                               │ │
│ │       key = 'FileVersion'                                                                    │ │
│ │  key_size = 24                                                                               │ │
│ │      next = rope(<_io.BufferedReader                                                         │ │
│ │             name='W:\\zzbuilds\\output\\foo.exe'>[35188860:35189652])             │ │
│ │     value = rope(<_io.BufferedReader                                                         │ │
│ │             name='W:\\zzbuilds\\output\\foo.exe'>[35188832:35188858])             │ │
│ │ value_len = 26                                                                               │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: version info string is not terminated by zero

@Napo2k
Copy link
Author

Napo2k commented Aug 26, 2022

Any idea?

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

No branches or pull requests

2 participants