socket.c: null byte at Socket.getnameinfo
* ext/socket/socket.c (sock_s_getnameinfo): check null byte. patched by tommy (Masahiro Tomita) in [ruby-dev:50286]. [Bug #13994] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0c551b7a6d
commit
fb89004a3b
@ -1287,7 +1287,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
|
|||||||
hptr = NULL;
|
hptr = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strncpy(hbuf, StringValuePtr(host), sizeof(hbuf));
|
strncpy(hbuf, StringValueCStr(host), sizeof(hbuf));
|
||||||
hbuf[sizeof(hbuf) - 1] = '\0';
|
hbuf[sizeof(hbuf) - 1] = '\0';
|
||||||
hptr = hbuf;
|
hptr = hbuf;
|
||||||
}
|
}
|
||||||
@ -1301,7 +1301,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
|
|||||||
pptr = pbuf;
|
pptr = pbuf;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strncpy(pbuf, StringValuePtr(port), sizeof(pbuf));
|
strncpy(pbuf, StringValueCStr(port), sizeof(pbuf));
|
||||||
pbuf[sizeof(pbuf) - 1] = '\0';
|
pbuf[sizeof(pbuf) - 1] = '\0';
|
||||||
pptr = pbuf;
|
pptr = pbuf;
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,8 @@ class TestSocket < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_getnameinfo
|
def test_getnameinfo
|
||||||
assert_raise(SocketError) { Socket.getnameinfo(["AF_UNIX", 80, "0.0.0.0"]) }
|
assert_raise(SocketError) { Socket.getnameinfo(["AF_UNIX", 80, "0.0.0.0"]) }
|
||||||
|
assert_raise(ArgumentError) {Socket.getnameinfo(["AF_INET", "http\0", "example.net"])}
|
||||||
|
assert_raise(ArgumentError) {Socket.getnameinfo(["AF_INET", "http", "example.net\0"])}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ip_address_list
|
def test_ip_address_list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user