aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2003-05-24 19:51:48 +0000
committerGerald Combs <gerald@wireshark.org>2003-05-24 19:51:48 +0000
commitdcc9976c1331ed55c0aa9179bbdcc08b5181fd47 (patch)
treec1bd8a99cf71146a18f12e7422030ab68e42603c
parent356ddbd284075257edda1b7a8c77fe9539f817b5 (diff)
downloadwireshark-dcc9976c1331ed55c0aa9179bbdcc08b5181fd47.tar.gz
wireshark-dcc9976c1331ed55c0aa9179bbdcc08b5181fd47.tar.bz2
wireshark-dcc9976c1331ed55c0aa9179bbdcc08b5181fd47.zip
Fix more string-related nits found by Timo Sirainen/
svn path=/trunk/; revision=7732
-rw-r--r--packet-clnp.c4
-rw-r--r--packet-isis-clv.c16
-rw-r--r--packet-rmi.c3
3 files changed, 13 insertions, 10 deletions
diff --git a/packet-clnp.c b/packet-clnp.c
index 32e583718f..0f54d442df 100644
--- a/packet-clnp.c
+++ b/packet-clnp.c
@@ -1,7 +1,7 @@
/* packet-clnp.c
* Routines for ISO/OSI network and transport protocol packet disassembly
*
- * $Id: packet-clnp.c,v 1.74 2003/04/22 22:03:45 deniel Exp $
+ * $Id: packet-clnp.c,v 1.75 2003/05/24 19:51:48 gerald Exp $
* Laurent Deniel <laurent.deniel@free.fr>
* Ralf Schneider <Ralf.Schneider@t-online.de>
*
@@ -326,7 +326,7 @@ static gboolean clnp_reassemble = FALSE;
static gchar *print_tsap(const guchar *tsap, int length)
{
- static gchar str[3][MAX_TSAP_LEN * 2 + 1];
+ static gchar str[3][MAX_TSAP_LEN * 2 + 3]; /* TSAP in hex + '0x' + NULL */
static gchar *cur;
gchar tmp[3];
gboolean allprintable;
diff --git a/packet-isis-clv.c b/packet-isis-clv.c
index 612abd962b..ded0558ddc 100644
--- a/packet-isis-clv.c
+++ b/packet-isis-clv.c
@@ -1,7 +1,7 @@
/* packet-isis-clv.c
* Common CLV decode routines.
*
- * $Id: packet-isis-clv.c,v 1.25 2003/04/02 08:36:42 guy Exp $
+ * $Id: packet-isis-clv.c,v 1.26 2003/05/24 19:51:48 gerald Exp $
* Stuart Stanley <stuarts@mxmail.net>
*
* Ethereal - Network traffic analyzer
@@ -145,14 +145,15 @@ isis_dissect_area_address_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
* Output:
* void, but we will add to proto tree if !NULL.
*/
+#define SBUF_LEN 300 /* 255 + header info area */
void
isis_dissect_authentication_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
int length, char *meaning)
{
guchar pw_type;
- char sbuf[300]; /* 255 + header info area */
+ char sbuf[SBUF_LEN];
char *s = sbuf;
- int auth_unsupported;
+ int auth_unsupported, ret;
if ( length <= 0 ) {
return;
@@ -165,11 +166,11 @@ isis_dissect_authentication_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
switch (pw_type) {
case 1:
- s += sprintf ( s, "clear text (1), password (length %d) = ", length );
+ ret = sprintf ( s, "clear text (1), password (length %d) = ", length );
+ s += ret;
if ( length > 0 ) {
- strncpy(s, tvb_get_ptr(tvb, offset, length), length);
- s[length] = 0;
+ strncpy(s, tvb_get_ptr(tvb, offset, length), MIN(length, SBUF_LEN - ret));
} else {
strcat(s, "no clear-text password found!!!" );
}
@@ -192,11 +193,12 @@ isis_dissect_authentication_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
}
break;
default:
- s += sprintf ( s, "type 0x%02x (0x%02x): ", pw_type, length );
+ sprintf (sbuf, "type 0x%02x (0x%02x): ", pw_type, length );
auth_unsupported=TRUE;
break;
}
+ sbuf[SBUF_LEN] = '\0';
proto_tree_add_text ( tree, tvb, offset - 1, length + 1,
"%s %s", meaning, sbuf );
diff --git a/packet-rmi.c b/packet-rmi.c
index ed2474de1f..cbcb2b9f86 100644
--- a/packet-rmi.c
+++ b/packet-rmi.c
@@ -2,7 +2,7 @@
* Routines for java rmiregistry dissection
* Copyright 2002, Michael Stiller <ms@2scale.net>
*
- * $Id: packet-rmi.c,v 1.7 2003/03/09 03:19:03 jmayer Exp $
+ * $Id: packet-rmi.c,v 1.8 2003/05/24 19:51:48 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -210,6 +210,7 @@ dissect_rmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
strncpy(epid_hostname,
"<string too long>", sizeof(epid_hostname));
}
+ epid_hostname[sizeof(epid_hostname)] = '\0';
proto_tree_add_string(rmi_tree, hf_rmi_epid_hostname,
tvb, offset + 3, strlen(epid_hostname),
epid_hostname);