]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Handle call to zlog_5424_cycle() without valid FD properly 17775/head
authorMartin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
Mon, 6 Jan 2025 14:35:30 +0000 (15:35 +0100)
committerMartin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
Wed, 8 Jan 2025 12:30:40 +0000 (13:30 +0100)
In zlog_5424_cycle(), struct zlt_5424 *zlt only points to valid memory when
the passed file descriptor is >= 0 (and passing -1 seems to be a supported
use case). So we shouldn't try to compute the address of its zt member when
zlt is NULL.

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
lib/zlog_5424.c

index c8586a1a02a62cf287d14defa180579f6bb72efe..6265ce3b1f92dbf8dddebdea278765c00b9aa4b9 100644 (file)
@@ -782,7 +782,7 @@ static void zlog_5424_cycle(struct zlog_cfg_5424 *zcf, int fd)
        }
 
        old = zcf->active ? &zcf->active->zt : NULL;
-       old = zlog_target_replace(old, &zlt->zt);
+       old = zlog_target_replace(old, zlt ? &zlt->zt : NULL);
        zcf->active = zlt;
 
        /* oldt->fd == fd happens for zlog_5424_apply_meta() */