Skip to content

Commit

Permalink
lib: Handle call to zlog_5424_cycle() without valid FD properly
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gromit1811 committed Jan 8, 2025
1 parent 90355e7 commit a4f92e2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/zlog_5424.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() */
Expand Down

0 comments on commit a4f92e2

Please sign in to comment.