aboutsummaryrefslogtreecommitdiffstats
path: root/packet-rpc.c
diff options
context:
space:
mode:
authorUwe Girlich <Uwe.Girlich@philosys.de>1999-12-06 09:51:56 +0000
committerUwe Girlich <Uwe.Girlich@philosys.de>1999-12-06 09:51:56 +0000
commitea591cd1708b9ccd135958579b828cb284f1e5e1 (patch)
treea525fc51472a076b47ae532649133c1aac610cd3 /packet-rpc.c
parentaf31f0b1ad5c17d53e6bfaf0c84c9f9a52991791 (diff)
downloadwireshark-ea591cd1708b9ccd135958579b828cb284f1e5e1.tar.gz
wireshark-ea591cd1708b9ccd135958579b828cb284f1e5e1.tar.bz2
wireshark-ea591cd1708b9ccd135958579b828cb284f1e5e1.zip
dissect_rpc_string() can now better handle truncated strings.
svn path=/trunk/; revision=1227
Diffstat (limited to 'packet-rpc.c')
-rw-r--r--packet-rpc.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/packet-rpc.c b/packet-rpc.c
index afaff97837..ddfb9d55c1 100644
--- a/packet-rpc.c
+++ b/packet-rpc.c
@@ -2,7 +2,7 @@
* Routines for rpc dissection
* Copyright 1999, Uwe Girlich <Uwe.Girlich@philosys.de>
*
- * $Id: packet-rpc.c,v 1.20 1999/12/02 10:20:42 girlich Exp $
+ * $Id: packet-rpc.c,v 1.21 1999/12/06 09:51:56 girlich Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -448,10 +448,21 @@ dissect_rpc_opaque_data(const u_char *pd, int offset, frame_data *fd, proto_tree
if (string_length) {
if (string_length != string_length_copy) {
if (string_data) {
- string_buffer_print = (char*)g_malloc(string_length_copy + 1 + 12);
+ /* alloc maximum data area */
+ string_buffer_print = (char*)g_malloc(string_length_copy + 12 + 1);
+ /* copy over the data */
memcpy(string_buffer_print,string_buffer,string_length_copy);
- memcpy(string_buffer_print+string_length_copy,
- "<TRUNCATED>", 12);
+ /* append a 0 byte for sure printing */
+ string_buffer_print[string_length_copy] = '\0';
+ /* append <TRUNCATED> */
+ /* This way, we get the TRUNCATED even
+ in the case of totally wrong packets,
+ where \0 are inside the string.
+ TRUNCATED will appear at the
+ first \0 or at the end (where we
+ put the securing \0).
+ */
+ strcat(string_buffer_print,"<TRUNCATED>");
}
else {
string_buffer_print = g_strdup("<DATA><TRUNCATED>");