Ethereal-dev: [Ethereal-dev] Does expert info always have pinfo

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Fri, 10 Mar 2006 22:22:09 +0100 (CET)
Hi list,

I assume expert_add_info_format() always has to have a valid pinfo
parameter, because possible tap listeners will expect it to be there.
Therefore I propose the following patch, which makes the function more
robust in that respect. Please apply is assumption is correct.

The issue was raised in Coverity CID 112.

Thanx,
Jaap


Index: expert.c
===================================================================
--- expert.c    (revision 17568)
+++ expert.c    (working copy)
@@ -77,7 +77,7 @@


        /* if this packet isn't loaded because of a read filter, don't
output anything */
-       if(pinfo->fd->num == 0) {
+       if(pinfo == NULL || pinfo->fd->num == 0) {
                return;
        }

@@ -87,7 +87,7 @@
                formatted[sizeof(formatted) - 1] = '\0';

        ei = ep_alloc(sizeof(expert_info_t));
-       ei->packet_num  = pinfo ? pinfo->fd->num : 0;
+       ei->packet_num  = pinfo->fd->num;
        ei->group               = group;
        ei->severity    = severity;
        ei->protocol    = ep_strdup(pinfo->current_proto);