{"action":"created","issue":{"url":"https://api.github.com/repos/nanomsg/nanomsg/issues/363","labels_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/363/labels{/name}","comments_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/363/comments","events_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/363/events","html_url":"https://github.com/nanomsg/nanomsg/pull/363","id":54673029,"number":363,"title":"Change from malloc to calloc","user":{"login":"marchon","id":238496,"avatar_url":"https://avatars.githubusercontent.com/u/238496?v=3","gravatar_id":"","url":"https://api.github.com/users/marchon","html_url":"https://github.com/marchon","followers_url":"https://api.github.com/users/marchon/followers","following_url":"https://api.github.com/users/marchon/following{/other_user}","gists_url":"https://api.github.com/users/marchon/gists{/gist_id}","starred_url":"https://api.github.com/users/marchon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marchon/subscriptions","organizations_url":"https://api.github.com/users/marchon/orgs","repos_url":"https://api.github.com/users/marchon/repos","events_url":"https://api.github.com/users/marchon/events{/privacy}","received_events_url":"https://api.github.com/users/marchon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":31,"created_at":"2015-01-17T19:55:38Z","updated_at":"2015-03-02T20:57:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nanomsg/nanomsg/pulls/363","html_url":"https://github.com/nanomsg/nanomsg/pull/363","diff_url":"https://github.com/nanomsg/nanomsg/pull/363.diff","patch_url":"https://github.com/nanomsg/nanomsg/pull/363.patch"},"body":"changes to make sure that the alloced memory block is zero filled,\r\ntakes a little more time but ALWAYS worth it.. to keep garbage out of\r\nthe memory block.\r\n\r\nThese changes are submitted under the MIT License "},"comment":{"url":"https://api.github.com/repos/nanomsg/nanomsg/issues/comments/76820864","html_url":"https://github.com/nanomsg/nanomsg/pull/363#issuecomment-76820864","issue_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/363","id":76820864,"user":{"login":"gdamore","id":1295229,"avatar_url":"https://avatars.githubusercontent.com/u/1295229?v=3","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":"2015-03-02T20:57:46Z","updated_at":"2015-03-02T20:57:46Z","body":"nanomsg doesn't pass the allocated memory block to any functions that expect null termination.  Again, it just things the thing is an array of bytes that might perfectly well contain any number of bytes that are zero.\r\n\r\nThere are many many application protocols (in fact, arguably this is true of the *vast* majority of them), that do not pass C style strings.  (Much more common when passing variable length string data is to pass a leading size ala Pascal - which is often encoded in *binary*, and that encoding can include null bytes -- for example the value \"256\" in a typical 16-bit value contains two bytes, 0x01, and 0x00.)\r\n\r\nThe *application* that takes a nanomsg packet and expects to be able to use C standard library routines that operate on null terminated strings has the responsibility to ensure that the memory contents actually are a well-formed C string. \r\n\r\nDemanding nanomsg do this for you is trying to use a hammer to drill a hole.  You can make a hole with a hammer, but you probably won't like the result, and you're more likely to break things than to have a correct solution."}}