Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null-pointer fixes #216

Merged
merged 6 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cfg-block.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ _validate_spurious_args(CfgArgs *self, CfgArgs *defs, const gchar *reference)
static gboolean
_validate_args(CfgArgs *self, CfgArgs *defs, const gchar *reference)
{
return _validate_mandatory_options(defs, self, reference) && _validate_spurious_args(self, defs, reference);
return defs && _validate_mandatory_options(defs, self, reference) && _validate_spurious_args(self, defs, reference);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion lib/logreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ log_reader_work_finished(void *s, gpointer arg)
self->notify_code = 0;
log_pipe_notify(self->control, notify_code, self);
}
if (self->super.super.flags & PIF_INITIALIZED)
if ((self->super.super.flags & PIF_INITIALIZED) && self->proto)
{
/* reenable polling the source assuming that we're still in
* business (e.g. the reader hasn't been uninitialized) */
Expand Down
2 changes: 1 addition & 1 deletion lib/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ plugin_load_module(PluginContext *context, const gchar *module_name, CfgArgs *ar
g_module_make_resident(mod);
module_info = _get_module_info(mod);

if (module_info->canonical_name)
if (module_info && module_info->canonical_name)
{
g_free(module_init_func);
module_init_func = _format_module_init_name(module_info->canonical_name ? : module_name);
Expand Down
1 change: 1 addition & 0 deletions lib/template/repr.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ _setup_function_call(LogTemplate *template, Plugin *p, LogTemplateElem *e,

g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
e->func.ops = plugin_construct(p);
g_return_val_if_fail(e->func.ops != NULL, FALSE);
e->func.state = e->func.ops->size_of_state > 0 ? g_malloc0(e->func.ops->size_of_state) : NULL;

/* prepare may modify the argv array: remove and rearrange elements */
Expand Down
11 changes: 10 additions & 1 deletion modules/affile/affile-dest.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ affile_dw_queue(LogPipe *s, LogMessage *lm, const LogPathOptions *path_options)
log_pipe_forward_msg(&self->super, lm, path_options);
}

static void
affile_dw_unset_owner(AFFileDestWriter *self)
{
if (self->owner)
log_pipe_unref(&self->owner->super.super.super);

self->owner = NULL;
}

static void
affile_dw_set_owner(AFFileDestWriter *self, AFFileDestDriver *owner)
{
Expand Down Expand Up @@ -512,7 +521,7 @@ affile_dd_reuse_writer(gpointer key, gpointer value, gpointer user_data)
affile_dw_set_owner(writer, self);
if (!log_pipe_init(&writer->super))
{
affile_dw_set_owner(writer, NULL);
affile_dw_unset_owner(writer);
log_pipe_unref(&writer->super);
g_hash_table_remove(self->writer_hash, key);
}
Expand Down
3 changes: 3 additions & 0 deletions news/bugfix-216.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed potential null pointer deref issues

TODO Add Dmitry Levin @nivelus to the NEWS file as a thank you for finding these
Loading