{"action":"created","issue":{"url":"https://api.github.com/repos/radare/radare2/issues/7558","repository_url":"https://api.github.com/repos/radare/radare2","labels_url":"https://api.github.com/repos/radare/radare2/issues/7558/labels{/name}","comments_url":"https://api.github.com/repos/radare/radare2/issues/7558/comments","events_url":"https://api.github.com/repos/radare/radare2/issues/7558/events","html_url":"https://github.com/radare/radare2/issues/7558","id":230229823,"number":7558,"title":"pdc produces Segmentation Fault","user":{"login":"thestr4ng3r","id":1460997,"avatar_url":"https://avatars3.githubusercontent.com/u/1460997?v=3","gravatar_id":"","url":"https://api.github.com/users/thestr4ng3r","html_url":"https://github.com/thestr4ng3r","followers_url":"https://api.github.com/users/thestr4ng3r/followers","following_url":"https://api.github.com/users/thestr4ng3r/following{/other_user}","gists_url":"https://api.github.com/users/thestr4ng3r/gists{/gist_id}","starred_url":"https://api.github.com/users/thestr4ng3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thestr4ng3r/subscriptions","organizations_url":"https://api.github.com/users/thestr4ng3r/orgs","repos_url":"https://api.github.com/users/thestr4ng3r/repos","events_url":"https://api.github.com/users/thestr4ng3r/events{/privacy}","received_events_url":"https://api.github.com/users/thestr4ng3r/received_events","type":"User","site_admin":false},"labels":[{"id":110937869,"url":"https://api.github.com/repos/radare/radare2/labels/anal","name":"anal","color":"009800","default":false},{"id":8289060,"url":"https://api.github.com/repos/radare/radare2/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/radare/radare2/milestones/20","html_url":"https://github.com/radare/radare2/milestone/20","labels_url":"https://api.github.com/repos/radare/radare2/milestones/20/labels","id":2267381,"number":20,"title":"1.5.0","description":"","creator":{"login":"radare","id":917142,"avatar_url":"https://avatars2.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},"open_issues":74,"closed_issues":34,"state":"open","created_at":"2017-01-20T16:17:41Z","updated_at":"2017-05-23T09:51:36Z","due_on":"2017-05-29T07:00:00Z","closed_at":null},"comments":7,"created_at":"2017-05-21T15:55:13Z","updated_at":"2017-05-23T10:49:31Z","closed_at":null,"body":"Example binary: [test.tar.gz](https://github.com/radare/radare2/files/1017125/test.tar.gz)\r\nRun r2 like this: `r2 -A test -c \"pdc @ sym.storm\"`\r\n\r\nThe crash happens in core at pseudo.c:127 in the function `find_and_change()`:\r\n```\r\n...\r\n} else if (ctx.comment && *in == '(' && (IS_ALPHA (in[-1]) || *ctx.right == '*') && !ctx.right) {\r\n...\r\n```\r\nIt's obvious that this whole condition cannot be correct, because of `!ctx.right` and `*ctx.right == '*'`, which is the cause of the segfault here. `IS_ALPHA (in[-1])` is false, but `ctx.right` is null.\r\n\r\nI'm having some trouble understanding the whole function's code myself to fix it correctly. Here's what I found out:\r\nFor each block, `r_core_pseudo_code()` calls `pD` with some specific options and gives the output to `find_and_change()` which parses it and makes it more readable.\r\nThis is the problematic part of the `pD` output in this case:\r\n```\r\n     sym.corrosion ()         ; sym.corrosion\r\n     if (dword [local_4h] == 0 \r\n```\r\n`find_and_change()` parses the first line here, including parsing the content of the comment for the function call. After reading the `sym.corrosion` in the comment, it will look for an opening brace, which does not exist here. However it does not stop at the end of the line, because of this code at line 36, which I have no idea what purpuse it has:\r\n```\r\nif (*in == '\\n' || !*in) {\r\n\tif (ctx.type == TYPE_SYM && ctx.linecount < 1) {\r\n\t\tctx.linecount++;\r\n\t\tctx.linebegin = in + 1;\r\n\t\tcontinue;\r\n\t}\r\n...\r\n```\r\nThis makes it continue reading into the next line, eventually finding the `(` of the if. At this point ctx.right is null, but `IS_ALPHA (in[-1])` is false, because of the space after the if, which leads to the segfault."},"comment":{"url":"https://api.github.com/repos/radare/radare2/issues/comments/303361949","html_url":"https://github.com/radare/radare2/issues/7558#issuecomment-303361949","issue_url":"https://api.github.com/repos/radare/radare2/issues/7558","id":303361949,"user":{"login":"wargio","id":561184,"avatar_url":"https://avatars1.githubusercontent.com/u/561184?v=3","gravatar_id":"","url":"https://api.github.com/users/wargio","html_url":"https://github.com/wargio","followers_url":"https://api.github.com/users/wargio/followers","following_url":"https://api.github.com/users/wargio/following{/other_user}","gists_url":"https://api.github.com/users/wargio/gists{/gist_id}","starred_url":"https://api.github.com/users/wargio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wargio/subscriptions","organizations_url":"https://api.github.com/users/wargio/orgs","repos_url":"https://api.github.com/users/wargio/repos","events_url":"https://api.github.com/users/wargio/events{/privacy}","received_events_url":"https://api.github.com/users/wargio/received_events","type":"User","site_admin":false},"created_at":"2017-05-23T10:49:31Z","updated_at":"2017-05-23T10:49:31Z","body":"yes, but you haven't merged the PR."}}
{"actor":{"display_login":"wargio"}}