Trivial warning fixes
[obnox/wireshark/wip.git] / epan / dissectors / packet-ssh.c
index 19987dbcc47f0b77739575c7b8898b6a9cc7e9d2..fc37106177590014a18d644180579c5730963d38 100644 (file)
@@ -38,6 +38,7 @@
 #if HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#include <string.h>
 #include <glib.h>
 #include <epan/packet.h>
 #include <epan/conversation.h>
@@ -106,7 +107,7 @@ struct ssh_flow_data {
        gchar*  enc_client_request;
        gchar*  enc_server_offer;
        gchar*  enc;
-       
+
        gchar*  comp_client_request;
        gchar*  comp_server_offer;
        gchar*  comp;
@@ -261,21 +262,10 @@ dissect_ssh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        global_data = conversation_get_proto_data(conversation,proto_ssh);
        if(!global_data ) {
-               global_data = se_alloc(sizeof(struct ssh_flow_data));
-               global_data->req_counter=0;
-               global_data->rsp_counter=0;
+               global_data = se_alloc0(sizeof(struct ssh_flow_data));
                global_data->version=SSH_VERSION_UNKNOWN;
-
-               global_data->mac_client_request=NULL;
-               global_data->mac_server_offer=NULL;
                global_data->mac_length=-1;
 
-               global_data->enc_client_request=NULL;
-               global_data->enc_server_offer=NULL;
-
-               global_data->comp_client_request=NULL;
-               global_data->comp_server_offer=NULL;
-
                conversation_add_proto_data(conversation,proto_ssh,global_data);
        }
 
@@ -421,7 +411,7 @@ ssh_dissect_ssh2(tvbuff_t *tvb, packet_info *pinfo,
                        g_string_append_printf(title,")");
                }
 
-               ti=proto_tree_add_text(tree,tvb,offset,-1,title->str);
+               ti=proto_tree_add_text(tree,tvb,offset,-1, "%s", title->str);
                ssh2_tree = proto_item_add_subtree(ti ,ett_ssh2);
                if (title) g_string_free(title,TRUE);
        }
@@ -525,7 +515,7 @@ ssh_dissect_ssh1(tvbuff_t *tvb, packet_info *pinfo,
                                msg_code);
                }
                if (check_col(pinfo->cinfo, COL_INFO)) {
-                       col_append_str(pinfo->cinfo, COL_INFO, 
+                       col_append_str(pinfo->cinfo, COL_INFO,
                        val_to_str(msg_code, ssh1_msg_vals, "Unknown (%u)"));
                }
                offset += 1;
@@ -664,7 +654,7 @@ ssh_dissect_key_exchange(tvbuff_t *tvb, packet_info *pinfo,
 
        }
        if (check_col(pinfo->cinfo, COL_INFO)) {
-               col_append_str(pinfo->cinfo, COL_INFO, 
+               col_append_str(pinfo->cinfo, COL_INFO,
                        val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"));
        }
        offset += 1;
@@ -702,7 +692,7 @@ ssh_dissect_key_exchange(tvbuff_t *tvb, packet_info *pinfo,
                        offset+=ssh_tree_add_string(tvb,offset,key_ex_tree,hf_ssh_kexdh_h_sig,hf_ssh_kexdh_h_sig_length);
                }
        }
+
        len = plen+4-padding_length-(offset-last_offset);
        if (tree ) {
                ssh_proto_tree_add_item(key_ex_tree, hf_ssh_payload,
@@ -862,13 +852,13 @@ ssh_set_mac_length(struct ssh_flow_data *global_data, gchar *mac_name)
        if ((size_str=g_strrstr(mac_name,"-")) && ((size=atoi(size_str+1)))) {
                global_data->mac_length = size;
        }
-       else if (!g_strcmp0(mac_name,"hmac-sha1")) {
+       else if (strcmp(mac_name,"hmac-sha1") == 0) {
                global_data->mac_length = 20;
        }
-       else if (!g_strcmp0(mac_name,"hmac-md5")) {
+       else if (strcmp(mac_name,"hmac-md5") == 0) {
                global_data->mac_length = 12;
        }
-       else if (!g_strcmp0(mac_name,"none")) {
+       else if (strcmp(mac_name,"none") == 0) {
                global_data->mac_length = 0;
        }
 }
@@ -876,7 +866,13 @@ ssh_set_mac_length(struct ssh_flow_data *global_data, gchar *mac_name)
 static gint
 ssh_gslist_compare_strings(gconstpointer a, gconstpointer b)
 {
-       return g_strcmp0((char*)a,(char*)b);
+       if (a == NULL && b == NULL)
+               return 0;
+       if (a == NULL)
+               return -1;
+       if (b == NULL)
+               return 1;
+       return strcmp((char*)a,(char*)b);
 }
 
 /* expects that *result is NULL */