{"action":"created","comment":{"url":"https://api.github.com/repos/radare/radare2/pulls/comments/58842551","id":58842551,"diff_hunk":"@@ -97,23 +97,42 @@ R_API int r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size, int a\n \n R_API int r_core_write_op(RCore *core, const char *arg, char op) {\n \tint i, j, len, ret = false;\n-\tchar *str;\n+\tchar *str = NULL;\n \tut8 *buf;\n \n \t// XXX we can work with config.block instead of dupping it\n \tbuf = (ut8 *)malloc (core->blocksize);\n-\tstr = (char *)malloc (strlen (arg)+1);\n-\tif (buf == NULL || str == NULL)\n+\tif (!buf)\n \t\tgoto beach;\n \tmemcpy (buf, core->block, core->blocksize);\n-\tif (op!='e') {\n-\t\tlen = r_hex_str2bin (arg, (ut8 *)str);\n-\t\tif (len < 0) {\n-\t\t\teprintf (\"Invalid hexpair string\\n\");\n+\n+\t// fill key buffer either from arg or from clipboard\n+\tif (arg) {  // parse arg for key\n+\t\tstr = (char *)malloc (strlen (arg)+1);\n+\t\tif (!str)\n \t\t\tgoto beach;\n-\t\t}\n-\t} else len = 0;\n+\t\tif (op!='e') {\n+\t\t\tlen = r_hex_str2bin (arg, (ut8 *)str);\n+\t\t\tif (len < 0) {","path":"libr/core/io.c","position":29,"original_position":29,"commit_id":"4a696f3930441aa2ced07897a897955c9b248d6a","original_commit_id":"4a696f3930441aa2ced07897a897955c9b248d6a","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},"body":"if len == 0 is also an invalid length, right?","created_at":"2016-04-07T09:22:13Z","updated_at":"2016-04-07T09:22:13Z","html_url":"https://github.com/radare/radare2/pull/4533#discussion_r58842551","pull_request_url":"https://api.github.com/repos/radare/radare2/pulls/4533","_links":{"self":{"href":"https://api.github.com/repos/radare/radare2/pulls/comments/58842551"},"html":{"href":"https://github.com/radare/radare2/pull/4533#discussion_r58842551"},"pull_request":{"href":"https://api.github.com/repos/radare/radare2/pulls/4533"}}},"pull_request":{"url":"https://api.github.com/repos/radare/radare2/pulls/4533","id":65373996,"html_url":"https://github.com/radare/radare2/pull/4533","diff_url":"https://github.com/radare/radare2/pull/4533.diff","patch_url":"https://github.com/radare/radare2/pull/4533.patch","issue_url":"https://api.github.com/repos/radare/radare2/issues/4533","number":4533,"state":"open","locked":false,"title":"Adding `wo*y` commands using clipboard instead of [val]","user":{"login":"cr","id":170331,"avatar_url":"https://avatars.githubusercontent.com/u/170331?v=3","gravatar_id":"","url":"https://api.github.com/users/cr","html_url":"https://github.com/cr","followers_url":"https://api.github.com/users/cr/followers","following_url":"https://api.github.com/users/cr/following{/other_user}","gists_url":"https://api.github.com/users/cr/gists{/gist_id}","starred_url":"https://api.github.com/users/cr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cr/subscriptions","organizations_url":"https://api.github.com/users/cr/orgs","repos_url":"https://api.github.com/users/cr/repos","events_url":"https://api.github.com/users/cr/events{/privacy}","received_events_url":"https://api.github.com/users/cr/received_events","type":"User","site_admin":false},"body":"When working with streaming ciphers, being able to XOR memory regions inside radare is super nifty. This implementation uses the clipboard as XOR key which is repeated when it is shorter than blocksize.","created_at":"2016-04-05T21:26:39Z","updated_at":"2016-04-07T09:22:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f6440502b557bb76b2acfe17b0d04970542b397","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/radare/radare2/pulls/4533/commits","review_comments_url":"https://api.github.com/repos/radare/radare2/pulls/4533/comments","review_comment_url":"https://api.github.com/repos/radare/radare2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/radare/radare2/issues/4533/comments","statuses_url":"https://api.github.com/repos/radare/radare2/statuses/4a696f3930441aa2ced07897a897955c9b248d6a","head":{"label":"cr:cr-xor","ref":"cr-xor","sha":"4a696f3930441aa2ced07897a897955c9b248d6a","user":{"login":"cr","id":170331,"avatar_url":"https://avatars.githubusercontent.com/u/170331?v=3","gravatar_id":"","url":"https://api.github.com/users/cr","html_url":"https://github.com/cr","followers_url":"https://api.github.com/users/cr/followers","following_url":"https://api.github.com/users/cr/following{/other_user}","gists_url":"https://api.github.com/users/cr/gists{/gist_id}","starred_url":"https://api.github.com/users/cr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cr/subscriptions","organizations_url":"https://api.github.com/users/cr/orgs","repos_url":"https://api.github.com/users/cr/repos","events_url":"https://api.github.com/users/cr/events{/privacy}","received_events_url":"https://api.github.com/users/cr/received_events","type":"User","site_admin":false},"repo":{"id":55552945,"name":"radare2","full_name":"cr/radare2","owner":{"login":"cr","id":170331,"avatar_url":"https://avatars.githubusercontent.com/u/170331?v=3","gravatar_id":"","url":"https://api.github.com/users/cr","html_url":"https://github.com/cr","followers_url":"https://api.github.com/users/cr/followers","following_url":"https://api.github.com/users/cr/following{/other_user}","gists_url":"https://api.github.com/users/cr/gists{/gist_id}","starred_url":"https://api.github.com/users/cr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cr/subscriptions","organizations_url":"https://api.github.com/users/cr/orgs","repos_url":"https://api.github.com/users/cr/repos","events_url":"https://api.github.com/users/cr/events{/privacy}","received_events_url":"https://api.github.com/users/cr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cr/radare2","description":"unix-like reverse engineering framework and commandline tools","fork":true,"url":"https://api.github.com/repos/cr/radare2","forks_url":"https://api.github.com/repos/cr/radare2/forks","keys_url":"https://api.github.com/repos/cr/radare2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cr/radare2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cr/radare2/teams","hooks_url":"https://api.github.com/repos/cr/radare2/hooks","issue_events_url":"https://api.github.com/repos/cr/radare2/issues/events{/number}","events_url":"https://api.github.com/repos/cr/radare2/events","assignees_url":"https://api.github.com/repos/cr/radare2/assignees{/user}","branches_url":"https://api.github.com/repos/cr/radare2/branches{/branch}","tags_url":"https://api.github.com/repos/cr/radare2/tags","blobs_url":"https://api.github.com/repos/cr/radare2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cr/radare2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cr/radare2/git/refs{/sha}","trees_url":"https://api.github.com/repos/cr/radare2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cr/radare2/statuses/{sha}","languages_url":"https://api.github.com/repos/cr/radare2/languages","stargazers_url":"https://api.github.com/repos/cr/radare2/stargazers","contributors_url":"https://api.github.com/repos/cr/radare2/contributors","subscribers_url":"https://api.github.com/repos/cr/radare2/subscribers","subscription_url":"https://api.github.com/repos/cr/radare2/subscription","commits_url":"https://api.github.com/repos/cr/radare2/commits{/sha}","git_commits_url":"https://api.github.com/repos/cr/radare2/git/commits{/sha}","comments_url":"https://api.github.com/repos/cr/radare2/comments{/number}","issue_comment_url":"https://api.github.com/repos/cr/radare2/issues/comments{/number}","contents_url":"https://api.github.com/repos/cr/radare2/contents/{+path}","compare_url":"https://api.github.com/repos/cr/radare2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cr/radare2/merges","archive_url":"https://api.github.com/repos/cr/radare2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cr/radare2/downloads","issues_url":"https://api.github.com/repos/cr/radare2/issues{/number}","pulls_url":"https://api.github.com/repos/cr/radare2/pulls{/number}","milestones_url":"https://api.github.com/repos/cr/radare2/milestones{/number}","notifications_url":"https://api.github.com/repos/cr/radare2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cr/radare2/labels{/name}","releases_url":"https://api.github.com/repos/cr/radare2/releases{/id}","deployments_url":"https://api.github.com/repos/cr/radare2/deployments","created_at":"2016-04-05T21:10:42Z","updated_at":"2016-04-05T21:10:57Z","pushed_at":"2016-04-05T23:32:13Z","git_url":"git://github.com/cr/radare2.git","ssh_url":"git@github.com:cr/radare2.git","clone_url":"https://github.com/cr/radare2.git","svn_url":"https://github.com/cr/radare2","homepage":"http://www.radare.org/","size":56688,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"radare:master","ref":"master","sha":"26546e4f3afe1945fe706131b5d4cadf04e40ddb","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},"repo":{"id":4869294,"name":"radare2","full_name":"radare/radare2","owner":{"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},"private":false,"html_url":"https://github.com/radare/radare2","description":"unix-like reverse engineering framework and commandline tools","fork":false,"url":"https://api.github.com/repos/radare/radare2","forks_url":"https://api.github.com/repos/radare/radare2/forks","keys_url":"https://api.github.com/repos/radare/radare2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/radare/radare2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/radare/radare2/teams","hooks_url":"https://api.github.com/repos/radare/radare2/hooks","issue_events_url":"https://api.github.com/repos/radare/radare2/issues/events{/number}","events_url":"https://api.github.com/repos/radare/radare2/events","assignees_url":"https://api.github.com/repos/radare/radare2/assignees{/user}","branches_url":"https://api.github.com/repos/radare/radare2/branches{/branch}","tags_url":"https://api.github.com/repos/radare/radare2/tags","blobs_url":"https://api.github.com/repos/radare/radare2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/radare/radare2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/radare/radare2/git/refs{/sha}","trees_url":"https://api.github.com/repos/radare/radare2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/radare/radare2/statuses/{sha}","languages_url":"https://api.github.com/repos/radare/radare2/languages","stargazers_url":"https://api.github.com/repos/radare/radare2/stargazers","contributors_url":"https://api.github.com/repos/radare/radare2/contributors","subscribers_url":"https://api.github.com/repos/radare/radare2/subscribers","subscription_url":"https://api.github.com/repos/radare/radare2/subscription","commits_url":"https://api.github.com/repos/radare/radare2/commits{/sha}","git_commits_url":"https://api.github.com/repos/radare/radare2/git/commits{/sha}","comments_url":"https://api.github.com/repos/radare/radare2/comments{/number}","issue_comment_url":"https://api.github.com/repos/radare/radare2/issues/comments{/number}","contents_url":"https://api.github.com/repos/radare/radare2/contents/{+path}","compare_url":"https://api.github.com/repos/radare/radare2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/radare/radare2/merges","archive_url":"https://api.github.com/repos/radare/radare2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/radare/radare2/downloads","issues_url":"https://api.github.com/repos/radare/radare2/issues{/number}","pulls_url":"https://api.github.com/repos/radare/radare2/pulls{/number}","milestones_url":"https://api.github.com/repos/radare/radare2/milestones{/number}","notifications_url":"https://api.github.com/repos/radare/radare2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/radare/radare2/labels{/name}","releases_url":"https://api.github.com/repos/radare/radare2/releases{/id}","deployments_url":"https://api.github.com/repos/radare/radare2/deployments","created_at":"2012-07-03T07:42:26Z","updated_at":"2016-04-07T06:16:17Z","pushed_at":"2016-04-07T09:19:10Z","git_url":"git://github.com/radare/radare2.git","ssh_url":"git@github.com:radare/radare2.git","clone_url":"https://github.com/radare/radare2.git","svn_url":"https://github.com/radare/radare2","homepage":"http://www.radare.org/","size":72901,"stargazers_count":2454,"watchers_count":2454,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":546,"mirror_url":null,"open_issues_count":677,"forks":546,"open_issues":677,"watchers":2454,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/radare/radare2/pulls/4533"},"html":{"href":"https://github.com/radare/radare2/pull/4533"},"issue":{"href":"https://api.github.com/repos/radare/radare2/issues/4533"},"comments":{"href":"https://api.github.com/repos/radare/radare2/issues/4533/comments"},"review_comments":{"href":"https://api.github.com/repos/radare/radare2/pulls/4533/comments"},"review_comment":{"href":"https://api.github.com/repos/radare/radare2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/radare/radare2/pulls/4533/commits"},"statuses":{"href":"https://api.github.com/repos/radare/radare2/statuses/4a696f3930441aa2ced07897a897955c9b248d6a"}}}}