aboutsummaryrefslogtreecommitdiffstats
path: root/packet-syslog.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-02-02 03:04:07 +0000
committerGuy Harris <guy@alum.mit.edu>2002-02-02 03:04:07 +0000
commit9d0cf92048bde44345e26b046751d99782e128d3 (patch)
tree64385392dae84739e2f48f3741615dbc0830ab5d /packet-syslog.c
parentae0d2eb20e506422a051a29dade50af7a452b3b0 (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. svn path=/trunk/; revision=4674
Diffstat (limited to 'packet-syslog.c')
-rw-r--r--packet-syslog.c11
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);