Skip to content

Conversation

@m4rch3n1ng
Copy link

@m4rch3n1ng m4rch3n1ng commented Jul 22, 2025

now parses options such as playerctl volume 45% (which is equivalent to playerctl volume 0.45) and playerctl volume 5%+ (which is equivalent to playerctl volume 0.05+)

as a drive-by fix in [aa558c5] also avoid a heap-buffer overflow, as it was reading from index -1 when the string was empty (i.e. when calling playerctl volume ""). when running with asan, i got this error before this pr:

=================================================================
==404784==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7b9262be110f at pc 0x563727a62061 bp 0x7ffc855a8810 sp 0x7ffc855a8800
READ of size 1 at 0x7b9262be110f thread T0
    #0 0x563727a62060 in playercmd_volume ../playerctl/playerctl-cli.c:424
    #1 0x563727a6727c in main ../playerctl/playerctl-cli.c:1267
    #2 0x7f7263f146b4  (/usr/lib/libc.so.6+0x276b4) (BuildId: 468e3585c794491a48ea75fceb9e4d6b1464fc35)
    #3 0x7f7263f14768 in __libc_start_main (/usr/lib/libc.so.6+0x27768) (BuildId: 468e3585c794491a48ea75fceb9e4d6b1464fc35)
    #4 0x563727a5f764 in _start (/home/may/projects/playerctl/build/playerctl/playerctl+0x7764) (BuildId: bfb9bf259ecef198d7b8b26cdd423b31888e79bc)

when passing an empty string to `playerctl volume` it would then try to
read `len - 1`, which would be `-1`, which would be an invalid index
@m4rch3n1ng m4rch3n1ng changed the title allow addig '%' to volume command allow adding '%' to volume command Jul 22, 2025
allows things like `playerctl 45%`, which would be equivalent to
`playerctl 0.45`, and `playerctl 5%+`, which would be equivalent to
`playerctl 0.05+`.
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.

1 participant