avast / avast/retdec

Incorrect wide string character size

Open
#200 0 comments 0 reactions 0 assignees View on GitHub
bug C-bin2llvmir P-output
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Right now, RetDec expects 4-byte wide chars on Linux (ELF binaries) and 2-byte wide chars on Windows (PE).

If we compile this source:
```c
#include
#include

int main() {
printf("%d\n", sizeof(wchar_t));
wprintf(L"\x1111\xaaaa");
return 0;
}
```
like this (force 2-byte wide char):
```
gcc -m32 -fshort-wchar -o test.elf test.c
```
and decompile the binary, we get an incorrect output - bad string, because 4-byte char size was used. The same will happen if 4-byte wide chars are used in PE binaries.

No idea how to solve this, if it is even possible. But maybe someone will come up with something.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with the provided test.c source, gcc -m32 -fshort-wchar, and the generated test.elf, then decompile it and compare the wide-string output. No project source file or test entry point is named; done means wide characters are interpreted correctly for both 2-byte and 4-byte binaries.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
compilers, reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.