]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Attempt to placate Coverity in rs_packet_process() (CID #1587345)
authorJames Jones <jejones3141@gmail.com>
Mon, 29 Jan 2024 20:28:05 +0000 (14:28 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 1 Feb 2024 16:02:46 +0000 (10:02 -0600)
Coverity infers from the check of original->expect in the call to
fr_radius_decode_simple() that original->expect can be NULL, and
hence the later call to rs_stats_update_latency() call that
dereferences original->expect may fail. It may be that if original
and original->linked are non-NULL, one can infer original->expect
is non-NULL. Coverity can't; hence the added check on that call to
rs_stats_update_latency()..

src/bin/radsniff.c

index e0158d3565c0a63f310ca165b5da6442f16e9dbc..64da1d6fe25ad3adbc9f4b5307a30475c4703596 100644 (file)
@@ -1856,7 +1856,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt
                 *      It also justifies allocating FR_RADIUS_CODE_MAXinstances of rs_latency_t.
                 */
                rs_stats_update_latency(&stats->exchange[packet->code], &latency);
-               rs_stats_update_latency(&stats->exchange[original->expect->code], &latency);
+               if (original->expect) rs_stats_update_latency(&stats->exchange[original->expect->code], &latency);
 
                /*
                 *      We're filtering on response, now print out the full data from the request