You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I've run Cppcheck for static code analysis on the master branch of this project. I've found the following 3 code snippets which may contain either a redundant check or a NULL dereference:
1) At src/onion/onion.c:860:7:
onion_listen_point *https = onion_https_new();
https->server = onion;
if (NULL == https) {
ONION_ERROR
("Could not promote from HTTP to HTTPS. Certificate not set.");
}
https->port = port;
https->hostname = hostname;
If the condition NULL == https can be true, then https->server is a NULL pointer dereference. Statement https->server = onion; was added in commit eaee81e03 , but before that commit the if condition was performed before the assignments. Maybe moving https->server = onion; after the condition is a good fix here?
Both code branches execute redisCommand(p->context, ...), but p is NULL for the first branch, so p->context will be a NULL pointer dereference.
3) At src/onion/poller.c:453:10:
if (el && el->fd == fd) {
...
}
while (el->next) {
...
}
If el can be NULL, then the statement while (el->next) will be a NULL pointer dereference. If not, the condition el && from if (el && el->fd == fd) is redundant.
The text was updated successfully, but these errors were encountered:
This commit resolves three null pointer dereferences mentioned by
Bogdanisar.
Comments about changes:
1) onion.c
Add return statement if promotion to https had failed
and set member variable only in !=NULL case.
2) Here, I'm unsure if my change is correct.
I assume that the NULL-check is using the wrong variable!
First of all, a check of the bl variable is missing. This indicates
that (bl == NULL) would be the correct check.
Moreover, the redis session probably should be deleted if the data
dict is empty, too. Thus, I changed the line to
if (onion_dict_count(data) == 0 || bl == NULL)
Other variants would be
if (bl == NULL)
if (data == NULL || bl == NULL )
3) poller.c:
If added a NULL check because poller->head is initialized
with NULL in onion_poller_new.
Hi!
I've run Cppcheck for static code analysis on the
master
branch of this project. I've found the following 3 code snippets which may contain either a redundant check or a NULL dereference:1) At
src/onion/onion.c:860:7
:If the condition
NULL == https
can be true, thenhttps->server
is a NULL pointer dereference. Statementhttps->server = onion;
was added in commit eaee81e03 , but before that commit theif
condition was performed before the assignments. Maybe movinghttps->server = onion;
after the condition is a good fix here?2) At
src/onion/sessions_redis.c:122:38
:Both code branches execute
redisCommand(p->context, ...)
, butp
isNULL
for the first branch, sop->context
will be a NULL pointer dereference.3) At
src/onion/poller.c:453:10
:If
el
can beNULL
, then the statementwhile (el->next)
will be a NULL pointer dereference. If not, the conditionel &&
fromif (el && el->fd == fd)
is redundant.The text was updated successfully, but these errors were encountered: