diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-30 15:33:06 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-30 15:33:06 +0000 |
commit | 3e5fe9f5522bfbc58b35e9c68d3f843620ddeb53 (patch) | |
tree | 3d3ad52fa8d8b3a3345dad40a94041eb8851ad6c /ext/socket/raddrinfo.c | |
parent | a11b5364b6d924f1d9c86543d1365e02336e2147 (diff) | |
download | ruby-3e5fe9f5522bfbc58b35e9c68d3f843620ddeb53.tar.gz |
* ext/socket/raddrinfo.c (host_str, port_str): Use StringValueCStr
instead of (Safe)StringValue, to detect NUL byte in the string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/raddrinfo.c')
-rw-r--r-- | ext/socket/raddrinfo.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index b0c80399de..11f5d1f5a6 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -429,6 +429,10 @@ str_is_number(const char *p) #define str_equal(ptr, len, name) \ ((ptr)[0] == name[0] && \ rb_strlen_lit(name) == (len) && memcmp(ptr, name, len) == 0) +#define SafeStringValueCStr(v) do {\ + StringValueCStr(v);\ + rb_check_safe_obj(v);\ +} while(0) static char* host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr) @@ -447,7 +451,7 @@ host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr) const char *name; size_t len; - SafeStringValue(host); + SafeStringValueCStr(host); RSTRING_GETMEM(host, name, len); if (!len || str_equal(name, len, "<any>")) { make_inetaddr(INADDR_ANY, hbuf, hbuflen); @@ -486,7 +490,7 @@ port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr) const char *serv; size_t len; - SafeStringValue(port); + SafeStringValueCStr(port); RSTRING_GETMEM(port, serv, len); if (len >= pbuflen) { rb_raise(rb_eArgError, "service name too long (%"PRIdSIZE")", |