librc/librc-depend.c: fix NULL pointer dereference
In some cases deptree or depinfo can be NULL, check before dereferencing. Fixes https://github.com/OpenRC/openrc/issues/293 Fixes https://github.com/OpenRC/openrc/pulls/294 X-Gentoo-Bug: 659906 X-Gentoo-Bug-URL: https://bugs.gentoo.org/659906
This commit is contained in:
parent
065b7ecc0d
commit
7478c104fc
@ -84,10 +84,11 @@ static RC_DEPINFO *
|
|||||||
get_depinfo(const RC_DEPTREE *deptree, const char *service)
|
get_depinfo(const RC_DEPTREE *deptree, const char *service)
|
||||||
{
|
{
|
||||||
RC_DEPINFO *di;
|
RC_DEPINFO *di;
|
||||||
|
if (deptree) {
|
||||||
TAILQ_FOREACH(di, deptree, entries)
|
TAILQ_FOREACH(di, deptree, entries)
|
||||||
if (strcmp(di->service, service) == 0)
|
if (strcmp(di->service, service) == 0)
|
||||||
return di;
|
return di;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,9 +97,11 @@ get_deptype(const RC_DEPINFO *depinfo, const char *type)
|
|||||||
{
|
{
|
||||||
RC_DEPTYPE *dt;
|
RC_DEPTYPE *dt;
|
||||||
|
|
||||||
TAILQ_FOREACH(dt, &depinfo->depends, entries)
|
if (depinfo) {
|
||||||
if (strcmp(dt->type, type) == 0)
|
TAILQ_FOREACH(dt, &depinfo->depends, entries)
|
||||||
return dt;
|
if (strcmp(dt->type, type) == 0)
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user