DCE RPC version numbers are unsigned - print them with "%u".
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 15 Dec 2003 20:15:03 +0000 (20:15 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 15 Dec 2003 20:15:03 +0000 (20:15 +0000)
Do the same checks for negative and >255 version numbers in the
Tethereal DCE RPC statistics tap that are done in the Ethereal tap.

In the Ethereal tap, do those checks before looking up the protocol name.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@9290 f5534014-38df-0310-8fa8-9805f1628bb7

gtk/dcerpc_stat.c
tap-dcerpcstat.c

index 18cfd2807fb4de4455faadb4e4da2cd92ec33a60..d504896f90860405f114be3c45c28194dd4c5720 100644 (file)
@@ -1,7 +1,7 @@
 /* dcerpc_stat.c
  * dcerpc_stat   2002 Ronnie Sahlberg
  *
- * $Id: dcerpc_stat.c,v 1.33 2003/12/13 22:23:18 guy Exp $
+ * $Id: dcerpc_stat.c,v 1.34 2003/12/15 20:15:03 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -89,7 +89,7 @@ dcerpcstat_gen_title(rpcstat_t *rs)
 {
        char *title;
 
-       title = g_strdup_printf("DCE-RPC Service Response Time statistics for %s version %d.%d: %s", rs->prog, rs->ver&0xff, rs->ver>>8, cf_get_display_name(&cfile));
+       title = g_strdup_printf("DCE-RPC Service Response Time statistics for %s version %u.%u: %s", rs->prog, rs->ver&0xff, rs->ver>>8, cf_get_display_name(&cfile));
        return title;
 }
 
@@ -190,6 +190,7 @@ gtk_dcerpcstat_init(char *optarg)
        e_uuid_t uuid;
        int d1,d2,d3,d40,d41,d42,d43,d44,d45,d46,d47;
        int major, minor;
+       guint16 ver;
        int pos=0;
         char *filter=NULL;
         GString *error_string;
@@ -216,22 +217,28 @@ gtk_dcerpcstat_init(char *optarg)
                fprintf(stderr, "ethereal: invalid \"-z dcerpc,srt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
                exit(1);
        }
+       if (major < 0 || major > 255) {
+               fprintf(stderr,"ethereal: dcerpcstat_init() Major version number %d is invalid - must be positive and <= 255\n", major);
+               exit(1);
+       }
+       if (minor < 0 || minor > 255) {
+               fprintf(stderr,"ethereal: dcerpcstat_init() Minor version number %d is invalid - must be positive and <= 255\n", minor);
+               exit(1);
+       }
+       ver = ((minor<<8)|(major&0xff));
 
 
        rs=g_malloc(sizeof(rpcstat_t));
-       if (major < 0 || major > 255 || minor < 0 || minor > 255)
-               rs->prog = NULL;        /* bogus major or minor */
-       else
-               rs->prog=dcerpc_get_proto_name(&uuid, (guint16) ((minor<<8)|(major&0xff)) );
+       rs->prog=dcerpc_get_proto_name(&uuid, ver);
        if(!rs->prog){
                g_free(rs);
-               fprintf(stderr,"ethereal: dcerpcstat_init() Protocol with uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x v%d.%d not supported\n",uuid.Data1,uuid.Data2,uuid.Data3,uuid.Data4[0],uuid.Data4[1],uuid.Data4[2],uuid.Data4[3],uuid.Data4[4],uuid.Data4[5],uuid.Data4[6],uuid.Data4[7],major,minor);
+               fprintf(stderr,"ethereal: dcerpcstat_init() Protocol with uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x v%u.%u not supported\n",uuid.Data1,uuid.Data2,uuid.Data3,uuid.Data4[0],uuid.Data4[1],uuid.Data4[2],uuid.Data4[3],uuid.Data4[4],uuid.Data4[5],uuid.Data4[6],uuid.Data4[7],major,minor);
                exit(1);
        }
-       hf_opnum=dcerpc_get_proto_hf_opnum(&uuid, (guint16) ((minor<<8)|(major&0xff)) );
-       procs=dcerpc_get_proto_sub_dissector(&uuid, (guint16) ((minor<<8)|(major&0xff)) );
+       hf_opnum=dcerpc_get_proto_hf_opnum(&uuid, ver);
+       procs=dcerpc_get_proto_sub_dissector(&uuid, ver);
        rs->uuid=uuid;
-       rs->ver=(minor<<8)|(major&0xff);
+       rs->ver=ver;
 
        rs->win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_default_size(GTK_WINDOW(rs->win), 550, 400);
@@ -322,7 +329,7 @@ dcerpcstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
 
        str = g_string_new("dcerpc,srt");
        g_string_sprintfa(str,
-           ",%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d",
+           ",%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%u.%u",
            dcerpc_uuid_program->Data1, dcerpc_uuid_program->Data2,
            dcerpc_uuid_program->Data3,
            dcerpc_uuid_program->Data4[0], dcerpc_uuid_program->Data4[1],
@@ -362,7 +369,7 @@ dcerpcstat_find_vers(gpointer *key, gpointer *value _U_, gpointer *user_data _U_
                return NULL;
        }
 
-       sprintf(vs,"%d.%d",k->ver&0xff,k->ver>>8);
+       sprintf(vs,"%u.%u",k->ver&0xff,k->ver>>8);
        menu_item=gtk_menu_item_new_with_label(vs);
        SIGNAL_CONNECT(menu_item, "activate", dcerpcstat_version_select,
                        ((int)k->ver));
index 1ef20c3fb5e4b0a1a420f7717ee66b17c37701ec..237b737ca5ca85eaab797ed927b1300f64159719 100644 (file)
@@ -1,7 +1,7 @@
 /* tap-dcerpcstat.c
  * dcerpcstat   2002 Ronnie Sahlberg
  *
- * $Id: tap-dcerpcstat.c,v 1.6 2003/09/03 10:10:17 sahlberg Exp $
+ * $Id: tap-dcerpcstat.c,v 1.7 2003/12/15 20:15:02 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -158,7 +158,7 @@ dcerpcstat_draw(void *prs)
 #endif
        printf("\n");
        printf("===================================================================\n");
-       printf("%s Version %d.%d RTT Statistics:\n", rs->prog, rs->ver&0xff,rs->ver>>8);
+       printf("%s Version %u.%u RTT Statistics:\n", rs->prog, rs->ver&0xff,rs->ver>>8);
        printf("Filter: %s\n",rs->filter?rs->filter:"");
        printf("Procedure                  Calls   Min RTT   Max RTT   Avg RTT\n");
        for(i=0;i<rs->num_procedures;i++){
@@ -194,6 +194,7 @@ dcerpcstat_init(char *optarg)
        e_uuid_t uuid;
        int d1,d2,d3,d40,d41,d42,d43,d44,d45,d46,d47;
        int major, minor;
+       guint16 ver;
        int pos=0;
         char *filter=NULL;
         GString *error_string;
@@ -219,18 +220,26 @@ dcerpcstat_init(char *optarg)
                fprintf(stderr, "tethereal: invalid \"-z dcerpc,rtt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
                exit(1);
        }
-
+       if (major < 0 || major > 255) {
+               fprintf(stderr,"tethereal: dcerpcstat_init() Major version number %d is invalid - must be positive and <= 255\n", major);
+               exit(1);
+       }
+       if (minor < 0 || minor > 255) {
+               fprintf(stderr,"tethereal: dcerpcstat_init() Minor version number %d is invalid - must be positive and <= 255\n", minor);
+               exit(1);
+       }
+       ver = ((minor<<8)|(major&0xff));
 
        rs=g_malloc(sizeof(rpcstat_t));
-       rs->prog=dcerpc_get_proto_name(&uuid, (minor<<8)|(major&0xff) );
+       rs->prog=dcerpc_get_proto_name(&uuid, ver);
        if(!rs->prog){
                g_free(rs);
-               fprintf(stderr,"tethereal: dcerpcstat_init() Protocol with uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x v%d.%d not supported\n",uuid.Data1,uuid.Data2,uuid.Data3,uuid.Data4[0],uuid.Data4[1],uuid.Data4[2],uuid.Data4[3],uuid.Data4[4],uuid.Data4[5],uuid.Data4[6],uuid.Data4[7],major,minor);
+               fprintf(stderr,"tethereal: dcerpcstat_init() Protocol with uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x v%u.%u not supported\n",uuid.Data1,uuid.Data2,uuid.Data3,uuid.Data4[0],uuid.Data4[1],uuid.Data4[2],uuid.Data4[3],uuid.Data4[4],uuid.Data4[5],uuid.Data4[6],uuid.Data4[7],major,minor);
                exit(1);
        }
-       procs=dcerpc_get_proto_sub_dissector(&uuid, (minor<<8)|(major&0xff) );
+       procs=dcerpc_get_proto_sub_dissector(&uuid, ver);
        rs->uuid=uuid;
-       rs->ver=(minor<<8)|(major&0xff);
+       rs->ver=ver;
 
        if(filter){
                rs->filter=g_malloc(strlen(filter)+1);