Skip to content

Commit

Permalink
Merge pull request JuliaLang#16732 from JuliaLang/amitm/fix_error_mes…
Browse files Browse the repository at this point in the history
…sage

Check for socket close condition when reading cookie/version
  • Loading branch information
amitmurthy committed Jun 3, 2016
2 parents f844b5f + a835663 commit 837f129
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,10 @@ end
function process_hdr(s, validate_cookie)
if validate_cookie
cookie = read(s, HDR_COOKIE_LEN)
if length(cookie) < HDR_COOKIE_LEN
error("Cookie read failed. Connection closed by peer.")
end

self_cookie = cluster_cookie()
for i in 1:HDR_COOKIE_LEN
if UInt8(self_cookie[i]) != cookie[i]
Expand All @@ -1051,7 +1055,12 @@ function process_hdr(s, validate_cookie)
# When we have incompatible julia versions trying to connect to each other,
# and can be detected, raise an appropriate error.
# For now, just return the version.
return VersionNumber(strip(String(read(s, HDR_VERSION_LEN))))
version = read(s, HDR_VERSION_LEN)
if length(version) < HDR_VERSION_LEN
error("Version read failed. Connection closed by peer.")
end

return VersionNumber(strip(String(version)))
end

function handle_msg(msg::CallMsg{:call}, r_stream, w_stream, version)
Expand Down

0 comments on commit 837f129

Please sign in to comment.