diff options
-rw-r--r-- | debian/libwireshark0.symbols | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-ieee802a.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-ssl-utils.c | 4 | ||||
-rw-r--r-- | epan/dvb_chartbl.c | 3 | ||||
-rw-r--r-- | epan/proto.c | 88 | ||||
-rw-r--r-- | epan/to_str.c | 32 | ||||
-rw-r--r-- | epan/to_str.h | 11 |
7 files changed, 63 insertions, 80 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index b4a57e1288..38bf1010fa 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -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 diff --git a/epan/dissectors/packet-ieee802a.c b/epan/dissectors/packet-ieee802a.c index d6b8af1258..4f6e1b38bf 100644 --- a/epan/dissectors/packet-ieee802a.c +++ b/epan/dissectors/packet-ieee802a.c @@ -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? diff --git a/epan/dissectors/packet-ssl-utils.c b/epan/dissectors/packet-ssl-utils.c index 1e9a6830cd..aef9101385 100644 --- a/epan/dissectors/packet-ssl-utils.c +++ b/epan/dissectors/packet-ssl-utils.c @@ -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 */ diff --git a/epan/dvb_chartbl.c b/epan/dvb_chartbl.c index 9d599d8be8..d1662d2341 100644 --- a/epan/dvb_chartbl.c +++ b/epan/dvb_chartbl.c @@ -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, ' ')); } } diff --git a/epan/proto.c b/epan/proto.c index a7722b3dd4..c8d8a338dc 100644 --- a/epan/proto.c +++ b/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; diff --git a/epan/to_str.c b/epan/to_str.c index 4dfdddf099..23629dac52 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -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) { diff --git a/epan/to_str.h b/epan/to_str.h index b1892dda1a..1f4c90e22e 100644 --- a/epan/to_str.h +++ b/epan/to_str.h @@ -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 |