diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2006-01-29 12:57:14 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2006-01-29 12:57:14 +0000 |
commit | 9e9f3f621f77537f94850f5ff438083ea83f780c (patch) | |
tree | fd5d0bbd41f54a4a1a18b326e276f6ff57d8e0ac /epan/dissectors/packet-syslog.c | |
parent | 6f3d6c1257821a39f924886262909c269a0b6fd6 (diff) |
Use tvb_format_text() on the message, to handle non-printable characters
(including tabs and newlines).
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@17118 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-syslog.c')
-rw-r--r-- | epan/dissectors/packet-syslog.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/epan/dissectors/packet-syslog.c b/epan/dissectors/packet-syslog.c index f4d02eaec6..1fd272eadb 100644 --- a/epan/dissectors/packet-syslog.c +++ b/epan/dissectors/packet-syslog.c @@ -44,9 +44,6 @@ /* The maximum number if priority digits to read in. */ #define MAX_DIGITS 3 -#define COL_INFO_LEN 32 -#define ELLIPSIS "..." /* ISO 8859-1 doesn't appear to have a real ellipsis. */ - static const value_string short_lev[] = { { 0, "EMERG" }, { 1, "ALERT" }, @@ -139,10 +136,9 @@ static void dissect_syslog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { gint pri = -1, lev = -1, fac = -1; gint msg_off = 0, msg_len; - gint ellipsis_len = (COL_INFO_LEN - strlen(ELLIPSIS)) - 1; proto_item *ti; proto_tree *syslog_tree; - gchar msg_str[COL_INFO_LEN]; + const char *msg_str; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "Syslog"); @@ -164,23 +160,15 @@ static void dissect_syslog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) lev = pri & PRIORITY_MASK; } - /* Copy the message into a string buffer, with a trailing ellipsis if needed. */ msg_len = tvb_ensure_length_remaining(tvb, msg_off); - if (msg_len >= COL_INFO_LEN) { - tvb_memcpy(tvb, msg_str, msg_off, ellipsis_len); - g_snprintf(msg_str + ellipsis_len, COL_INFO_LEN-ellipsis_len, "%s", ELLIPSIS); - } else { - tvb_memcpy(tvb, msg_str, msg_off, msg_len); - msg_str[msg_len] = '\0'; - } - + msg_str = tvb_format_text(tvb, msg_off, msg_len); if (check_col(pinfo->cinfo, COL_INFO)) { if (pri >= 0) { col_add_fstr(pinfo->cinfo, COL_INFO, "%s.%s: %s", val_to_str(fac, short_fac, "UNKNOWN"), val_to_str(lev, short_lev, "UNKNOWN"), msg_str); } else { - col_add_fstr(pinfo->cinfo, COL_INFO, "%s", msg_str); + col_add_str(pinfo->cinfo, COL_INFO, msg_str); } } |