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

SIGABRT and calloc failure in parse_file() #5002

Closed
zhrvn opened this issue Jun 9, 2022 · 1 comment · Fixed by #5003
Closed

SIGABRT and calloc failure in parse_file() #5002

zhrvn opened this issue Jun 9, 2022 · 1 comment · Fixed by #5003

Comments

@zhrvn
Copy link
Contributor

zhrvn commented Jun 9, 2022

I'm submitting a…

[x] Bug
[ ] Feature Request
[ ] Documentation Request
[ ] Other (Please describe in detail)

Current Behavior

Using a config with nested variables (see config) causes i3 to crash either with a heap allocation failure (in calloc) or SIGABRT (heap smashing).

Expected Behavior

Using a config with nested variables (see config) doesn't cause i3 to crash.

Reproduction Instructions

Start i3 with the following configs.

Environment

Output of i3 --moreversion 2>&-:

Binary i3 version:  4.20-96-gce2665ca © 2009 Michael Stapelberg and contributors
Config file causing allocation failure
# i3 config file (v4)
set $xxxxxxxxxx 1
set $$xxxxxxxxxx 2
set $$$xxxxxxxxxx 3
set $$$$xxxxxxxxxx 4
set $$$$$xxxxxxxxxx 5
set $$$$$$xxxxxxxxxx 6
set $$$$$$$xxxxxxxxxx 7
set $$$$$$$$xxxxxxxxxx 8
set $$$$$$$$$xxxxxxxxxx 9
set $$$$$$$$$$xxxxxxxxxx 10
set $$$$$$$$$$$xxxxxxxxxx 11
set $$$$$$$$$$$$xxxxxxxxxx 12
set $$$$$$$$$$$$$xxxxxxxxxx 13
set $$$$$$$$$$$$$$xxxxxxxxxx 14
Config file causing SIGABRT
# i3 config file (v4)
set $xxxxxxxxxx 1
set $$xxxxxxxxxx 2
set $$$xxxxxxxxxx 3
Logfile URL: https://github.com/i3/i3/files/8869940/sigabrt-log.txt (SIGABRT) https://logs.i3wm.org/logs/6302401581547520.bz2 (calloc failure)
Strace URL: https://github.com/i3/i3/files/8869954/sigabrt-strace.txt (SIGABRT) https://github.com/i3/i3/files/8869961/calloc-strace.txt (calloc failure)
Backtrace URL: https://github.com/i3/i3/files/8869971/sigabrt-backtrace.txt (SIGABRT)
- Linux Distribution & Version: Arch Linux
- Are you using a compositor (e.g., xcompmgr or compton): no
@Airblader
Copy link
Member

Thanks for the report. Indeed we should not crash, but just to point it out, we do not support nested variables names.

zhrvn pushed a commit to zhrvn/i3 that referenced this issue Jun 9, 2022
Fixes i3#5002
If there is a variable with the same name as the rest of another
variable after removing $, then it will be counted twice. Therefore,
we need to completely replace it in order to correctly calculate the
length of a new string.
zhrvn pushed a commit to zhrvn/i3 that referenced this issue Jun 9, 2022
zhrvn pushed a commit to zhrvn/i3 that referenced this issue Jun 9, 2022
zhrvn pushed a commit to zhrvn/i3 that referenced this issue Jun 10, 2022
If there is a variable with the same name as the rest of another
variable after removing $, then it will be counted twice. Therefore,
we need to completely replace it with spaces (variable names cannot
contain spaces) in order to correctly calculate the length of a new
string.
zhrvn pushed a commit to zhrvn/i3 that referenced this issue Jun 10, 2022
If there is a variable with the same name as the rest of another
variable after removing $, then it will be counted twice. Therefore,
we need to completely replace it with spaces (variable names cannot
contain spaces) in order to correctly calculate the length of a new
string.
zhrvn pushed a commit to zhrvn/i3 that referenced this issue Jun 10, 2022
If there is a variable with the same name as the rest of another
variable after removing $, then it will be counted twice. Therefore,
we need to completely replace it with spaces (variable names cannot
contain spaces) in order to correctly calculate the length of a new
string.
stapelberg added a commit that referenced this issue Sep 12, 2022
Count extra_bytes correctly

If there is a variable with the same name as the rest of another
variable after removing $, then it will be counted twice. Therefore,
we need to completely replace it with spaces (variable names cannot
contain spaces) in order to correctly calculate the length of a new
string.

fixes #5002

Co-authored-by: Ivan Zharov <zhiv.email@gmail.com>
Co-authored-by: Michael Stapelberg <stapelberg@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants