diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-03-06 04:15:42 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-03-06 04:15:42 +0000 |
commit | d7b8e448bfd29042f64ed3535dc21014b9259088 (patch) | |
tree | 095315717e3050b4acb09d91e848dc2e3d0b2b5f /ext/socket | |
parent | b014cc337ef28498311f58a7b28bdfffebc53f00 (diff) | |
download | ruby-d7b8e448bfd29042f64ed3535dc21014b9259088.tar.gz |
2000-03-06
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/socket.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 7838b151a3..ac79d89134 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -530,6 +530,9 @@ ip_addrsetup(host, port) else if (name[0] == '<' && strcmp(name, "<broadcast>") == 0) { mkinetaddr(INADDR_BROADCAST, hbuf, sizeof(hbuf)); } + else if (strlen(name) > sizeof(hbuf)-1) { + rb_raise(rb_eArgError, "hostname too long (%d)", strlen(name)); + } else { strcpy(hbuf, name); } @@ -551,6 +554,9 @@ ip_addrsetup(host, port) hints.ai_socktype = SOCK_DGRAM; error = getaddrinfo(hostp, portp, &hints, &res); if (error) { + if (hostp && hostp[strlen(hostp)-1] == '\n') { + rb_raise(rb_eSocket, "newline at the end of hostname"); + } rb_raise(rb_eSocket, "%s", gai_strerror(error)); } |