aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2012-11-11 20:29:06 +0000
committerEvan Huus <eapache@gmail.com>2012-11-11 20:29:06 +0000
commit1bcc30de17ca94ebbe847c6cf3835a6cf849856f (patch)
tree547102f8faab97785d5aa5d64522de7cb582dc3d /epan/dissectors
parent08b94f4dd01a1d6d8489ca276c19b3c9152f8c6b (diff)
Fix part of https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6665
Make sure the array of names is always null-terminated, even if we have enough names to fill the entire thing. Also use a gboolean instead of a gint for one variable. svn path=/trunk/; revision=46003
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/packet-tpncp.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/epan/dissectors/packet-tpncp.c b/epan/dissectors/packet-tpncp.c
index 8e1a28b12f..7a5524ee62 100644
--- a/epan/dissectors/packet-tpncp.c
+++ b/epan/dissectors/packet-tpncp.c
@@ -371,7 +371,8 @@ static gint fill_tpncp_id_vals(value_string string[], FILE *file) {
/*-------------------------------------------------------------------------------------------------------------------------------------------*/
static gint fill_enums_id_vals(FILE *file) {
- gint i = 0, enum_id = 0, enum_val = 0, first_entry = 1;
+ gint i = 0, enum_id = 0, enum_val = 0;
+ gboolean first_entry = TRUE;
gchar *line_in_file = NULL, *enum_name = NULL,
*enum_type = NULL, *enum_str = NULL;
@@ -401,7 +402,7 @@ static gint fill_enums_id_vals(FILE *file) {
}
}
else
- first_entry = 0;
+ first_entry = FALSE;
tpncp_enums_name_vals[enum_val] = g_strdup(enum_name);
g_strlcpy(enum_type, enum_name, MAX_TPNCP_DB_ENTRY_LEN);
}
@@ -415,6 +416,16 @@ static gint fill_enums_id_vals(FILE *file) {
}
}
}
+ /* make sure the last entry in the array is null but
+ * don't overflow if we've filled the entire thing (in which case
+ * we have to drop an entry) */
+ if (enum_val + 1 >= MAX_ENUMS_NUM) {
+ g_free(tpncp_enums_name_vals[enum_val]);
+ tpncp_enums_name_vals[enum_val] = NULL;
+ }
+ else {
+ tpncp_enums_name_vals[enum_val+1] = NULL;
+ }
return 0;
}