dhcpd: Verify DICT_VALUE exists itself
authorNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
Fri, 30 Jan 2015 11:35:06 +0000 (13:35 +0200)
committerNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
Fri, 30 Jan 2015 16:16:32 +0000 (18:16 +0200)
Verify that a DICT_VALUE was returned from dict_valbyattr by checking
the returned pointer, not the "name" field address. This likely fixes a
possible segfault when debugging.

This also fixes the following Coverity error:

Error: NO_EFFECT (CWE-398):
freeradius-server-2.2.6/src/main/dhcpd.c:300: array_null: Comparing an array to null is not useful: "dv->name".

src/main/dhcpd.c

index ce7b6be..b4e907f 100644 (file)
@@ -298,7 +298,7 @@ static int dhcp_process(REQUEST *request)
        if (vp) {
                DICT_VALUE *dv = dict_valbyattr(DHCP2ATTR(53), vp->vp_integer);
                DEBUG("Trying sub-section dhcp %s {...}",
-                     dv->name ? dv->name : "<unknown>");
+                     dv ? dv->name : "<unknown>");
                rcode = module_post_auth(vp->vp_integer, request);
        } else {
                DEBUG("DHCP: Failed to find DHCP-Message-Type in packet!");