{"action":"created","issue":{"url":"https://api.github.com/repos/nanomsg/nng/issues/731","repository_url":"https://api.github.com/repos/nanomsg/nng","labels_url":"https://api.github.com/repos/nanomsg/nng/issues/731/labels{/name}","comments_url":"https://api.github.com/repos/nanomsg/nng/issues/731/comments","events_url":"https://api.github.com/repos/nanomsg/nng/issues/731/events","html_url":"https://github.com/nanomsg/nng/issues/731","id":361076913,"node_id":"MDU6SXNzdWUzNjEwNzY5MTM=","number":731,"title":"Invalid URL reports NNG_EINVAL instead of NNG_EADDRINVAL","user":{"login":"neachdainn","id":2917148,"node_id":"MDQ6VXNlcjI5MTcxNDg=","avatar_url":"https://avatars1.githubusercontent.com/u/2917148?v=4","gravatar_id":"","url":"https://api.github.com/users/neachdainn","html_url":"https://github.com/neachdainn","followers_url":"https://api.github.com/users/neachdainn/followers","following_url":"https://api.github.com/users/neachdainn/following{/other_user}","gists_url":"https://api.github.com/users/neachdainn/gists{/gist_id}","starred_url":"https://api.github.com/users/neachdainn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neachdainn/subscriptions","organizations_url":"https://api.github.com/users/neachdainn/orgs","repos_url":"https://api.github.com/users/neachdainn/repos","events_url":"https://api.github.com/users/neachdainn/events{/privacy}","received_events_url":"https://api.github.com/users/neachdainn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-17T23:07:36Z","updated_at":"2018-09-18T00:02:10Z","closed_at":null,"author_association":"NONE","body":"## NNG & Platform details.\r\n\r\nRunning nng v1.0.1 on an up-to-date Arch Linux (Linux 4.18.6 x86_64). Bug was originally found in Rust calling into C but can be reproduced in pure C.\r\n\r\n## Expected Behavior\r\n\r\nPassing \"tcp:://127.0.0.1:5555\" to `nng_listen` and `nng_dial` should return `NNG_EADDRINVAL`.\r\n\r\n## Actual Behavior\r\n\r\n`NNG_EINVAL` is returned instead.\r\n\r\n## Steps to Reproduce\r\n\r\nPass the incorrectly formatted URL to the function. A minimal test program follows:\r\n\r\n```c\r\n#include <stdio.h>\r\n#include <stdlib.h>\r\n#include <nng/nng.h>\r\n#include <nng/protocol/reqrep0/rep.h>\r\n\r\nvoid fatal(const char* func, int rv)\r\n{\r\n\tfprintf(stderr, \"%s: (%d) %s\\n\", func, rv, nng_strerror(rv));\r\n\texit(1);\r\n}\r\n\r\nint main(int argc, char** argv)\r\n{\r\n\tnng_socket sock;\r\n\tint rv;\r\n\r\n\tif((rv = nng_rep0_open(&sock)) != 0) {\r\n\t\tfatal(\"nng_rep0_open\", rv);\r\n\t}\r\n\r\n\tif((rv = nng_listen(sock, \"tpc:://127.0.0.1:5555\", NULL, 0)) != 0) {\r\n\t\tfatal(\"nng_listen\", rv);\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/nanomsg/nng/issues/comments/422209600","html_url":"https://github.com/nanomsg/nng/issues/731#issuecomment-422209600","issue_url":"https://api.github.com/repos/nanomsg/nng/issues/731","id":422209600,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjIwOTYwMA==","user":{"login":"gdamore","id":1295229,"node_id":"MDQ6VXNlcjEyOTUyMjk=","avatar_url":"https://avatars2.githubusercontent.com/u/1295229?v=4","gravatar_id":"","url":"https://api.github.com/users/gdamore","html_url":"https://github.com/gdamore","followers_url":"https://api.github.com/users/gdamore/followers","following_url":"https://api.github.com/users/gdamore/following{/other_user}","gists_url":"https://api.github.com/users/gdamore/gists{/gist_id}","starred_url":"https://api.github.com/users/gdamore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gdamore/subscriptions","organizations_url":"https://api.github.com/users/gdamore/orgs","repos_url":"https://api.github.com/users/gdamore/repos","events_url":"https://api.github.com/users/gdamore/events{/privacy}","received_events_url":"https://api.github.com/users/gdamore/received_events","type":"User","site_admin":false},"created_at":"2018-09-18T00:02:10Z","updated_at":"2018-09-18T00:02:10Z","author_association":"CONTRIBUTOR","body":"I don’t think we should change nng_url_parse() — that is a public API and\n(via nng_url_parse()) and so it has a documented return code of NNG_EINVAL.\n\nI’d be open to *either*:\n\na) Updating the docs for dial and listen to indicate that NNG_EINVAL is a\npossible error for an invalid (unparseable) URL\nb) Updating the implementation of nni_dialer_create() and\nnni_listener_create() to convert NNG_EINVAL coming from nni_url_parse to\nNNG_EADDRINVAL.\n\nFrankly, “a” seems the lower risk, simpler, and possibly the better of the\ntwo.\n\n - Garrett\n\nOn Mon, Sep 17, 2018 at 4:33 PM Nate Kent <notifications@github.com> wrote:\n\n> Looking through nni_url_parse, it appears that all errors in parsing\n> return an NNG_EINVAL without a single instance of NNG_EADDRINVAL. It\n> seems to me that the fix is easy as either replacing all instances of\n> EINVAL with EADDRINVAL or to update the documentation to correctly\n> reflect which error code is returned.\n>\n> I'm willing to submit a pull request for either solution if I am told\n> which one is better.\n>\n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/nanomsg/nng/issues/731#issuecomment-422204863>, or mute\n> the thread\n> <https://github.com/notifications/unsubscribe-auth/ABPDfXcg2Q4jJCpHq2NF9VsKB85E0Du0ks5ucDFYgaJpZM4Ws4_k>\n> .\n>\n"}}
{"actor":{"display_login":"gdamore"}}