diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/pty/pty.c | 6 | ||||
-rw-r--r-- | test/test_pty.rb | 4 |
3 files changed, 8 insertions, 7 deletions
@@ -1,3 +1,8 @@ +Mon Dec 15 21:24:01 2008 Tanaka Akira <akr@fsij.org> + + * ext/pty/pty.c (get_device_once): use DEVICELEN instead of + sizeof SlaveName. + Mon Dec 15 21:01:46 2008 Tanaka Akira <akr@fsij.org> * ext/pty/pty.c (chfunc): make it static. diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 4b3ebb19a6..88163d7ad5 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -293,7 +293,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int fail) } *slave = open(name, O_RDWR); - strlcpy(SlaveName, name, sizeof SlaveName); + strlcpy(SlaveName, name, DEVICELEN); return 0; #else /* HAVE__GETPTY */ @@ -321,7 +321,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int fail) #endif *master = i; *slave = j; - strlcpy(SlaveName, pn, sizeof SlaveName); + strlcpy(SlaveName, pn, DEVICELEN); return 0; #if defined I_PUSH && !defined linux } @@ -343,7 +343,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int fail) snprintf(MasterName, sizeof MasterName, MasterDevice, *p); if ((i = open(MasterName,O_RDWR,0)) >= 0) { *master = i; - snprintf(SlaveName, sizeof SlaveName, SlaveDevice, *p); + snprintf(SlaveName, DEVICELEN, SlaveDevice, *p); if ((j = open(SlaveName,O_RDWR,0)) >= 0) { *slave = j; chown(SlaveName, getuid(), getgid()); diff --git a/test/test_pty.rb b/test/test_pty.rb index 6787da4d21..bbf85a3d33 100644 --- a/test/test_pty.rb +++ b/test/test_pty.rb @@ -13,7 +13,6 @@ class TestPTY < Test::Unit::TestCase def test_spawn_without_block r, w, pid = PTY.spawn(RUBY, '-e', 'puts "a"') assert_equal("a\r\n", r.gets) - assert_raise(Errno::EIO) { r.gets } ensure Process.wait pid if pid end @@ -22,7 +21,6 @@ class TestPTY < Test::Unit::TestCase PTY.spawn(RUBY, '-e', 'puts "b"') {|r,w,pid| assert_equal("b\r\n", r.gets) Process.wait(pid) - assert_raise(Errno::EIO) { r.gets } } end @@ -31,7 +29,6 @@ class TestPTY < Test::Unit::TestCase PTY.spawn(commandline) {|r,w,pid| assert_equal("foo\r\n", r.gets) Process.wait(pid) - assert_raise(Errno::EIO) { r.gets } } end @@ -39,7 +36,6 @@ class TestPTY < Test::Unit::TestCase PTY.spawn([RUBY, "argv0"], '-e', 'puts "bar"') {|r,w,pid| assert_equal("bar\r\n", r.gets) Process.wait(pid) - assert_raise(Errno::EIO) { r.gets } } end end if defined? PTY |