aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/file-png.c
diff options
context:
space:
mode:
authorMartin Kaiser <martin@skogar.kaiser.cx>2014-03-31 22:44:56 +0200
committerMartin Kaiser <wireshark@kaiser.cx>2014-04-01 21:26:12 +0000
commit577f16a25c1595f1775cde4a36c9f937c5ad7823 (patch)
tree3dbc3dd2c7d12f94aa1410e3ba99daeee369940c /epan/dissectors/file-png.c
parentfc48f57214d55d3f35bff87f1fffa08ac6f7bfd6 (diff)
use tvb_find_guint8() to find the 0 termination in a text chunk
keyword and text are latin1 strings Change-Id: I01637efa2ebf4d1e1a83f6001737066dc1258e6c Reviewed-on: https://code.wireshark.org/review/913 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Diffstat (limited to 'epan/dissectors/file-png.c')
-rw-r--r--epan/dissectors/file-png.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/epan/dissectors/file-png.c b/epan/dissectors/file-png.c
index 2c07e3ba6b..548f4918df 100644
--- a/epan/dissectors/file-png.c
+++ b/epan/dissectors/file-png.c
@@ -187,11 +187,11 @@ static header_field_info hfi_png_srgb_intent PNG_HFI_INIT = {
VALS(srgb_intent_vals), 0, NULL, HFILL };
static header_field_info hfi_png_text_keyword PNG_HFI_INIT = {
- "Keyword", "png.text.keyword", FT_STRING, BASE_NONE,
+ "Keyword", "png.text.keyword", FT_STRING, STR_UNICODE,
NULL, 0, NULL, HFILL };
static header_field_info hfi_png_text_string PNG_HFI_INIT = {
- "String", "png.text.string", FT_STRING, BASE_NONE,
+ "String", "png.text.string", FT_STRING, STR_UNICODE,
NULL, 0, NULL, HFILL };
static header_field_info hfi_png_time_year PNG_HFI_INIT = {
@@ -286,20 +286,19 @@ dissect_png_srgb(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
static void
dissect_png_text(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
{
- int offset=1;
+ gint offset=0, nul_offset;
- /* find the null that separates keyword and text string */
- while(1){
- if(!tvb_get_guint8(tvb, offset)){
- break;
- }
- offset++;
+ nul_offset = tvb_find_guint8(tvb, offset, tvb_length_remaining(tvb, offset), 0);
+ /* nul_offset == 0 means empty keyword, this is not allowed by the png standard */
+ if (nul_offset<=0) {
+ /* XXX exception */
+ return;
}
- proto_tree_add_item(tree, &hfi_png_text_keyword, tvb, 0, offset, ENC_ASCII|ENC_NA);
- offset++;
+ proto_tree_add_item(tree, &hfi_png_text_keyword, tvb, offset, nul_offset, ENC_ISO_8859_1|ENC_NA);
+ offset = nul_offset+1; /* length of the key word + 0 character */
- proto_tree_add_item(tree, &hfi_png_text_string, tvb, offset, tvb_length_remaining(tvb, offset), ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tree, &hfi_png_text_string, tvb, offset, tvb_length_remaining(tvb, offset), ENC_ISO_8859_1|ENC_NA);
}