{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/kura/pulls/comments/88451720","pull_request_review_id":9023917,"id":88451720,"diff_hunk":"@@ -124,72 +107,127 @@ public static int convertIp4Address(String ipAddress) {\n         return NetworkUtil.packIp4AddressBytes(addressBytes);\n     }\n \n-    public static int packIp4AddressBytes(short[] bytes) {\n+    public static int packIp4AddressBytes(short[] bytes) throws KuraException {\n+        if ((bytes == null) || (bytes.length != 4)) {\n+            throw new KuraException(KuraErrorCode.INVALID_PARAMETER);\n+        }\n+        \n         int val = 0;\n-        for (int i = 3; i >= 0; i--) {\n+        for (int i = 0; i < 4; i++) {\n+            if ((bytes[i] < 0) || (bytes[i] > 255)) {\n+                throw new KuraException(KuraErrorCode.INVALID_PARAMETER);\n+            }\n+            \n             val = val << 8;\n             val |= bytes[i];\n         }\n         return val;\n     }\n \n     public static short[] unpackIP4AddressInt(int address) {\n-        return new short[] { (short) (address & 0xFF), (short) (address >> 8 & 0xFF), (short) (address >> 16 & 0xFF),\n-                (short) (address >> 24 & 0xFF) };\n+        short[] addressBytes = new short[4];\n+        int value = address;\n+        \n+        for (int i = 3; i >= 0; i--) {\n+            addressBytes[i] = (short)(value & 0xFF);\n+            value = value >>> 8;\n+        }\n+        \n+        return addressBytes;\n     }\n \n-    public static byte[] convertIP6Address(String fullFormIP6Address) {\n+    public static byte[] convertIP6Address(String fullFormIP6Address) throws KuraException {\n+        if (fullFormIP6Address == null) {\n+            throw new KuraException(KuraErrorCode.INVALID_PARAMETER);\n+        }\n+\n         byte[] retVal = new byte[16];\n         String[] ip6Split = fullFormIP6Address.split(\":\");\n-        for (int i = 0; i < 8; i++) {\n-            ;\n-            String octet = ip6Split[i];\n-            StringBuffer sb = new StringBuffer();\n \n-            while (sb.length() + octet.length() < 4) {\n-                sb.append(\"0\");\n-            }\n-            sb.append(octet);\n+        if (ip6Split.length != 8) {\n+            throw new KuraException(KuraErrorCode.INVALID_PARAMETER);\n+        }\n \n-            retVal[i * 2] = (byte) Short.parseShort(sb.toString().substring(0, 2), 16);\n-            retVal[i * 2 + 1] = (byte) Short.parseShort(sb.toString().substring(2, 4), 16);\n+        for (int i = 0; i < 8; i++) {\n+            try {\n+                String octet = ip6Split[i];\n+                int value = Integer.parseInt(octet, 16);\n+                \n+                if ((value < 0) || (value > 0xFFFF))\n+                {\n+                    throw new KuraException(KuraErrorCode.INVALID_PARAMETER);\n+                }\n+                \n+                int k = i * 2;\n+                retVal[k] = (byte) ((value >>> 8) & 0xFF);\n+                retVal[k + 1] = (byte) (value & 0xFF);\n+            } catch (NumberFormatException e) {\n+                throw new KuraException(KuraErrorCode.INVALID_PARAMETER);\n+            }","path":"kura/org.eclipse.kura.core.net/src/main/java/org/eclipse/kura/core/net/util/NetworkUtil.java","position":189,"original_position":189,"commit_id":"c7bbbbea523d5de2c648a0e21265f771d8a023eb","original_commit_id":"c7bbbbea523d5de2c648a0e21265f771d8a023eb","user":{"login":"amitjoy","id":13380182,"avatar_url":"https://avatars.githubusercontent.com/u/13380182?v=3","gravatar_id":"","url":"https://api.github.com/users/amitjoy","html_url":"https://github.com/amitjoy","followers_url":"https://api.github.com/users/amitjoy/followers","following_url":"https://api.github.com/users/amitjoy/following{/other_user}","gists_url":"https://api.github.com/users/amitjoy/gists{/gist_id}","starred_url":"https://api.github.com/users/amitjoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitjoy/subscriptions","organizations_url":"https://api.github.com/users/amitjoy/orgs","repos_url":"https://api.github.com/users/amitjoy/repos","events_url":"https://api.github.com/users/amitjoy/events{/privacy}","received_events_url":"https://api.github.com/users/amitjoy/received_events","type":"User","site_admin":false},"body":"Same here. Runtime Exception.","created_at":"2016-11-17T13:34:09Z","updated_at":"2016-11-17T13:49:38Z","html_url":"https://github.com/eclipse/kura/pull/781#discussion_r88451720","pull_request_url":"https://api.github.com/repos/eclipse/kura/pulls/781","_links":{"self":{"href":"https://api.github.com/repos/eclipse/kura/pulls/comments/88451720"},"html":{"href":"https://github.com/eclipse/kura/pull/781#discussion_r88451720"},"pull_request":{"href":"https://api.github.com/repos/eclipse/kura/pulls/781"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/kura/pulls/781","id":94166619,"html_url":"https://github.com/eclipse/kura/pull/781","diff_url":"https://github.com/eclipse/kura/pull/781.diff","patch_url":"https://github.com/eclipse/kura/pull/781.patch","issue_url":"https://api.github.com/repos/eclipse/kura/issues/781","number":781,"state":"open","locked":false,"title":"issue #778: Refactored NetworkUtil class","user":{"login":"djurod","id":23033705,"avatar_url":"https://avatars.githubusercontent.com/u/23033705?v=3","gravatar_id":"","url":"https://api.github.com/users/djurod","html_url":"https://github.com/djurod","followers_url":"https://api.github.com/users/djurod/followers","following_url":"https://api.github.com/users/djurod/following{/other_user}","gists_url":"https://api.github.com/users/djurod/gists{/gist_id}","starred_url":"https://api.github.com/users/djurod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djurod/subscriptions","organizations_url":"https://api.github.com/users/djurod/orgs","repos_url":"https://api.github.com/users/djurod/repos","events_url":"https://api.github.com/users/djurod/events{/privacy}","received_events_url":"https://api.github.com/users/djurod/received_events","type":"User","site_admin":false},"body":"Changes:\r\n* Removed code duplication.\r\n* Added checking of inputs: a KuraException is thrown in case of invalid\r\n  inputs.\r\n* Fixed the byte order in conversion of IP addresses.\r\n* Code cleanup.\r\n\r\nSigned-off-by: Djuro Drljaca <djuro.drljaca@comtrade.com>","created_at":"2016-11-17T13:26:39Z","updated_at":"2016-11-17T13:49:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70af7c60fd7901f16bc331ad7228d880465491a0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/kura/pulls/781/commits","review_comments_url":"https://api.github.com/repos/eclipse/kura/pulls/781/comments","review_comment_url":"https://api.github.com/repos/eclipse/kura/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/kura/issues/781/comments","statuses_url":"https://api.github.com/repos/eclipse/kura/statuses/c7bbbbea523d5de2c648a0e21265f771d8a023eb","head":{"label":"djurod:PR-Refactor-NetworkUtil","ref":"PR-Refactor-NetworkUtil","sha":"c7bbbbea523d5de2c648a0e21265f771d8a023eb","user":{"login":"djurod","id":23033705,"avatar_url":"https://avatars.githubusercontent.com/u/23033705?v=3","gravatar_id":"","url":"https://api.github.com/users/djurod","html_url":"https://github.com/djurod","followers_url":"https://api.github.com/users/djurod/followers","following_url":"https://api.github.com/users/djurod/following{/other_user}","gists_url":"https://api.github.com/users/djurod/gists{/gist_id}","starred_url":"https://api.github.com/users/djurod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djurod/subscriptions","organizations_url":"https://api.github.com/users/djurod/orgs","repos_url":"https://api.github.com/users/djurod/repos","events_url":"https://api.github.com/users/djurod/events{/privacy}","received_events_url":"https://api.github.com/users/djurod/received_events","type":"User","site_admin":false},"repo":{"id":74007380,"name":"kura","full_name":"djurod/kura","owner":{"login":"djurod","id":23033705,"avatar_url":"https://avatars.githubusercontent.com/u/23033705?v=3","gravatar_id":"","url":"https://api.github.com/users/djurod","html_url":"https://github.com/djurod","followers_url":"https://api.github.com/users/djurod/followers","following_url":"https://api.github.com/users/djurod/following{/other_user}","gists_url":"https://api.github.com/users/djurod/gists{/gist_id}","starred_url":"https://api.github.com/users/djurod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djurod/subscriptions","organizations_url":"https://api.github.com/users/djurod/orgs","repos_url":"https://api.github.com/users/djurod/repos","events_url":"https://api.github.com/users/djurod/events{/privacy}","received_events_url":"https://api.github.com/users/djurod/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/djurod/kura","description":"Eclipse Kura™ project - http://eclipse.org/kura","fork":true,"url":"https://api.github.com/repos/djurod/kura","forks_url":"https://api.github.com/repos/djurod/kura/forks","keys_url":"https://api.github.com/repos/djurod/kura/keys{/key_id}","collaborators_url":"https://api.github.com/repos/djurod/kura/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/djurod/kura/teams","hooks_url":"https://api.github.com/repos/djurod/kura/hooks","issue_events_url":"https://api.github.com/repos/djurod/kura/issues/events{/number}","events_url":"https://api.github.com/repos/djurod/kura/events","assignees_url":"https://api.github.com/repos/djurod/kura/assignees{/user}","branches_url":"https://api.github.com/repos/djurod/kura/branches{/branch}","tags_url":"https://api.github.com/repos/djurod/kura/tags","blobs_url":"https://api.github.com/repos/djurod/kura/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/djurod/kura/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/djurod/kura/git/refs{/sha}","trees_url":"https://api.github.com/repos/djurod/kura/git/trees{/sha}","statuses_url":"https://api.github.com/repos/djurod/kura/statuses/{sha}","languages_url":"https://api.github.com/repos/djurod/kura/languages","stargazers_url":"https://api.github.com/repos/djurod/kura/stargazers","contributors_url":"https://api.github.com/repos/djurod/kura/contributors","subscribers_url":"https://api.github.com/repos/djurod/kura/subscribers","subscription_url":"https://api.github.com/repos/djurod/kura/subscription","commits_url":"https://api.github.com/repos/djurod/kura/commits{/sha}","git_commits_url":"https://api.github.com/repos/djurod/kura/git/commits{/sha}","comments_url":"https://api.github.com/repos/djurod/kura/comments{/number}","issue_comment_url":"https://api.github.com/repos/djurod/kura/issues/comments{/number}","contents_url":"https://api.github.com/repos/djurod/kura/contents/{+path}","compare_url":"https://api.github.com/repos/djurod/kura/compare/{base}...{head}","merges_url":"https://api.github.com/repos/djurod/kura/merges","archive_url":"https://api.github.com/repos/djurod/kura/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/djurod/kura/downloads","issues_url":"https://api.github.com/repos/djurod/kura/issues{/number}","pulls_url":"https://api.github.com/repos/djurod/kura/pulls{/number}","milestones_url":"https://api.github.com/repos/djurod/kura/milestones{/number}","notifications_url":"https://api.github.com/repos/djurod/kura/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/djurod/kura/labels{/name}","releases_url":"https://api.github.com/repos/djurod/kura/releases{/id}","deployments_url":"https://api.github.com/repos/djurod/kura/deployments","created_at":"2016-11-17T08:42:01Z","updated_at":"2016-11-17T08:42:10Z","pushed_at":"2016-11-17T13:23:15Z","git_url":"git://github.com/djurod/kura.git","ssh_url":"git@github.com:djurod/kura.git","clone_url":"https://github.com/djurod/kura.git","svn_url":"https://github.com/djurod/kura","homepage":"","size":105976,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"develop"}},"base":{"label":"eclipse:develop","ref":"develop","sha":"d1ed0d0cae4366b8f34ec5d7d4580ad6e30391d0","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":15237269,"name":"kura","full_name":"eclipse/kura","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/kura","description":"Eclipse Kura™ project - http://eclipse.org/kura","fork":false,"url":"https://api.github.com/repos/eclipse/kura","forks_url":"https://api.github.com/repos/eclipse/kura/forks","keys_url":"https://api.github.com/repos/eclipse/kura/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/kura/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/kura/teams","hooks_url":"https://api.github.com/repos/eclipse/kura/hooks","issue_events_url":"https://api.github.com/repos/eclipse/kura/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/kura/events","assignees_url":"https://api.github.com/repos/eclipse/kura/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/kura/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/kura/tags","blobs_url":"https://api.github.com/repos/eclipse/kura/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/kura/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/kura/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/kura/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/kura/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/kura/languages","stargazers_url":"https://api.github.com/repos/eclipse/kura/stargazers","contributors_url":"https://api.github.com/repos/eclipse/kura/contributors","subscribers_url":"https://api.github.com/repos/eclipse/kura/subscribers","subscription_url":"https://api.github.com/repos/eclipse/kura/subscription","commits_url":"https://api.github.com/repos/eclipse/kura/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/kura/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/kura/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/kura/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/kura/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/kura/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/kura/merges","archive_url":"https://api.github.com/repos/eclipse/kura/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/kura/downloads","issues_url":"https://api.github.com/repos/eclipse/kura/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/kura/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/kura/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/kura/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/kura/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/kura/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/kura/deployments","created_at":"2013-12-16T21:07:20Z","updated_at":"2016-11-15T02:20:02Z","pushed_at":"2016-11-17T13:42:03Z","git_url":"git://github.com/eclipse/kura.git","ssh_url":"git@github.com:eclipse/kura.git","clone_url":"https://github.com/eclipse/kura.git","svn_url":"https://github.com/eclipse/kura","homepage":"","size":106000,"stargazers_count":120,"watchers_count":120,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":101,"mirror_url":null,"open_issues_count":179,"forks":101,"open_issues":179,"watchers":120,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/kura/pulls/781"},"html":{"href":"https://github.com/eclipse/kura/pull/781"},"issue":{"href":"https://api.github.com/repos/eclipse/kura/issues/781"},"comments":{"href":"https://api.github.com/repos/eclipse/kura/issues/781/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/kura/pulls/781/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/kura/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/kura/pulls/781/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/kura/statuses/c7bbbbea523d5de2c648a0e21265f771d8a023eb"}}}}
{"actor":{"display_login":"amitjoy"}}