}
}
-static const gchar *
-format_xdr_bytes(guint8 *bytes, guint32 length)
-{
- gchar *buf;
- guint32 i;
-
- if (length == 0)
- return "";
- buf = wmem_alloc(wmem_packet_scope(), length*2 + 1);
- for (i = 0; i < length; i++) {
- /* We know that buf has enough size to contain
- 2 * length + '\0' characters. */
- g_snprintf(buf, 2*(length - i) + 1, "%02x", bytes[i]);
- buf += 2;
- }
- return buf - length*2;
-}
-
static gboolean
dissect_xdr_opaque(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf,
guint32 size)
val = g_malloc(size);
start = xdr_getpos(xdrs);
if ((rc = xdr_opaque(xdrs, (caddr_t)val, size))) {
- proto_tree_add_bytes_format_value(tree, hf, tvb, start, xdr_getpos(xdrs) - start,
- NULL, "%s", format_xdr_bytes(val, size));
+ gint len = xdr_getpos(xdrs) - start;
+ const char *s = tvb_bytes_to_str(wmem_packet_scope(), tvb, start, len);
+
+ proto_tree_add_bytes_format_value(tree, hf, tvb, start, len, NULL, "%s", s);
} else {
proto_tree_add_item(tree, hf_libvirt_unknown, tvb, start, -1, ENC_NA);
}
start = xdr_getpos(xdrs);
if (xdr_bytes(xdrs, (char **)&val, &length, maxlen)) {
- proto_tree_add_bytes_format_value(tree, hf, tvb, start, xdr_getpos(xdrs) - start,
- NULL, "%s", format_xdr_bytes(val, length));
+ gint len = xdr_getpos(xdrs) - start;
+ const char *s = tvb_bytes_to_str(wmem_packet_scope(), tvb, start, len);
+
+ proto_tree_add_bytes_format_value(tree, hf, tvb, start, len, NULL, "%s", s);
/* Seems I can't call xdr_free() for this case.
It will raises SEGV by referencing out of bounds call stack */
free(val);