avast / avast/retdec

Invalid initializer-string generation, writes random memory.

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

Description

Decompiled with `--backend-disabled-opts CopyPropagationOptimizer,DeadLocalAssignOptimizer,SimpleCopyPropagationOptimizer` as it was using 200GB of memory and had no progress for 24 hours with them enabled, so it might be related to that. But anyways, the output for intializer-strings breaks and tries to write random memory. Maybe an off-by one error in string length. e.g.
```
struct _GUID_8563 {
int32_t e0;
int16_t e1;
int16_t e2;
char e3[8];
};
struct _GUID_8563 var = {
.e0 = 0,
.e1 = 0,
.e2 = 16,
.e3 = "\x80\x00\x00\xaa\x00\x38\x9bq"
};
char base_dither_matrix[16][16] =
{
"\x00\xc0\x30\xf0\f\xcc<\xfc\x03\xc3\x33\xf3\x0f\xcf?\xff",
"\x80@\xb0p\x8cL\xbc|\x83\x43\xb3s\x8fO\xbf\x7f",
" \xe0\x10\xd0,\xec\x1c\xdc#\xe3\x13\xd3/\xef\x1f\xdf",
"\xa0`\x90P\xacl\x9c\\\xa3\x63\x93S\xafo\x9f_",
"\b\xc8\x38\xf8\x04\xc4\x34\xf4\v\xcb;\xfb\a\xc7\x37\xf7",
"\x88H\xb8x\x84\x44\xb4t\x8bK\xbb{\x87G\xb7w",
"(\xe8\x18\xd8$\xe4\x14\xd4+\xeb\x1b\xdb'\xe7\x17\xd7",
"\xa8h\x98X\xa4\x64\x94T\xabk\x9b[\xa7g\x97W",
"\x02\xc2\x32\xf2\x0e\xce>\xfe\x01\xc1\x31\xf1\r\xcd=\xfd",
"\x82\x42\xb2r\x8eN\xbe~\x81\x41\xb1q\x8dM\xbd}",
...
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the decompilation with the listed backend optimizers disabled and inspect the initializer-string generation that produces the shown C output. The fix is complete when generated string initializers preserve their intended lengths and no longer write random memory; the payload names no source files or tests to target.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.