avast / avast/retdec

Bad decompiled matrix size

Open
#925 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Hi,

When decompiling a program with a matrix, the sizes of the matrix are not the correct. From 7x11 (correct) to 1x1 (wrong).

Original file maze.c:
https://pastebin.com/6wG5stht

```bash
> clang -g -O0 -fno-stack-protector -no-pie -Wall maze.c -o maze
> retdec-decompiler --select-functions main,draw maze -o mazeret.c
```

Decompiled file mazeret.c:
```c
...
// --------------------- Global Variables ---------------------

int32_t g1 = -3289; // 0x402004
char maze[1][1] = {"+"}; // 0x404050
...
```

There is also the "return &g1" which is very weird.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the report using maze.c and the shown clang and retdec-decompiler commands, then compare the matrix declaration in maze.c with mazeret.c for main and draw. Trace how RetDec derives the global matrix size and investigate the reported "return &g1"; done means the decompiled matrix has the original 7x11 dimensions and the unexpected return is explained or corrected.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
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.