{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/10994","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/10994/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/10994/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/10994/events","html_url":"https://github.com/JuliaLang/julia/pull/10994","id":70765892,"number":10994,"title":"add Cstring/Cwstring types for safe passing of NUL-terminated strings to ccall","user":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars.githubusercontent.com/u/2913679?v=3","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/unicode","name":"unicode","color":"5f4a60"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":37,"created_at":"2015-04-24T18:47:06Z","updated_at":"2015-05-12T02:51:24Z","closed_at":"2015-05-02T18:25:49Z","pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/10994","html_url":"https://github.com/JuliaLang/julia/pull/10994","diff_url":"https://github.com/JuliaLang/julia/pull/10994.diff","patch_url":"https://github.com/JuliaLang/julia/pull/10994.patch"},"body":"This adds two new types, `Cstring` and `Cwstring`, which act just like `Ptr{UInt8}` and `Ptr{Cwchar_t}` as arguments to `ccall`, except that they throw an error if the string contains an embedded NUL character.  I went through the Julia code and used these types wherever they seemed necessary. \r\n\r\nThis is necessary for safe passing of strings to C routines expecting NUL-terminated strings, to avoid silent truncation.  See #10958, #10991.\r\n\r\nNote that you can avoid the test, for strings known not to contain NUL, simply by using `Ptr{UInt8}` as before.\r\n\r\nNote also that I changed several of our own C API routines to accept a `char*` and a `size_t` length parameter, rather than assuming NUL termination.\r\n\r\nStill missing:\r\n- [x] Regression tests\r\n- [x] Documentation\r\n- [x] Check for NUL in `Cmd` strings (command-line params)\r\n- [x] Change `Cstring` to a `bitstype`\r\n\r\ncc: @JeffBezanson, @StefanKarpinski, @ScottPJones, @jiahao "},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/101110079","html_url":"https://github.com/JuliaLang/julia/pull/10994#issuecomment-101110079","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/10994","id":101110079,"user":{"login":"tkelman","id":5934628,"avatar_url":"https://avatars.githubusercontent.com/u/5934628?v=3","gravatar_id":"","url":"https://api.github.com/users/tkelman","html_url":"https://github.com/tkelman","followers_url":"https://api.github.com/users/tkelman/followers","following_url":"https://api.github.com/users/tkelman/following{/other_user}","gists_url":"https://api.github.com/users/tkelman/gists{/gist_id}","starred_url":"https://api.github.com/users/tkelman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkelman/subscriptions","organizations_url":"https://api.github.com/users/tkelman/orgs","repos_url":"https://api.github.com/users/tkelman/repos","events_url":"https://api.github.com/users/tkelman/events{/privacy}","received_events_url":"https://api.github.com/users/tkelman/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T02:51:23Z","updated_at":"2015-05-12T02:51:23Z","body":"Whatever my bootstrapping problem with an msvc build was seems to have gone away. Now just hitting the segfault from 8b8b26193093ae2a0663b3b0d83341719826fcad..."}}