{"action":"created","issue":{"url":"https://api.github.com/repos/Exiv2/exiv2/issues/316","repository_url":"https://api.github.com/repos/Exiv2/exiv2","labels_url":"https://api.github.com/repos/Exiv2/exiv2/issues/316/labels{/name}","comments_url":"https://api.github.com/repos/Exiv2/exiv2/issues/316/comments","events_url":"https://api.github.com/repos/Exiv2/exiv2/issues/316/events","html_url":"https://github.com/Exiv2/exiv2/pull/316","id":324648800,"number":316,"title":"Fix issue #306","user":{"login":"piponazo","id":102645,"avatar_url":"https://avatars0.githubusercontent.com/u/102645?v=4","gravatar_id":"","url":"https://api.github.com/users/piponazo","html_url":"https://github.com/piponazo","followers_url":"https://api.github.com/users/piponazo/followers","following_url":"https://api.github.com/users/piponazo/following{/other_user}","gists_url":"https://api.github.com/users/piponazo/gists{/gist_id}","starred_url":"https://api.github.com/users/piponazo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piponazo/subscriptions","organizations_url":"https://api.github.com/users/piponazo/orgs","repos_url":"https://api.github.com/users/piponazo/repos","events_url":"https://api.github.com/users/piponazo/events{/privacy}","received_events_url":"https://api.github.com/users/piponazo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-19T18:07:01Z","updated_at":"2018-05-20T20:27:25Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/Exiv2/exiv2/pulls/316","html_url":"https://github.com/Exiv2/exiv2/pull/316","diff_url":"https://github.com/Exiv2/exiv2/pull/316.diff","patch_url":"https://github.com/Exiv2/exiv2/pull/316.patch"},"body":"According to the specification:\r\nhttp://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html\r\n\r\nThe language tag (languageText) can be empty. In that case the language\r\nis unspecified and therefore there is not a translated keyword.\r\n\r\nI still need to add a test for this case, but please, let me know if you think that my analysis is correct."},"comment":{"url":"https://api.github.com/repos/Exiv2/exiv2/issues/comments/390509704","html_url":"https://github.com/Exiv2/exiv2/pull/316#issuecomment-390509704","issue_url":"https://api.github.com/repos/Exiv2/exiv2/issues/316","id":390509704,"user":{"login":"piponazo","id":102645,"avatar_url":"https://avatars0.githubusercontent.com/u/102645?v=4","gravatar_id":"","url":"https://api.github.com/users/piponazo","html_url":"https://github.com/piponazo","followers_url":"https://api.github.com/users/piponazo/followers","following_url":"https://api.github.com/users/piponazo/following{/other_user}","gists_url":"https://api.github.com/users/piponazo/gists{/gist_id}","starred_url":"https://api.github.com/users/piponazo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piponazo/subscriptions","organizations_url":"https://api.github.com/users/piponazo/orgs","repos_url":"https://api.github.com/users/piponazo/repos","events_url":"https://api.github.com/users/piponazo/events{/privacy}","received_events_url":"https://api.github.com/users/piponazo/received_events","type":"User","site_admin":false},"created_at":"2018-05-20T20:27:25Z","updated_at":"2018-05-20T20:27:25Z","author_association":"COLLABORATOR","body":"According to the specification:\r\n```\r\nThe language tag [RFC-1766] indicates the human language used by the translated keyword and the text. Unlike the keyword, the language tag is case-insensitive. It is an ASCII [ISO-646] string consisting of hyphen-separated words of 1-8 letters each (for example: cn, en-uk, no-bok, x-klingon). If the first word is two letters long, it is an ISO language code [ISO-639]. If the language tag is empty, the language is unspecified.\r\n```\r\nThis would be related to our `languageText` variable. Then the specification continues with:\r\n\r\n```\r\nThe translated keyword and text both use the UTF-8 encoding of the Unicode character set [ISO/IEC-10646-1], and neither may contain a zero byte (null character). The text, unlike the other strings, is not null-terminated; its length is implied by the chunk length.\r\n```\r\nI debugged the code with the POC provided in #306 and what we have is:\r\n- `compressionFlag == 1'\r\n- `compressionMethod == 0'\r\n- `languageText == \"\"'\r\n- `languageTextSize == 0'\r\n\r\nThen the next line of code (the old one):\r\n```\r\nstd::string translatedKeyText((const char*)(data.pData_ + keysize + 3 + languageTextSize +1));\r\n```\r\nWas causing the crash. It's true that I made an assumption. The code now says: if the `languageText` (that is the Language Tag according to the specification) is 0, we do not have a translated keyword, since we do not know to which language the tag is translated. However, later on, the code is still reading the **Text**.\r\n\r\nI actually tried with one valid PNG image with several text chunks that I got from this webpage:\r\nhttps://pmt.sourceforge.io/itxt/\r\n\r\nI think it would be also useful to include that small image in the test suite to check that we do not break this code in the future. I think we are not testing that part of the code right now.\r\n\r\nAnyways, let me know if you have more insights about this. The specification is not clear about what to do when the **Language Tag** is empty."}}
{"actor":{"display_login":"piponazo"}}