On Tue, May 20, 2025 at 04:24:07PM +0200, Stanislav Brabec wrote: > Stanislav Brabec wrote: > > As the whhole econf_file structure is freed by econf_free(file) at the end > > > of blkid_read_config, econf_file structure cannot be defined as static and > > initialized only once. The econf_free() is not robust enough and keeps a > > pointer to the garbage after the first call. And if /etc/blkid.conf does > > not exist, it is called second time. > > However the patch is correct and fixes the crash, there are still open questions: > > - Why blkid_read_config() and econf_readConfig() are called twice with the same parameters? Is it intended behavior? This code pattern (e.g., libblkid/src/evaluate.c): conf = blkid_read_config(NULL); ... cachefile = blkid_get_cache_filename(conf); rc = blkid_get_cache(&c, cachefile); If blkid_get_cache_filename() returns NULL, then blkid_get_cache() reads the configuration again. Additionally, blkid_get_cache_filename() can read the configuration if 'conf' is NULL. Yes, it's not elegant. > - And finally, is a similar code in logindefs.c vulnerable to a similar type of crash? The `logindefs` uses a global `list` variable, which should be filled only once. Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com