diff options
author | Guy Harris <guy@alum.mit.edu> | 2005-08-13 22:08:22 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2005-08-13 22:08:22 +0000 |
commit | 79dcb408d3982022a275c26139c75e2a74dd4226 (patch) | |
tree | 9c6f958918b3002a5f215b6ec570e3902a305ecb /epan/dissectors/packet-rpc.c | |
parent | 0fb64bd9cb7abfa1f1b2c9b42d9092fe024726ba (diff) |
Properly terminate the string generated for string items.
Use "format_text()" to handle non-printable characters in the display
string for those items.
svn path=/trunk/; revision=15342
Diffstat (limited to 'epan/dissectors/packet-rpc.c')
-rw-r--r-- | epan/dissectors/packet-rpc.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c index ca5c000033..d6e3adac78 100644 --- a/epan/dissectors/packet-rpc.c +++ b/epan/dissectors/packet-rpc.c @@ -44,6 +44,7 @@ #include "packet-nfs.h" #include <epan/tap.h> #include <epan/emem.h> +#include <epan/strutil.h> /* * See: @@ -621,20 +622,22 @@ dissect_rpc_opaque_data(tvbuff_t *tvb, int offset, if (string_data) { char *tmpstr; tmpstr = tvb_get_ephemeral_string(tvb, data_offset, string_length_copy); - string_buffer = memcpy(ep_alloc(string_length_copy), tmpstr, string_length_copy); + string_buffer = memcpy(ep_alloc(string_length_copy+1), tmpstr, string_length_copy); } else { - string_buffer = tvb_memcpy(tvb, ep_alloc(string_length_copy), data_offset, string_length_copy); + string_buffer = tvb_memcpy(tvb, ep_alloc(string_length_copy+1), data_offset, string_length_copy); } + string_buffer[string_length_copy] = '\0'; /* calculate a nice printable string */ if (string_length) { if (string_length != string_length_copy) { if (string_data) { + char *formatted; + + formatted = format_text(string_buffer, strlen(string_buffer)); /* alloc maximum data area */ - string_buffer_print = (char*)ep_alloc(string_length_copy + 12 + 1); + string_buffer_print = (char*)ep_alloc(strlen(formatted) + 12 + 1); /* copy over the data */ - memcpy(string_buffer_print,string_buffer,string_length_copy); - /* append a 0 byte for sure printing */ - string_buffer_print[string_length_copy] = '\0'; + strcpy(string_buffer_print,formatted); /* append <TRUNCATED> */ /* This way, we get the TRUNCATED even in the case of totally wrong packets, @@ -649,7 +652,8 @@ dissect_rpc_opaque_data(tvbuff_t *tvb, int offset, } } else { if (string_data) { - string_buffer_print = string_buffer; + string_buffer_print = + ep_strdup(format_text(string_buffer, strlen(string_buffer))); } else { string_buffer_print="<DATA>"; } |