Skip to content

Fix view segv in rc config - #1326

Merged
flyingmutant merged 2 commits into
cmus:masterfrom
adeason:fix-view-segv
Sep 8, 2024
Merged

flyingmutant merged 2 commits into
cmus:masterfrom
adeason:fix-view-segv

Conversation

@adeason

@adeason adeason commented Apr 22, 2024

Copy link
Copy Markdown
Contributor

I noticed if I have a view command in my rc config (e.g. view playlist), cmus segfaults at startup. I can provide a more detailed backtrace if needed, but I thought it's clear enough what's happening from the description in the commit message in here.

I also added a note in the manpage to say not to use view in the rc; I assume you're not supposed to do that, because the start_view option exists instead. I feel like view used to either work or do nothing, for old versions from years ago, because I had this in my rc for an old install. Using view in the config could also throw an error, I wasn't sure what's preferred.

@pgaskin
pgaskin self-requested a review August 6, 2024 01:19

@pgaskin pgaskin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, fixes the crash.

The start_view option was added in f1e96d8 and released in 2.8.0.

@pgaskin

pgaskin commented Sep 2, 2024

Copy link
Copy Markdown
Member

@flyingmutant

If our configuration contains a command like 'view playlist', we'll
call set_view() before init_curses() has run. tree_win_w is still 0,
and so update_pl_list calls update_window with w==1, which calls
sprint() with width==1, which calls format_str with with==-1. The
negative width gets interpreted as a very large unsigned int, leading
to memory corruption and a SEGV.

To avoid this, make do_update_view() check ui_initialized like
do_update_titleline() and other functions already do, and return early
if the ui isn't initialized yet.
@flyingmutant
flyingmutant merged commit dbe81e3 into cmus:master Sep 8, 2024
@flyingmutant

Copy link
Copy Markdown
Member

Thanks! Merged.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants