Re: [dev] [lsw][bug] segfault after querying window with no children

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sat, 25 Jun 2022 10:22:30 +0200

On Sat, Jun 25, 2022 at 01:50:17AM +0000, Augusto Castelo wrote:
> Hi,
>
> lsw crashes with a segfault when you pass a window id of a window with no children.
>
> I spotted the problem, at line 39 of lsw.c; XQueryTree isn't failing but is setting `n` (children count (unsigned int)) to 0, later on `n` is used to loop throgh the children, in the first iteration &wins[n-1] >= &wins[0] is true when `n` is equal to 0 (because n-1 will evaluate to UINT_MAX) and then calling XGetWindowAttributes on that address produces a segfault.
>
> lsw-version: 0.3
> lsw-commit-hash: 4d6e1b3
>
> Cheers!
>

Hi Augusto,

Thanks reporting it. I pushed a fix to the repo. Let me know if it doesn't work
for you.

I also pushed a few code-style and cleanup improvements.

Thanks,

-- 
Kind regards,
Hiltjo
Received on Sat Jun 25 2022 - 10:22:30 CEST

This archive was generated by hypermail 2.3.0 : Sat Jun 25 2022 - 10:24:08 CEST