{"action":"created","comment":{"url":"https://api.github.com/repos/jpr5/ngrep/pulls/comments/37693146","id":37693146,"diff_hunk":"@@ -1557,4 +1573,27 @@ char *win32_choosedevice(void) {\n }\n #endif\n \n+/* Parse an unsigned long, exit program if anything goes wrong. */\n+unsigned long parseulong(const char *s) {\n+    unsigned long n = 0;\n+    char *end = NULL;\n \n+    errno = 0;\n+    n = strtoul(s, &end, 0);\n+\n+    if (errno != 0 || *s == '\\0' || end == NULL || *end != '\\0') {\n+        if (errno != 0) { /* GNU strtoul will set errno. */\n+            perror(\"strtoul\");\n+        }\n+        fprintf(stderr, \"Could not convert unsigned long: `%s'.\\n\", s);\n+\n+        clean_exit(-1);\n+    }\n+\n+    return n;\n+}\n+\n+void dierange(char *msg, unsigned long value) {\n+    fprintf(stderr, \"`%s': value `%lu' is out of range.\\n\", msg, value);","path":"ngrep.c","position":125,"original_position":125,"commit_id":"210ede35e65fca8ea3df7ed1b90bdff4cc100f80","original_commit_id":"210ede35e65fca8ea3df7ed1b90bdff4cc100f80","user":{"login":"jpiccari","id":768990,"avatar_url":"https://avatars.githubusercontent.com/u/768990?v=3","gravatar_id":"","url":"https://api.github.com/users/jpiccari","html_url":"https://github.com/jpiccari","followers_url":"https://api.github.com/users/jpiccari/followers","following_url":"https://api.github.com/users/jpiccari/following{/other_user}","gists_url":"https://api.github.com/users/jpiccari/gists{/gist_id}","starred_url":"https://api.github.com/users/jpiccari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpiccari/subscriptions","organizations_url":"https://api.github.com/users/jpiccari/orgs","repos_url":"https://api.github.com/users/jpiccari/repos","events_url":"https://api.github.com/users/jpiccari/events{/privacy}","received_events_url":"https://api.github.com/users/jpiccari/received_events","type":"User","site_admin":false},"body":"If this routine expected a character array as the second parameter I think the feedback would be more valuable since in some cases we won't be able to output `value` properly as an `unsigned long`.","created_at":"2015-08-22T06:10:55Z","updated_at":"2015-08-22T06:10:55Z","html_url":"https://github.com/jpr5/ngrep/pull/3#discussion_r37693146","pull_request_url":"https://api.github.com/repos/jpr5/ngrep/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/jpr5/ngrep/pulls/comments/37693146"},"html":{"href":"https://github.com/jpr5/ngrep/pull/3#discussion_r37693146"},"pull_request":{"href":"https://api.github.com/repos/jpr5/ngrep/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/jpr5/ngrep/pulls/3","id":39587803,"html_url":"https://github.com/jpr5/ngrep/pull/3","diff_url":"https://github.com/jpr5/ngrep/pull/3.diff","patch_url":"https://github.com/jpr5/ngrep/pull/3.patch","issue_url":"https://api.github.com/repos/jpr5/ngrep/issues/3","number":3,"state":"open","locked":false,"title":"Expand integer range","user":{"login":"haguenau","id":3029165,"avatar_url":"https://avatars.githubusercontent.com/u/3029165?v=3","gravatar_id":"","url":"https://api.github.com/users/haguenau","html_url":"https://github.com/haguenau","followers_url":"https://api.github.com/users/haguenau/followers","following_url":"https://api.github.com/users/haguenau/following{/other_user}","gists_url":"https://api.github.com/users/haguenau/gists{/gist_id}","starred_url":"https://api.github.com/users/haguenau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haguenau/subscriptions","organizations_url":"https://api.github.com/users/haguenau/orgs","repos_url":"https://api.github.com/users/haguenau/repos","events_url":"https://api.github.com/users/haguenau/events{/privacy}","received_events_url":"https://api.github.com/users/haguenau/received_events","type":"User","site_admin":false},"body":"The published version of ngrep appears to have to small issues:\r\n\r\n* The range for many integral options is small because the underlying type is a 16-bit unsigned (so it's impossible to ask to capture 100000 packets using `-n`, for example);\r\n\r\n* the option-parsing code does not check for overflow conditions, resulting in silent wraparound (so that asking to capture exactly 128K packets will be the same as `-n 0`: no limit to how many packets will be captured).\r\n\r\nThis change set:\r\n\r\n* switches the type for many counters to unsigned long, so that it's at least 32 bits;\r\n* checks command line values for syntactic correctness and range, and errors out if needed.","created_at":"2015-07-09T14:17:59Z","updated_at":"2015-08-22T06:10:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d93a07a57c99d4ff550bcb0afa18c7e1ed44b3c3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jpr5/ngrep/pulls/3/commits","review_comments_url":"https://api.github.com/repos/jpr5/ngrep/pulls/3/comments","review_comment_url":"https://api.github.com/repos/jpr5/ngrep/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jpr5/ngrep/issues/3/comments","statuses_url":"https://api.github.com/repos/jpr5/ngrep/statuses/210ede35e65fca8ea3df7ed1b90bdff4cc100f80","head":{"label":"haguenau:expand-integer-range","ref":"expand-integer-range","sha":"210ede35e65fca8ea3df7ed1b90bdff4cc100f80","user":{"login":"haguenau","id":3029165,"avatar_url":"https://avatars.githubusercontent.com/u/3029165?v=3","gravatar_id":"","url":"https://api.github.com/users/haguenau","html_url":"https://github.com/haguenau","followers_url":"https://api.github.com/users/haguenau/followers","following_url":"https://api.github.com/users/haguenau/following{/other_user}","gists_url":"https://api.github.com/users/haguenau/gists{/gist_id}","starred_url":"https://api.github.com/users/haguenau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haguenau/subscriptions","organizations_url":"https://api.github.com/users/haguenau/orgs","repos_url":"https://api.github.com/users/haguenau/repos","events_url":"https://api.github.com/users/haguenau/events{/privacy}","received_events_url":"https://api.github.com/users/haguenau/received_events","type":"User","site_admin":false},"repo":{"id":38775936,"name":"ngrep","full_name":"haguenau/ngrep","owner":{"login":"haguenau","id":3029165,"avatar_url":"https://avatars.githubusercontent.com/u/3029165?v=3","gravatar_id":"","url":"https://api.github.com/users/haguenau","html_url":"https://github.com/haguenau","followers_url":"https://api.github.com/users/haguenau/followers","following_url":"https://api.github.com/users/haguenau/following{/other_user}","gists_url":"https://api.github.com/users/haguenau/gists{/gist_id}","starred_url":"https://api.github.com/users/haguenau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haguenau/subscriptions","organizations_url":"https://api.github.com/users/haguenau/orgs","repos_url":"https://api.github.com/users/haguenau/repos","events_url":"https://api.github.com/users/haguenau/events{/privacy}","received_events_url":"https://api.github.com/users/haguenau/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/haguenau/ngrep","description":"ngrep strives to provide most of GNU grep's common features, applying them to the network layer. ngrep is a pcap-aware tool that will allow you to specify extended regular expressions to match against data payloads of packets.","fork":true,"url":"https://api.github.com/repos/haguenau/ngrep","forks_url":"https://api.github.com/repos/haguenau/ngrep/forks","keys_url":"https://api.github.com/repos/haguenau/ngrep/keys{/key_id}","collaborators_url":"https://api.github.com/repos/haguenau/ngrep/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/haguenau/ngrep/teams","hooks_url":"https://api.github.com/repos/haguenau/ngrep/hooks","issue_events_url":"https://api.github.com/repos/haguenau/ngrep/issues/events{/number}","events_url":"https://api.github.com/repos/haguenau/ngrep/events","assignees_url":"https://api.github.com/repos/haguenau/ngrep/assignees{/user}","branches_url":"https://api.github.com/repos/haguenau/ngrep/branches{/branch}","tags_url":"https://api.github.com/repos/haguenau/ngrep/tags","blobs_url":"https://api.github.com/repos/haguenau/ngrep/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/haguenau/ngrep/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/haguenau/ngrep/git/refs{/sha}","trees_url":"https://api.github.com/repos/haguenau/ngrep/git/trees{/sha}","statuses_url":"https://api.github.com/repos/haguenau/ngrep/statuses/{sha}","languages_url":"https://api.github.com/repos/haguenau/ngrep/languages","stargazers_url":"https://api.github.com/repos/haguenau/ngrep/stargazers","contributors_url":"https://api.github.com/repos/haguenau/ngrep/contributors","subscribers_url":"https://api.github.com/repos/haguenau/ngrep/subscribers","subscription_url":"https://api.github.com/repos/haguenau/ngrep/subscription","commits_url":"https://api.github.com/repos/haguenau/ngrep/commits{/sha}","git_commits_url":"https://api.github.com/repos/haguenau/ngrep/git/commits{/sha}","comments_url":"https://api.github.com/repos/haguenau/ngrep/comments{/number}","issue_comment_url":"https://api.github.com/repos/haguenau/ngrep/issues/comments{/number}","contents_url":"https://api.github.com/repos/haguenau/ngrep/contents/{+path}","compare_url":"https://api.github.com/repos/haguenau/ngrep/compare/{base}...{head}","merges_url":"https://api.github.com/repos/haguenau/ngrep/merges","archive_url":"https://api.github.com/repos/haguenau/ngrep/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/haguenau/ngrep/downloads","issues_url":"https://api.github.com/repos/haguenau/ngrep/issues{/number}","pulls_url":"https://api.github.com/repos/haguenau/ngrep/pulls{/number}","milestones_url":"https://api.github.com/repos/haguenau/ngrep/milestones{/number}","notifications_url":"https://api.github.com/repos/haguenau/ngrep/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/haguenau/ngrep/labels{/name}","releases_url":"https://api.github.com/repos/haguenau/ngrep/releases{/id}","created_at":"2015-07-08T19:43:53Z","updated_at":"2015-07-08T19:43:54Z","pushed_at":"2015-07-09T14:09:01Z","git_url":"git://github.com/haguenau/ngrep.git","ssh_url":"git@github.com:haguenau/ngrep.git","clone_url":"https://github.com/haguenau/ngrep.git","svn_url":"https://github.com/haguenau/ngrep","homepage":"http://ngrep.sf.net","size":1822,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"jpr5:master","ref":"master","sha":"fb9310c60e1fd607a2e14e8449d089ff2a582c06","user":{"login":"jpr5","id":86957,"avatar_url":"https://avatars.githubusercontent.com/u/86957?v=3","gravatar_id":"","url":"https://api.github.com/users/jpr5","html_url":"https://github.com/jpr5","followers_url":"https://api.github.com/users/jpr5/followers","following_url":"https://api.github.com/users/jpr5/following{/other_user}","gists_url":"https://api.github.com/users/jpr5/gists{/gist_id}","starred_url":"https://api.github.com/users/jpr5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpr5/subscriptions","organizations_url":"https://api.github.com/users/jpr5/orgs","repos_url":"https://api.github.com/users/jpr5/repos","events_url":"https://api.github.com/users/jpr5/events{/privacy}","received_events_url":"https://api.github.com/users/jpr5/received_events","type":"User","site_admin":false},"repo":{"id":453178,"name":"ngrep","full_name":"jpr5/ngrep","owner":{"login":"jpr5","id":86957,"avatar_url":"https://avatars.githubusercontent.com/u/86957?v=3","gravatar_id":"","url":"https://api.github.com/users/jpr5","html_url":"https://github.com/jpr5","followers_url":"https://api.github.com/users/jpr5/followers","following_url":"https://api.github.com/users/jpr5/following{/other_user}","gists_url":"https://api.github.com/users/jpr5/gists{/gist_id}","starred_url":"https://api.github.com/users/jpr5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpr5/subscriptions","organizations_url":"https://api.github.com/users/jpr5/orgs","repos_url":"https://api.github.com/users/jpr5/repos","events_url":"https://api.github.com/users/jpr5/events{/privacy}","received_events_url":"https://api.github.com/users/jpr5/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jpr5/ngrep","description":"ngrep strives to provide most of GNU grep's common features, applying them to the network layer. ngrep is a pcap-aware tool that will allow you to specify extended regular expressions to match against data payloads of packets.","fork":false,"url":"https://api.github.com/repos/jpr5/ngrep","forks_url":"https://api.github.com/repos/jpr5/ngrep/forks","keys_url":"https://api.github.com/repos/jpr5/ngrep/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jpr5/ngrep/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jpr5/ngrep/teams","hooks_url":"https://api.github.com/repos/jpr5/ngrep/hooks","issue_events_url":"https://api.github.com/repos/jpr5/ngrep/issues/events{/number}","events_url":"https://api.github.com/repos/jpr5/ngrep/events","assignees_url":"https://api.github.com/repos/jpr5/ngrep/assignees{/user}","branches_url":"https://api.github.com/repos/jpr5/ngrep/branches{/branch}","tags_url":"https://api.github.com/repos/jpr5/ngrep/tags","blobs_url":"https://api.github.com/repos/jpr5/ngrep/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jpr5/ngrep/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jpr5/ngrep/git/refs{/sha}","trees_url":"https://api.github.com/repos/jpr5/ngrep/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jpr5/ngrep/statuses/{sha}","languages_url":"https://api.github.com/repos/jpr5/ngrep/languages","stargazers_url":"https://api.github.com/repos/jpr5/ngrep/stargazers","contributors_url":"https://api.github.com/repos/jpr5/ngrep/contributors","subscribers_url":"https://api.github.com/repos/jpr5/ngrep/subscribers","subscription_url":"https://api.github.com/repos/jpr5/ngrep/subscription","commits_url":"https://api.github.com/repos/jpr5/ngrep/commits{/sha}","git_commits_url":"https://api.github.com/repos/jpr5/ngrep/git/commits{/sha}","comments_url":"https://api.github.com/repos/jpr5/ngrep/comments{/number}","issue_comment_url":"https://api.github.com/repos/jpr5/ngrep/issues/comments{/number}","contents_url":"https://api.github.com/repos/jpr5/ngrep/contents/{+path}","compare_url":"https://api.github.com/repos/jpr5/ngrep/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jpr5/ngrep/merges","archive_url":"https://api.github.com/repos/jpr5/ngrep/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jpr5/ngrep/downloads","issues_url":"https://api.github.com/repos/jpr5/ngrep/issues{/number}","pulls_url":"https://api.github.com/repos/jpr5/ngrep/pulls{/number}","milestones_url":"https://api.github.com/repos/jpr5/ngrep/milestones{/number}","notifications_url":"https://api.github.com/repos/jpr5/ngrep/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jpr5/ngrep/labels{/name}","releases_url":"https://api.github.com/repos/jpr5/ngrep/releases{/id}","created_at":"2009-12-30T08:14:15Z","updated_at":"2015-07-30T05:05:32Z","pushed_at":"2015-07-09T14:18:00Z","git_url":"git://github.com/jpr5/ngrep.git","ssh_url":"git@github.com:jpr5/ngrep.git","clone_url":"https://github.com/jpr5/ngrep.git","svn_url":"https://github.com/jpr5/ngrep","homepage":"http://ngrep.sf.net","size":2148,"stargazers_count":23,"watchers_count":23,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jpr5/ngrep/pulls/3"},"html":{"href":"https://github.com/jpr5/ngrep/pull/3"},"issue":{"href":"https://api.github.com/repos/jpr5/ngrep/issues/3"},"comments":{"href":"https://api.github.com/repos/jpr5/ngrep/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/jpr5/ngrep/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/jpr5/ngrep/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jpr5/ngrep/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/jpr5/ngrep/statuses/210ede35e65fca8ea3df7ed1b90bdff4cc100f80"}}}}