{"action":"created","issue":{"url":"https://api.github.com/repos/radare/radare2/issues/2555","labels_url":"https://api.github.com/repos/radare/radare2/issues/2555/labels{/name}","comments_url":"https://api.github.com/repos/radare/radare2/issues/2555/comments","events_url":"https://api.github.com/repos/radare/radare2/issues/2555/events","html_url":"https://github.com/radare/radare2/issues/2555","id":75475575,"number":2555,"title":"Invalid read in r_bin_dwarf_parse_lnp_header when doing rabin2 -d of rabin2 itself","user":{"login":"dequis","id":94108,"avatar_url":"https://avatars.githubusercontent.com/u/94108?v=3","gravatar_id":"","url":"https://api.github.com/users/dequis","html_url":"https://github.com/dequis","followers_url":"https://api.github.com/users/dequis/followers","following_url":"https://api.github.com/users/dequis/following{/other_user}","gists_url":"https://api.github.com/users/dequis/gists{/gist_id}","starred_url":"https://api.github.com/users/dequis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dequis/subscriptions","organizations_url":"https://api.github.com/users/dequis/orgs","repos_url":"https://api.github.com/users/dequis/repos","events_url":"https://api.github.com/users/dequis/events{/privacy}","received_events_url":"https://api.github.com/users/dequis/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/radare/radare2/milestones/7","html_url":"https://github.com/radare/radare2/milestones/0.9.9","labels_url":"https://api.github.com/repos/radare/radare2/milestones/7/labels","id":684287,"number":7,"title":"0.9.9","description":"","creator":{"login":"jvoisin","id":325724,"avatar_url":"https://avatars.githubusercontent.com/u/325724?v=3","gravatar_id":"","url":"https://api.github.com/users/jvoisin","html_url":"https://github.com/jvoisin","followers_url":"https://api.github.com/users/jvoisin/followers","following_url":"https://api.github.com/users/jvoisin/following{/other_user}","gists_url":"https://api.github.com/users/jvoisin/gists{/gist_id}","starred_url":"https://api.github.com/users/jvoisin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvoisin/subscriptions","organizations_url":"https://api.github.com/users/jvoisin/orgs","repos_url":"https://api.github.com/users/jvoisin/repos","events_url":"https://api.github.com/users/jvoisin/events{/privacy}","received_events_url":"https://api.github.com/users/jvoisin/received_events","type":"User","site_admin":false},"open_issues":19,"closed_issues":91,"state":"open","created_at":"2014-06-08T01:35:57Z","updated_at":"2015-05-12T22:49:54Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2015-05-12T05:53:05Z","updated_at":"2015-05-13T16:05:23Z","closed_at":"2015-05-12T22:49:54Z","body":"Did this `valgrind -v rabin2 -d /usr/bin/rabin2`. Got this:\r\n\r\n```\r\n==26501== 1 errors in context 1 of 1:\r\n==26501== Invalid read of size 1\r\n==26501==    at 0x5CF3CA2: vfprintf (in /usr/lib/libc-2.21.so)\r\n==26501==    by 0x5CFA096: fprintf (in /usr/lib/libc-2.21.so)\r\n==26501==    by 0x538D7F1: r_bin_dwarf_parse_lnp_header (dwarf.c:261)\r\n==26501==    by 0x538EDBF: r_bin_dwarf_parse_line_raw2 (dwarf.c:695)\r\n==26501==    by 0x5391751: r_bin_dwarf_parse_line (dwarf.c:1517)\r\n==26501==    by 0x4EC0B53: bin_dwarf (bin.c:465)\r\n==26501==    by 0x4EC51B9: r_core_bin_info (bin.c:1631)\r\n==26501==    by 0x404B7D: main (rabin2.c:792)\r\n==26501==  Address 0x9cdbc68 is 0 bytes after a block of size 3,288 alloc'd\r\n==26501==    at 0x4C2C080: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==26501==    by 0x53916DB: r_bin_dwarf_parse_line (dwarf.c:1509)\r\n==26501==    by 0x4EC0B53: bin_dwarf (bin.c:465)\r\n==26501==    by 0x4EC51B9: r_core_bin_info (bin.c:1631)\r\n==26501==    by 0x404B7D: main (rabin2.c:792)\r\n```\r\n\r\nLine numbers correspond to 96a44f8ebf2c3f8e19f37ad89d1b0b50015b71e0\r\n\r\nThe relevant part of the output looks like this:\r\n\r\n```\r\nDWARF LINE HEADER\r\n  total_length: -468843518\r\n  version: 512\r\n  header_length: : 6688516\r\n  mininstlen: 2\r\n  is_stmt: 4\r\n  line_base: 16\r\n  line_range: 130\r\n  opcode_base: 0\r\nINCLUDEDIR (�)\r\nINCLUDEDIR (t\r\nINCLUDEDIR (\r\nINCLUDEDIR (�)\r\nINCLUDEDIR (f)\r\nINCLUDEDIR t)\r\nINCLUDEDIR (C)\r\nINCLUDEDIR (    �)\r\n```\r\n\r\nThe INCLUDEDIR lines are the ones that have invalid reads. The real issue is when it starts reading the line header at some location where it shouldn't, but I have no idea about any of this dwarf code does, so uh, better leave it to someone else.\r\n\r\nAlso, ASAN doesn't catch this because it doesn't instrument fprintf.\r\n\r\nIf you happen to need the binary i used for whatever reason, http://dequis.org/rabin2 - it also happens with the r2 binary and other programs i've built with debug symbols here."},"comment":{"url":"https://api.github.com/repos/radare/radare2/issues/comments/101726002","html_url":"https://github.com/radare/radare2/issues/2555#issuecomment-101726002","issue_url":"https://api.github.com/repos/radare/radare2/issues/2555","id":101726002,"user":{"login":"radare","id":917142,"avatar_url":"https://avatars.githubusercontent.com/u/917142?v=3","gravatar_id":"","url":"https://api.github.com/users/radare","html_url":"https://github.com/radare","followers_url":"https://api.github.com/users/radare/followers","following_url":"https://api.github.com/users/radare/following{/other_user}","gists_url":"https://api.github.com/users/radare/gists{/gist_id}","starred_url":"https://api.github.com/users/radare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radare/subscriptions","organizations_url":"https://api.github.com/users/radare/orgs","repos_url":"https://api.github.com/users/radare/repos","events_url":"https://api.github.com/users/radare/events{/privacy}","received_events_url":"https://api.github.com/users/radare/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T16:05:22Z","updated_at":"2015-05-13T16:05:22Z","body":"it fixes the issue which says “invaild read in ..”, now there are no invalid reads acording to asan or valgrind, but the parsing problem is another problem that should be addressed with more time, fixing the crash is the first step.\n\ni would ping the author @montekki before going deeper in the issue. Because this can be produced by a regression. which should be addressed by checking which commit broke that (first try with older versions of that parser).\n\n> On 13 May 2015, at 01:32, dx <notifications@github.com> wrote:\n> \n> But that doesn't fix the fact that the header contents are gibberish.\n> \n> DWARF LINE HEADER\n>   total_length: -468843518\n>   version: 512\n>   header_length: : 6688516\n>   mininstlen: 2\n>   is_stmt: 4\n>   line_base: 16\n>   line_range: 130\n>   opcode_base: 0\n> —\n> Reply to this email directly or view it on GitHub <https://github.com/radare/radare2/issues/2555#issuecomment-101459800>.\n> \n\n"}}