diff options
| author | Quentin Young <qlyoung@nvidia.com> | 2020-09-02 17:24:54 -0400 |
|---|---|---|
| committer | Quentin Young <qlyoung@nvidia.com> | 2020-09-08 11:43:40 -0400 |
| commit | 589b5e4802920d260ce1804d51ce0b1e80788622 (patch) | |
| tree | c7e84f9abf7e1c40dd6a208796734d4408d0e1a8 /lib/zlog_targets.c | |
| parent | 2e5b029865137c1aa383454d3552487a2b998ee4 (diff) | |
lib: fix possible null dereference in zlog
In some cases one or both of the zlog targets in use here can be null,
we need to check for that.
Interestingly it appears we don't crash even when this is the case.
Undefined behavior ftw
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
Diffstat (limited to 'lib/zlog_targets.c')
| -rw-r--r-- | lib/zlog_targets.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/zlog_targets.c b/lib/zlog_targets.c index b23ab073b4..8f4c2a46a8 100644 --- a/lib/zlog_targets.c +++ b/lib/zlog_targets.c @@ -225,10 +225,11 @@ static bool zlog_file_cycle(struct zlog_cfg_file *zcf) zlt->zt.logfn_sigsafe = zlog_fd_sigsafe; } while (0); - old = zlog_target_replace(&zcf->active->zt, &zlt->zt); + old = zlog_target_replace(zcf->active ? &zcf->active->zt : NULL, + zlt ? &zlt->zt : NULL); zcf->active = zlt; - zlog_file_target_free(container_of(old, struct zlt_fd, zt)); + zlog_file_target_free(container_of_null(old, struct zlt_fd, zt)); return rv; } |
