* [ruby-dev:50286] [Ruby trunk Bug#13994] Socket.getnameinfo が NUL終端文字列を期待している
[not found] <redmine.issue-13994.20171010150622@ruby-lang.org>
@ 2017-10-10 15:06 ` tommy
2018-03-23 12:43 ` [ruby-dev:50513] " nagachika00
2018-03-28 5:59 ` [ruby-dev:50516] " usa
2 siblings, 0 replies; 3+ messages in thread
From: tommy @ 2017-10-10 15:06 UTC (permalink / raw)
To: ruby-dev
Issue #13994 has been reported by tommy (Masahiro Tomita).
----------------------------------------
Bug #13994: Socket.getnameinfo が NUL終端文字列を期待している
https://bugs.ruby-lang.org/issues/13994
* Author: tommy (Masahiro Tomita)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.0dev (2017-10-10 trunk 60154) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Socket.getnameinfo が NUL終端文字列を期待していて、SHARABLE_MIDDLE_SUBSTRING=1 時におかしくなります。
```
% grep abcdefg /etc/hosts /etc/services
/etc/hosts:192.168.0.99 abcdefghijklmnopqrstuvwxyz.test
/etc/services:abcdefghijklmnopqrstuvwxyz 9999/tcp
% ruby -rsocket -e 'p Socket.getnameinfo(["AF_INET", "abcdefghijklmnopqrstuvwxyz!".chop, "abcdefghijklmnopqrstuvwxyz.test!".chop])'
Traceback (most recent call last):
1: from -e:1:in `<main>'
-e:1:in `getnameinfo': getaddrinfo: Servname not supported for ai_socktype (SocketError)
```
パッチ適用後は次のようになります。
```
% ruby -rsocket -e 'p Socket.getnameinfo(["AF_INET", "abcdefghijklmnopqrstuvwxyz!".chop, "abcdefghijklmnopqrstuvwxyz.test!".chop])'
["abcdefghijklmnopqrstuvwxyz.test", "abcdefghijklmnopqrstuvwxyz"]
```
パッチ:
```diff
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 14e069bb8d..9eb36def14 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1287,7 +1287,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
hptr = NULL;
}
else {
- strncpy(hbuf, StringValuePtr(host), sizeof(hbuf));
+ strncpy(hbuf, StringValueCStr(host), sizeof(hbuf));
hbuf[sizeof(hbuf) - 1] = '\0';
hptr = hbuf;
}
@@ -1301,7 +1301,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
pptr = pbuf;
}
else {
- strncpy(pbuf, StringValuePtr(port), sizeof(pbuf));
+ strncpy(pbuf, StringValueCStr(port), sizeof(pbuf));
pbuf[sizeof(pbuf) - 1] = '\0';
pptr = pbuf;
}
```
--
https://bugs.ruby-lang.org/
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [ruby-dev:50513] [Ruby trunk Bug#13994] Socket.getnameinfo が NUL終端文字列を期待している
[not found] <redmine.issue-13994.20171010150622@ruby-lang.org>
2017-10-10 15:06 ` [ruby-dev:50286] [Ruby trunk Bug#13994] Socket.getnameinfo が NUL終端文字列を期待している tommy
@ 2018-03-23 12:43 ` nagachika00
2018-03-28 5:59 ` [ruby-dev:50516] " usa
2 siblings, 0 replies; 3+ messages in thread
From: nagachika00 @ 2018-03-23 12:43 UTC (permalink / raw)
To: ruby-dev
Issue #13994 has been updated by nagachika (Tomoyuki Chikanaga).
Backport changed from 2.3: REQUIRED, 2.4: REQUIRED to 2.3: REQUIRED, 2.4: DONE
ruby_2_4 r62904 merged revision(s) 60162.
----------------------------------------
Bug #13994: Socket.getnameinfo が NUL終端文字列を期待している
https://bugs.ruby-lang.org/issues/13994#change-71174
* Author: tommy (Masahiro Tomita)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.0dev (2017-10-10 trunk 60154) [x86_64-linux]
* Backport: 2.3: REQUIRED, 2.4: DONE
----------------------------------------
Socket.getnameinfo が NUL終端文字列を期待していて、SHARABLE_MIDDLE_SUBSTRING=1 時におかしくなります。
```
% grep abcdefg /etc/hosts /etc/services
/etc/hosts:192.168.0.99 abcdefghijklmnopqrstuvwxyz.test
/etc/services:abcdefghijklmnopqrstuvwxyz 9999/tcp
% ruby -rsocket -e 'p Socket.getnameinfo(["AF_INET", "abcdefghijklmnopqrstuvwxyz!".chop, "abcdefghijklmnopqrstuvwxyz.test!".chop])'
Traceback (most recent call last):
1: from -e:1:in `<main>'
-e:1:in `getnameinfo': getaddrinfo: Servname not supported for ai_socktype (SocketError)
```
パッチ適用後は次のようになります。
```
% ruby -rsocket -e 'p Socket.getnameinfo(["AF_INET", "abcdefghijklmnopqrstuvwxyz!".chop, "abcdefghijklmnopqrstuvwxyz.test!".chop])'
["abcdefghijklmnopqrstuvwxyz.test", "abcdefghijklmnopqrstuvwxyz"]
```
パッチ:
```diff
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 14e069bb8d..9eb36def14 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1287,7 +1287,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
hptr = NULL;
}
else {
- strncpy(hbuf, StringValuePtr(host), sizeof(hbuf));
+ strncpy(hbuf, StringValueCStr(host), sizeof(hbuf));
hbuf[sizeof(hbuf) - 1] = '\0';
hptr = hbuf;
}
@@ -1301,7 +1301,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
pptr = pbuf;
}
else {
- strncpy(pbuf, StringValuePtr(port), sizeof(pbuf));
+ strncpy(pbuf, StringValueCStr(port), sizeof(pbuf));
pbuf[sizeof(pbuf) - 1] = '\0';
pptr = pbuf;
}
```
--
https://bugs.ruby-lang.org/
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [ruby-dev:50516] [Ruby trunk Bug#13994] Socket.getnameinfo が NUL終端文字列を期待している
[not found] <redmine.issue-13994.20171010150622@ruby-lang.org>
2017-10-10 15:06 ` [ruby-dev:50286] [Ruby trunk Bug#13994] Socket.getnameinfo が NUL終端文字列を期待している tommy
2018-03-23 12:43 ` [ruby-dev:50513] " nagachika00
@ 2018-03-28 5:59 ` usa
2 siblings, 0 replies; 3+ messages in thread
From: usa @ 2018-03-28 5:59 UTC (permalink / raw)
To: ruby-dev
Issue #13994 has been updated by usa (Usaku NAKAMURA).
Backport changed from 2.3: REQUIRED, 2.4: DONE to 2.3: DONE, 2.4: DONE
ruby_2_3 r62948 merged revision(s) 60162.
----------------------------------------
Bug #13994: Socket.getnameinfo が NUL終端文字列を期待している
https://bugs.ruby-lang.org/issues/13994#change-71275
* Author: tommy (Masahiro Tomita)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.0dev (2017-10-10 trunk 60154) [x86_64-linux]
* Backport: 2.3: DONE, 2.4: DONE
----------------------------------------
Socket.getnameinfo が NUL終端文字列を期待していて、SHARABLE_MIDDLE_SUBSTRING=1 時におかしくなります。
```
% grep abcdefg /etc/hosts /etc/services
/etc/hosts:192.168.0.99 abcdefghijklmnopqrstuvwxyz.test
/etc/services:abcdefghijklmnopqrstuvwxyz 9999/tcp
% ruby -rsocket -e 'p Socket.getnameinfo(["AF_INET", "abcdefghijklmnopqrstuvwxyz!".chop, "abcdefghijklmnopqrstuvwxyz.test!".chop])'
Traceback (most recent call last):
1: from -e:1:in `<main>'
-e:1:in `getnameinfo': getaddrinfo: Servname not supported for ai_socktype (SocketError)
```
パッチ適用後は次のようになります。
```
% ruby -rsocket -e 'p Socket.getnameinfo(["AF_INET", "abcdefghijklmnopqrstuvwxyz!".chop, "abcdefghijklmnopqrstuvwxyz.test!".chop])'
["abcdefghijklmnopqrstuvwxyz.test", "abcdefghijklmnopqrstuvwxyz"]
```
パッチ:
```diff
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 14e069bb8d..9eb36def14 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1287,7 +1287,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
hptr = NULL;
}
else {
- strncpy(hbuf, StringValuePtr(host), sizeof(hbuf));
+ strncpy(hbuf, StringValueCStr(host), sizeof(hbuf));
hbuf[sizeof(hbuf) - 1] = '\0';
hptr = hbuf;
}
@@ -1301,7 +1301,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
pptr = pbuf;
}
else {
- strncpy(pbuf, StringValuePtr(port), sizeof(pbuf));
+ strncpy(pbuf, StringValueCStr(port), sizeof(pbuf));
pbuf[sizeof(pbuf) - 1] = '\0';
pptr = pbuf;
}
```
--
https://bugs.ruby-lang.org/
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-28 5:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-13994.20171010150622@ruby-lang.org>
2017-10-10 15:06 ` [ruby-dev:50286] [Ruby trunk Bug#13994] Socket.getnameinfo が NUL終端文字列を期待している tommy
2018-03-23 12:43 ` [ruby-dev:50513] " nagachika00
2018-03-28 5:59 ` [ruby-dev:50516] " usa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).