diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-02-02 03:04:07 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-02-02 03:04:07 +0000 |
commit | fe6cf9f3c519e37807130983dc1cced901598855 (patch) | |
tree | 64385392dae84739e2f48f3741615dbc0830ab5d /packet-syslog.c | |
parent | a4ff655ef2005c8828764820fe910d21f33772c5 (diff) |
The syslog daemon parses a facility and level if the message begins with
a '<', regardless of whether it's followed by a digit; do the same.
Use "tvb_bytes_exist()" rather than "tvb_length_remaining()" in the loop
that scans those digits.
Use "tvb_ensure_length_remaining()" to get the length of the message, so
we throw an exception if we've gone past the end of the tvbuff.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4674 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-syslog.c')
-rw-r--r-- | packet-syslog.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/packet-syslog.c b/packet-syslog.c index 33bd44f0d5..e94152eac6 100644 --- a/packet-syslog.c +++ b/packet-syslog.c @@ -3,7 +3,7 @@ * * Copyright 2000, Gerald Combs <gerald@ethereal.com> * - * $Id: packet-syslog.c,v 1.15 2002/01/24 09:20:52 guy Exp $ + * $Id: packet-syslog.c,v 1.16 2002/02/02 03:04:07 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -149,11 +149,12 @@ static void dissect_syslog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (check_col(pinfo->cinfo, COL_INFO)) col_clear(pinfo->cinfo, COL_INFO); - if (tvb_get_guint8(tvb, 0) == '<' && isdigit(tvb_get_guint8(tvb, 1))) { + if (tvb_get_guint8(tvb, msg_off) == '<') { + /* A facility and level follow. */ msg_off++; pri = 0; - while (isdigit(tvb_get_guint8(tvb, msg_off)) && msg_off <= MAX_DIGITS && - tvb_length_remaining(tvb, msg_off)) { + while (tvb_bytes_exist(tvb, msg_off, 1) && + isdigit(tvb_get_guint8(tvb, msg_off)) && msg_off <= MAX_DIGITS) { pri = pri * 10 + (tvb_get_guint8(tvb, msg_off) - '0'); msg_off++; } @@ -164,7 +165,7 @@ static void dissect_syslog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } /* Copy the message into a string buffer, with a trailing ellipsis if needed. */ - msg_len = tvb_length_remaining(tvb, msg_off); + msg_len = tvb_ensure_length_remaining(tvb, msg_off); if (msg_len >= COL_INFO_LEN) { tvb_memcpy(tvb, msg_str, msg_off, ellipsis_len); strcpy (msg_str + ellipsis_len, ELLIPSIS); |