Replace bytes_to_ep_str_punct with wmem equivalent.
Change-Id: I8aa7d7374db94685fd875cbf358c3bfbc83f3255 Reviewed-on: https://code.wireshark.org/review/6370 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
9cfe67fde6
commit
98d3b1494b
|
@ -76,7 +76,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
byte_array_dup@Base 1.9.1
|
||||
byte_array_equal@Base 1.9.1
|
||||
bytes_to_ep_str@Base 1.12.0~rc1
|
||||
bytes_to_ep_str_punct@Base 1.12.0~rc1
|
||||
bytes_to_str@Base 1.99.2
|
||||
bytestring_to_str@Base 1.9.1
|
||||
call_ber_oid_callback@Base 1.9.1
|
||||
|
|
|
@ -102,12 +102,12 @@ dissect_ieee802a(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
pid = tvb_get_ntohs(tvb, 3);
|
||||
|
||||
col_add_fstr(pinfo->cinfo, COL_INFO, "OUI %s (%s), PID 0x%04X",
|
||||
bytes_to_ep_str_punct(oui, 3, ':'),
|
||||
bytestring_to_str(wmem_packet_scope(), oui, 3, ':'),
|
||||
manuf ? manuf : "Unknown", pid);
|
||||
|
||||
proto_tree_add_uint_format_value(ieee802a_tree, hf_ieee802a_oui,
|
||||
tvb, 0, 3, oui32, "%s (%s)",
|
||||
bytes_to_ep_str_punct(oui, 3, ':'), manuf ? manuf : "Unknown");
|
||||
bytestring_to_str(wmem_packet_scope(), oui, 3, ':'), manuf ? manuf : "Unknown");
|
||||
|
||||
/*
|
||||
* Do we have information for this OUI?
|
||||
|
|
|
@ -3435,7 +3435,9 @@ ssl_privkey_to_sexp(struct gnutls_x509_privkey_int* priv_key)
|
|||
if (ret != 0) {
|
||||
ssl_debug_printf( "gnutls_x509_privkey_get_key_id(ssl_pkey, 0, buf_keyid, &buf_len) - %s\n", gnutls_strerror(ret));
|
||||
} else {
|
||||
ssl_debug_printf( "Private key imported: KeyID %s\n", bytes_to_ep_str_punct(buf_keyid, (int) buf_len, ':'));
|
||||
char* keyid = (char*)bytestring_to_str(NULL, buf_keyid, (int) buf_len, ':');
|
||||
ssl_debug_printf( "Private key imported: KeyID %s\n", keyid);
|
||||
wmem_free(NULL, keyid);
|
||||
}
|
||||
|
||||
/* RSA get parameter */
|
||||
|
|
|
@ -292,8 +292,7 @@ dvb_add_chartbl(proto_tree *tree, int hf,
|
|||
proto_tree_add_bytes_format_value(tree, hf,
|
||||
tvb, offset, length, NULL, "%s (%s)",
|
||||
val_to_str_const(encoding, dvb_string_encoding_vals, "Unknown"),
|
||||
bytes_to_ep_str_punct(
|
||||
tvb_get_ptr(tvb, offset, length), length, ' '));
|
||||
tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, offset, length, ' '));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
88
epan/proto.c
88
epan/proto.c
|
@ -4271,25 +4271,41 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
switch(hfinfo->display)
|
||||
{
|
||||
case BASE_DOT:
|
||||
offset_r += protoo_strlcpy(result+offset_r,
|
||||
bytes ? bytes_to_ep_str_punct(bytes, fvalue_length(&finfo->value), '.') : "<MISSING>",
|
||||
size-offset_r);
|
||||
if (bytes) {
|
||||
char* str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), '.');
|
||||
offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
|
||||
wmem_free(NULL, str);
|
||||
} else {
|
||||
offset_r += protoo_strlcpy(result+offset_r, "<MISSING>", size-offset_r);
|
||||
}
|
||||
break;
|
||||
case BASE_DASH:
|
||||
offset_r += protoo_strlcpy(result+offset_r,
|
||||
bytes ? bytes_to_ep_str_punct(bytes, fvalue_length(&finfo->value), '-') : "<MISSING>",
|
||||
size-offset_r);
|
||||
if (bytes) {
|
||||
char* str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), '-');
|
||||
offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
|
||||
wmem_free(NULL, str);
|
||||
} else {
|
||||
offset_r += protoo_strlcpy(result+offset_r, "<MISSING>", size-offset_r);
|
||||
}
|
||||
break;
|
||||
case BASE_SEMICOLON:
|
||||
offset_r += protoo_strlcpy(result+offset_r,
|
||||
bytes ? bytes_to_ep_str_punct(bytes, fvalue_length(&finfo->value), ':') : "<MISSING>",
|
||||
size-offset_r);
|
||||
if (bytes) {
|
||||
char* str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), ':');
|
||||
offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
|
||||
wmem_free(NULL, str);
|
||||
} else {
|
||||
offset_r += protoo_strlcpy(result+offset_r, "<MISSING>", size-offset_r);
|
||||
}
|
||||
break;
|
||||
case BASE_NONE:
|
||||
default:
|
||||
offset_r += protoo_strlcpy(result+offset_r,
|
||||
bytes ? bytes_to_ep_str(bytes, fvalue_length(&finfo->value)) : "<MISSING>",
|
||||
size-offset_r);
|
||||
if (bytes) {
|
||||
char* str = (char*)bytes_to_str(NULL, bytes, fvalue_length(&finfo->value));
|
||||
offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
|
||||
wmem_free(NULL, str);
|
||||
} else {
|
||||
offset_r += protoo_strlcpy(result+offset_r, "<MISSING>", size-offset_r);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -4416,10 +4432,9 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
break;
|
||||
|
||||
case FT_ETHER:
|
||||
offset_r += protoo_strlcpy(result+offset_r,
|
||||
bytes_to_ep_str_punct((const guint8 *)fvalue_get(&finfo->value),
|
||||
FT_ETHER_LEN, ':'),
|
||||
size-offset_r);
|
||||
SET_ADDRESS (&addr, AT_ETHER, FT_ETHER_LEN, fvalue_get(&finfo->value));
|
||||
address_to_str_buf(&addr, result+offset_r, size-offset_r);
|
||||
offset_r = (int)strlen(result);
|
||||
break;
|
||||
|
||||
case FT_GUID:
|
||||
|
@ -6028,25 +6043,28 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
|
|||
case FT_BYTES:
|
||||
case FT_UINT_BYTES:
|
||||
bytes = (guint8 *)fvalue_get(&fi->value);
|
||||
switch(hfinfo->display)
|
||||
{
|
||||
case BASE_DOT:
|
||||
label_fill(label_str, 0, hfinfo,
|
||||
(bytes) ? bytes_to_ep_str_punct(bytes, fvalue_length(&fi->value), '.') : "<MISSING>");
|
||||
break;
|
||||
case BASE_DASH:
|
||||
label_fill(label_str, 0, hfinfo,
|
||||
(bytes) ? bytes_to_ep_str_punct(bytes, fvalue_length(&fi->value), '-') : "<MISSING>");
|
||||
break;
|
||||
case BASE_SEMICOLON:
|
||||
label_fill(label_str, 0, hfinfo,
|
||||
(bytes) ? bytes_to_ep_str_punct(bytes, fvalue_length(&fi->value), ':') : "<MISSING>");
|
||||
break;
|
||||
case BASE_NONE:
|
||||
default:
|
||||
label_fill(label_str, 0, hfinfo,
|
||||
(bytes) ? bytes_to_ep_str(bytes, fvalue_length(&fi->value)) : "<MISSING>");
|
||||
break;
|
||||
if (bytes) {
|
||||
char* str = NULL;
|
||||
switch(hfinfo->display)
|
||||
{
|
||||
case BASE_DOT:
|
||||
str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&fi->value), '.');
|
||||
break;
|
||||
case BASE_DASH:
|
||||
str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&fi->value), '-');
|
||||
break;
|
||||
case BASE_SEMICOLON:
|
||||
str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&fi->value), ':');
|
||||
break;
|
||||
case BASE_NONE:
|
||||
default:
|
||||
str = (char*)bytes_to_str(NULL, bytes, fvalue_length(&fi->value));
|
||||
break;
|
||||
}
|
||||
label_fill(label_str, 0, hfinfo, str);
|
||||
wmem_free(NULL, str);
|
||||
} else {
|
||||
label_fill(label_str, 0, hfinfo, "<MISSING>");
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -253,38 +253,6 @@ bytes_to_str(wmem_allocator_t *allocator, const guint8 *bd, int bd_len)
|
|||
return cur;
|
||||
}
|
||||
|
||||
/* Turn an array of bytes into a string showing the bytes in hex with
|
||||
* punct as a bytes separator.
|
||||
*/
|
||||
gchar *
|
||||
bytes_to_ep_str_punct(const guint8 *bd, int bd_len, gchar punct)
|
||||
{
|
||||
gchar *cur;
|
||||
gchar *cur_ptr;
|
||||
int truncated = 0;
|
||||
|
||||
if (!punct)
|
||||
return bytes_to_ep_str(bd, bd_len);
|
||||
|
||||
cur=(gchar *)ep_alloc(MAX_BYTE_STR_LEN+3+1);
|
||||
if (bd_len <= 0) { cur[0] = '\0'; return cur; }
|
||||
|
||||
if (bd_len > MAX_BYTE_STR_LEN/3) { /* bd_len > 16 */
|
||||
truncated = 1;
|
||||
bd_len = MAX_BYTE_STR_LEN/3;
|
||||
}
|
||||
|
||||
cur_ptr = bytes_to_hexstr_punct(cur, bd, bd_len, punct); /* max MAX_BYTE_STR_LEN-1 bytes */
|
||||
|
||||
if (truncated) {
|
||||
*cur_ptr++ = punct; /* 1 byte */
|
||||
cur_ptr = g_stpcpy(cur_ptr, "..."); /* 3 bytes */
|
||||
}
|
||||
|
||||
*cur_ptr = '\0';
|
||||
return cur;
|
||||
}
|
||||
|
||||
static int
|
||||
guint32_to_str_buf_len(const guint32 u)
|
||||
{
|
||||
|
|
|
@ -123,8 +123,6 @@ WS_DLL_PUBLIC gchar* tvb_address_var_to_str(wmem_allocator_t *scope, tvbuff_t *t
|
|||
* @param bd A pointer to the byte array
|
||||
* @param bd_len The length of the byte array
|
||||
* @return A pointer to the formatted string
|
||||
*
|
||||
* @see bytes_to_ep_str_punct()
|
||||
*/
|
||||
WS_DLL_PUBLIC gchar *bytes_to_ep_str(const guint8 *bd, int bd_len);
|
||||
|
||||
|
@ -136,15 +134,14 @@ WS_DLL_PUBLIC char *bytes_to_str(wmem_allocator_t *allocator, const guint8 *bd,
|
|||
/** Turn an array of bytes into a string showing the bytes in hex,
|
||||
* separated by a punctuation character.
|
||||
*
|
||||
* @param bd A pointer to the byte array
|
||||
* @param bd_len The length of the byte array
|
||||
* @param scope memory allocation scheme used
|
||||
* @param ad A pointer to the byte array
|
||||
* @param len The length of the byte array
|
||||
* @param punct The punctuation character
|
||||
* @return A pointer to the formatted string
|
||||
*
|
||||
* @see bytes_to_ep_str()
|
||||
* @see bytes_to_str()
|
||||
*/
|
||||
WS_DLL_PUBLIC gchar *bytes_to_ep_str_punct(const guint8 *bd, int bd_len, gchar punct);
|
||||
|
||||
WS_DLL_PUBLIC const gchar *bytestring_to_str(wmem_allocator_t *scope, const guint8 *ad, const guint32 len, const char punct);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue