{"action":"created","comment":{"url":"https://api.github.com/repos/cfengine/core/pulls/comments/80264016","id":80264016,"diff_hunk":"@@ -576,25 +576,47 @@ bool IsInterfaceAddress(const Item *ip_addresses, const char *adr)\n  */\n void ParseHostPort(char *s, char **hostname, char **port)\n {\n-    char *h, *p;                              /* hostname, port temporaries */\n+    char *h, *p;                            // hostname, port temporaries\n \n-    if (s[0] == '[')                           /* IPv6 form: [address]:port */\n+    h = s;\n+    p = NULL;\n+\n+    char *first_colon = strchr(s, ':');\n+    char *first_dot   = strchr(s, '.');\n+\n+    if (s[0] == '[')                       // [host or ip]:port\n     {\n         h = s + 1;\n         p = strchr(h, ']');\n         if (p != NULL)\n         {\n-            *p = '\\0';                           /* '\\0'-terminate hostname */\n-            p = (p[1] == ':') ? p+2 : NULL;\n+            *p = '\\0';                     // '\\0' terminate host name\n+            if (p[1] == ':')               // move port* forward\n+            {\n+                p += 2;\n+            }\n+        }\n+    }\n+    else if ( first_colon == NULL )        // no colon, no port, host correct\n+    {\n+        // Do nothing\n+    }\n+    else if ( first_dot == NULL || first_colon < first_dot )\n+    {\n+        // If only one colon: (cfengine.com:222 or localhost:)\n+        if( strchr(first_colon + 1, ':') == NULL )\n+        {\n+            *first_colon = '\\0';\n+            p = first_colon + 1;\n         }\n+        // Multiple colons means IPv6 address without port, host correct\n     }\n-    else                                       /* normal form: address:port */\n+    else if ( first_dot < first_colon )    // IPv4 or hostname, can have port\n     {\n-        h = s;\n         p = strchr(h, ':');\n         if (p != NULL)\n         {\n-            *p = '\\0';                           /* '\\0'-terminate hostname */\n+            *p = '\\0';                     // '\\0'-terminate hostname\n             p++;\n         }\n     }","path":"libpromises/addr_lib.c","position":54,"original_position":54,"commit_id":"ee24caa987025fe0b729532f331eeab4ef8e1a52","original_commit_id":"e579124422e352c021a65036dd005bad6e8fb23e","user":{"login":"jimis","id":3584514,"avatar_url":"https://avatars.githubusercontent.com/u/3584514?v=3","gravatar_id":"","url":"https://api.github.com/users/jimis","html_url":"https://github.com/jimis","followers_url":"https://api.github.com/users/jimis/followers","following_url":"https://api.github.com/users/jimis/following{/other_user}","gists_url":"https://api.github.com/users/jimis/gists{/gist_id}","starred_url":"https://api.github.com/users/jimis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimis/subscriptions","organizations_url":"https://api.github.com/users/jimis/orgs","repos_url":"https://api.github.com/users/jimis/repos","events_url":"https://api.github.com/users/jimis/events{/privacy}","received_events_url":"https://api.github.com/users/jimis/received_events","type":"User","site_admin":false},"body":"I ended up changing this to an `else` and `assert()`ing that we are handling the right case. So there is no way there is an unhandled branch.","created_at":"2016-09-23T15:09:18Z","updated_at":"2016-09-23T15:09:18Z","html_url":"https://github.com/cfengine/core/pull/2687#discussion_r80264016","pull_request_url":"https://api.github.com/repos/cfengine/core/pulls/2687","_links":{"self":{"href":"https://api.github.com/repos/cfengine/core/pulls/comments/80264016"},"html":{"href":"https://github.com/cfengine/core/pull/2687#discussion_r80264016"},"pull_request":{"href":"https://api.github.com/repos/cfengine/core/pulls/2687"}}},"pull_request":{"url":"https://api.github.com/repos/cfengine/core/pulls/2687","id":85859892,"html_url":"https://github.com/cfengine/core/pull/2687","diff_url":"https://github.com/cfengine/core/pull/2687.diff","patch_url":"https://github.com/cfengine/core/pull/2687.patch","issue_url":"https://api.github.com/repos/cfengine/core/issues/2687","number":2687,"state":"closed","locked":false,"title":"CFE-546 Fixed parsing of host name/IP and port number in cf-runagent","user":{"login":"olehermanse","id":4048546,"avatar_url":"https://avatars.githubusercontent.com/u/4048546?v=3","gravatar_id":"","url":"https://api.github.com/users/olehermanse","html_url":"https://github.com/olehermanse","followers_url":"https://api.github.com/users/olehermanse/followers","following_url":"https://api.github.com/users/olehermanse/following{/other_user}","gists_url":"https://api.github.com/users/olehermanse/gists{/gist_id}","starred_url":"https://api.github.com/users/olehermanse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olehermanse/subscriptions","organizations_url":"https://api.github.com/users/olehermanse/orgs","repos_url":"https://api.github.com/users/olehermanse/repos","events_url":"https://api.github.com/users/olehermanse/events{/privacy}","received_events_url":"https://api.github.com/users/olehermanse/received_events","type":"User","site_admin":false},"body":"This fixes CFE-546. Added some more tests, the new parser should work for most weird cases.","created_at":"2016-09-19T20:05:54Z","updated_at":"2016-09-23T15:09:18Z","closed_at":"2016-09-23T15:06:56Z","merged_at":null,"merge_commit_sha":"b3f912ee7ca3b0b5803043ef1ae099d1d055301d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cfengine/core/pulls/2687/commits","review_comments_url":"https://api.github.com/repos/cfengine/core/pulls/2687/comments","review_comment_url":"https://api.github.com/repos/cfengine/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cfengine/core/issues/2687/comments","statuses_url":"https://api.github.com/repos/cfengine/core/statuses/ee24caa987025fe0b729532f331eeab4ef8e1a52","head":{"label":"olehermanse:CFE-546","ref":"CFE-546","sha":"ee24caa987025fe0b729532f331eeab4ef8e1a52","user":{"login":"olehermanse","id":4048546,"avatar_url":"https://avatars.githubusercontent.com/u/4048546?v=3","gravatar_id":"","url":"https://api.github.com/users/olehermanse","html_url":"https://github.com/olehermanse","followers_url":"https://api.github.com/users/olehermanse/followers","following_url":"https://api.github.com/users/olehermanse/following{/other_user}","gists_url":"https://api.github.com/users/olehermanse/gists{/gist_id}","starred_url":"https://api.github.com/users/olehermanse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olehermanse/subscriptions","organizations_url":"https://api.github.com/users/olehermanse/orgs","repos_url":"https://api.github.com/users/olehermanse/repos","events_url":"https://api.github.com/users/olehermanse/events{/privacy}","received_events_url":"https://api.github.com/users/olehermanse/received_events","type":"User","site_admin":false},"repo":{"id":66275830,"name":"core","full_name":"olehermanse/core","owner":{"login":"olehermanse","id":4048546,"avatar_url":"https://avatars.githubusercontent.com/u/4048546?v=3","gravatar_id":"","url":"https://api.github.com/users/olehermanse","html_url":"https://github.com/olehermanse","followers_url":"https://api.github.com/users/olehermanse/followers","following_url":"https://api.github.com/users/olehermanse/following{/other_user}","gists_url":"https://api.github.com/users/olehermanse/gists{/gist_id}","starred_url":"https://api.github.com/users/olehermanse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olehermanse/subscriptions","organizations_url":"https://api.github.com/users/olehermanse/orgs","repos_url":"https://api.github.com/users/olehermanse/repos","events_url":"https://api.github.com/users/olehermanse/events{/privacy}","received_events_url":"https://api.github.com/users/olehermanse/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/olehermanse/core","description":"CFEngine Community","fork":true,"url":"https://api.github.com/repos/olehermanse/core","forks_url":"https://api.github.com/repos/olehermanse/core/forks","keys_url":"https://api.github.com/repos/olehermanse/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/olehermanse/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/olehermanse/core/teams","hooks_url":"https://api.github.com/repos/olehermanse/core/hooks","issue_events_url":"https://api.github.com/repos/olehermanse/core/issues/events{/number}","events_url":"https://api.github.com/repos/olehermanse/core/events","assignees_url":"https://api.github.com/repos/olehermanse/core/assignees{/user}","branches_url":"https://api.github.com/repos/olehermanse/core/branches{/branch}","tags_url":"https://api.github.com/repos/olehermanse/core/tags","blobs_url":"https://api.github.com/repos/olehermanse/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/olehermanse/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/olehermanse/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/olehermanse/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/olehermanse/core/statuses/{sha}","languages_url":"https://api.github.com/repos/olehermanse/core/languages","stargazers_url":"https://api.github.com/repos/olehermanse/core/stargazers","contributors_url":"https://api.github.com/repos/olehermanse/core/contributors","subscribers_url":"https://api.github.com/repos/olehermanse/core/subscribers","subscription_url":"https://api.github.com/repos/olehermanse/core/subscription","commits_url":"https://api.github.com/repos/olehermanse/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/olehermanse/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/olehermanse/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/olehermanse/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/olehermanse/core/contents/{+path}","compare_url":"https://api.github.com/repos/olehermanse/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/olehermanse/core/merges","archive_url":"https://api.github.com/repos/olehermanse/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/olehermanse/core/downloads","issues_url":"https://api.github.com/repos/olehermanse/core/issues{/number}","pulls_url":"https://api.github.com/repos/olehermanse/core/pulls{/number}","milestones_url":"https://api.github.com/repos/olehermanse/core/milestones{/number}","notifications_url":"https://api.github.com/repos/olehermanse/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/olehermanse/core/labels{/name}","releases_url":"https://api.github.com/repos/olehermanse/core/releases{/id}","deployments_url":"https://api.github.com/repos/olehermanse/core/deployments","created_at":"2016-08-22T13:38:09Z","updated_at":"2016-09-05T11:52:31Z","pushed_at":"2016-09-21T13:30:21Z","git_url":"git://github.com/olehermanse/core.git","ssh_url":"git@github.com:olehermanse/core.git","clone_url":"https://github.com/olehermanse/core.git","svn_url":"https://github.com/olehermanse/core","homepage":"https://cfengine.com/community/","size":55907,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"cfengine:master","ref":"master","sha":"b6e08bd98e2504ffd126d961d623b3cddc519ce6","user":{"login":"cfengine","id":1239823,"avatar_url":"https://avatars.githubusercontent.com/u/1239823?v=3","gravatar_id":"","url":"https://api.github.com/users/cfengine","html_url":"https://github.com/cfengine","followers_url":"https://api.github.com/users/cfengine/followers","following_url":"https://api.github.com/users/cfengine/following{/other_user}","gists_url":"https://api.github.com/users/cfengine/gists{/gist_id}","starred_url":"https://api.github.com/users/cfengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfengine/subscriptions","organizations_url":"https://api.github.com/users/cfengine/orgs","repos_url":"https://api.github.com/users/cfengine/repos","events_url":"https://api.github.com/users/cfengine/events{/privacy}","received_events_url":"https://api.github.com/users/cfengine/received_events","type":"Organization","site_admin":false},"repo":{"id":3543548,"name":"core","full_name":"cfengine/core","owner":{"login":"cfengine","id":1239823,"avatar_url":"https://avatars.githubusercontent.com/u/1239823?v=3","gravatar_id":"","url":"https://api.github.com/users/cfengine","html_url":"https://github.com/cfengine","followers_url":"https://api.github.com/users/cfengine/followers","following_url":"https://api.github.com/users/cfengine/following{/other_user}","gists_url":"https://api.github.com/users/cfengine/gists{/gist_id}","starred_url":"https://api.github.com/users/cfengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfengine/subscriptions","organizations_url":"https://api.github.com/users/cfengine/orgs","repos_url":"https://api.github.com/users/cfengine/repos","events_url":"https://api.github.com/users/cfengine/events{/privacy}","received_events_url":"https://api.github.com/users/cfengine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cfengine/core","description":"CFEngine Community","fork":false,"url":"https://api.github.com/repos/cfengine/core","forks_url":"https://api.github.com/repos/cfengine/core/forks","keys_url":"https://api.github.com/repos/cfengine/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cfengine/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cfengine/core/teams","hooks_url":"https://api.github.com/repos/cfengine/core/hooks","issue_events_url":"https://api.github.com/repos/cfengine/core/issues/events{/number}","events_url":"https://api.github.com/repos/cfengine/core/events","assignees_url":"https://api.github.com/repos/cfengine/core/assignees{/user}","branches_url":"https://api.github.com/repos/cfengine/core/branches{/branch}","tags_url":"https://api.github.com/repos/cfengine/core/tags","blobs_url":"https://api.github.com/repos/cfengine/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cfengine/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cfengine/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/cfengine/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cfengine/core/statuses/{sha}","languages_url":"https://api.github.com/repos/cfengine/core/languages","stargazers_url":"https://api.github.com/repos/cfengine/core/stargazers","contributors_url":"https://api.github.com/repos/cfengine/core/contributors","subscribers_url":"https://api.github.com/repos/cfengine/core/subscribers","subscription_url":"https://api.github.com/repos/cfengine/core/subscription","commits_url":"https://api.github.com/repos/cfengine/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/cfengine/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/cfengine/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/cfengine/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/cfengine/core/contents/{+path}","compare_url":"https://api.github.com/repos/cfengine/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cfengine/core/merges","archive_url":"https://api.github.com/repos/cfengine/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cfengine/core/downloads","issues_url":"https://api.github.com/repos/cfengine/core/issues{/number}","pulls_url":"https://api.github.com/repos/cfengine/core/pulls{/number}","milestones_url":"https://api.github.com/repos/cfengine/core/milestones{/number}","notifications_url":"https://api.github.com/repos/cfengine/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cfengine/core/labels{/name}","releases_url":"https://api.github.com/repos/cfengine/core/releases{/id}","deployments_url":"https://api.github.com/repos/cfengine/core/deployments","created_at":"2012-02-25T09:19:05Z","updated_at":"2016-09-19T18:24:39Z","pushed_at":"2016-09-23T15:06:24Z","git_url":"git://github.com/cfengine/core.git","ssh_url":"git@github.com:cfengine/core.git","clone_url":"https://github.com/cfengine/core.git","svn_url":"https://github.com/cfengine/core","homepage":"https://cfengine.com/community/","size":71429,"stargazers_count":245,"watchers_count":245,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":153,"mirror_url":null,"open_issues_count":33,"forks":153,"open_issues":33,"watchers":245,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cfengine/core/pulls/2687"},"html":{"href":"https://github.com/cfengine/core/pull/2687"},"issue":{"href":"https://api.github.com/repos/cfengine/core/issues/2687"},"comments":{"href":"https://api.github.com/repos/cfengine/core/issues/2687/comments"},"review_comments":{"href":"https://api.github.com/repos/cfengine/core/pulls/2687/comments"},"review_comment":{"href":"https://api.github.com/repos/cfengine/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cfengine/core/pulls/2687/commits"},"statuses":{"href":"https://api.github.com/repos/cfengine/core/statuses/ee24caa987025fe0b729532f331eeab4ef8e1a52"}}}}
{"actor":{"display_login":"jimis"}}