'tshark -G values' - Validate (somewhat) value_string_ext before use to prevent a...
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 14 Nov 2010 16:30:56 +0000 (16:30 +0000)
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 14 Nov 2010 16:30:56 +0000 (16:30 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@34869 f5534014-38df-0310-8fa8-9805f1628bb7

epan/proto.c
epan/value_string.c
epan/value_string.h

index 227508ed1786ec96487ad444b58246e464e048c2..2d451af257d975a5dd255bf3c2d843b8b3af9d72 100644 (file)
@@ -6035,6 +6035,10 @@ proto_registrar_dump_values(void)
                        if (vals) {
                                if (hfinfo->display & BASE_EXT_STRING) {
                                        value_string_ext *vse_p = (value_string_ext *)hfinfo->strings;
+                                        if (!value_string_ext_validate(vse_p)) {
+                                            g_warning("Invalid value_string_ext ptr for: %s", hfinfo->abbrev);
+                                            continue;
+                                        }
                                        match_strval_ext(0, vse_p); /* "prime" the extended value_string */
                                        printf("E\t%s\t%d\t%s\t%s\n",
                                               hfinfo->abbrev,
index 98c36ed6eec32a76bec31b058d8f93e8e09f6e57..b05fec4bf41fbb95cb710eb08cfd3c7d4a4308a4 100644 (file)
@@ -298,7 +298,19 @@ _match_strval_ext_init(const guint32 val, value_string_ext *vse)
   return vse->_vs_match(val, vse);
 }
 
-/* (For use by proto_registrar_dump_values() [See proto.c]) */
+/* (Fcns for use by proto_registrar_dump_values() [See proto.c]) */
+gboolean
+value_string_ext_validate(value_string_ext *vse) {
+    if (vse == NULL)
+        return FALSE;
+    if ((vse->_vs_match == (_value_string_match_t) _match_strval_ext_init) ||
+        (vse->_vs_match == _match_strval_linear)   ||
+        (vse->_vs_match == _match_strval_bsearch)  ||
+        (vse->_vs_match == _match_strval_index))
+        return TRUE;
+    return FALSE;
+}
+
 gchar *
 value_string_ext_match_type_str(value_string_ext *vse) {
     if (vse->_vs_match == _match_strval_linear)
@@ -307,7 +319,7 @@ value_string_ext_match_type_str(value_string_ext *vse) {
         return "[Binary Search]";
     if (vse->_vs_match == _match_strval_index)
         return "[Direct (indexed) Access]";
-    return "[Match Type not initialized]";
+    return "[Match Type not initialized or invalid]";
 }
 
 /* ----------- */
index d78c62337a36d1ac4f7bda02afb4f6429eb6f822..e018dc786f2a886f558a757e66d787760f4de1e4 100644 (file)
@@ -130,6 +130,9 @@ typedef struct _value_string_ext {
 #define VALUE_STRING_EXT_VS_P(x) (x)->_vs_p
 #define VALUE_STRING_EXT_VS_NUM_ENTRIES(x) (x)->_vs_num_entries
 #define VALUE_STRING_EXT_VS_NAME(x) (x)->_vs_name
+
+/* (Fcns for use by proto_registrar_dump_values() [See proto.c]) */
+gboolean value_string_ext_validate(value_string_ext *vse);
 gchar *value_string_ext_match_type_str(value_string_ext *vse);
 /* --- --- */