Re: fix a use-after-free bug

Simon Josefsson via Bug reports for the GNU Internet utilities <[email protected]> Wed, 02 Jul 2025 10:07:20 +0200
Newsgroups gmane.comp.gnu.inetutils.bugs
Message-ID <[email protected]>
Collin Funk <[email protected]> writes:

> Hi Bruno,
>
> Bruno Haible via Bug reports for the GNU Internet utilities
> <[email protected]> writes:
>
>> gcc 15 reports this warning from -Wanalyzer-use-after-free:
>> ../../talkd/table.c:65:30: warning: use after 'free' of 'ptr' [CWE-416]
>>
>> gcc is right here: Accessing ptr->next after calling free (ptr)
>> (inside table_delete (ptr)) is invalid.
>
> I don't recall seeing this using -fanalyzer previously, so I assume
> there were some improvements in GCC 15. Thanks for the patch.
>
> Simon, this patch looks correct to me. Can you apply it? Not sure if it
> needs to be marked '(tiny patch)' or not.

I didn't review the patch yet, but I pushed it as a codeberg pull
request to see if that review workflow could work:

https://codeberg.org/inetutils/inetutils/pulls/1

I dislike merge commits, and I don't know how codeberg will behave if I
merge this in the web browser, and I also don't know if PGP signed git
commits will behave on codeberg (which I use).  So expect some confusion
on the codeberg git repo, I may need to force push things a couple of
times to get it right...

The preferences I like would be these:

https://codeberg.org/inetutils/inetutils/settings/units#pulls

Merge styles: 'Rebase then fast-forward' and 'Fast-forward only'
Default merge style: 'Fast-forward only'
Default update style: Update branch by rebase
Enable autodetect manual merge

I think that matches how we have merged contributions on Savannah, i.e.,
no merge commits.

/Simon
signature.asc (application/pgp-signature, 1.2 KB)
-----BEGIN PGP SIGNATURE-----

iQNoBAEWCAMQFiEEo8ychwudMQq61M8vUXIrCP5HRaIFAmhk6LgUHHNpbW9uQGpv
c2Vmc3Nvbi5vcmfCHCYAmDMEXJLOtBYJKwYBBAHaRw8BAQdACIcrZIvhrxDBkK9f
V+QlTmXxo2naObDuGtw58YaxlOu0JVNpbW9uIEpvc2Vmc3NvbiA8c2ltb25Aam9z
ZWZzc29uLm9yZz6IlgQTFggAPgIbAwULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgBYh
BLHSvRN1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