[#35688] サブクラスのオブジェクト生成時に、スーパークラスの初期化を行うには ? — Onodera Takafumi <onodera-tak@...>

9 messages 2002/08/01

[#35772] Unsecure world writeable dirの警告 — "井上 浩一" <kyoui32@...>

=1B$B0f>e$G$9!#=1B(B

31 messages 2002/08/26
[#35774] Re: Unsecure world writeable dir の警告 — matz@... (Yukihiro Matsumoto) 2002/08/26

まつもと ゆきひろです

[#35775] Re: Unsecure world writeabledir の警告 — nobu.nakada@... 2002/08/26

なかだです。

[#35776] Re: Unsecure world writeabledir の警告 — matz@... (Yukihiro Matsumoto) 2002/08/26

まつもと ゆきひろです

[#35778] Re: Unsecure world writeabledir の警告 — nobu.nakada@... 2002/08/26

なかだです。

[#35779] Re: Unsecure world writeabledir の警告 — WATANABE Hirofumi <eban@...> 2002/08/26

わたなべです。

[#35780] Re: Unsecure world writeabledir の警告 — nobu.nakada@... 2002/08/26

なかだです。

[#35784] Re: Unsecure world writeabledir の警告 — "U.Nakamura" <usa@...> 2002/08/26

こんにちは、なかむら(う)です。

[#35854] Re: Unsecure world writeabledir の警告 — "Inoue" <rubyist@...1.117.ne.jp> 2002/09/04

井上です。

[#35865] Re: Unsecure world writeabledir の警告 — Koji Arai <JCA02266@...> 2002/09/05

新井です。

[#35866] Re: Unsecure world writeabledir の警告 — matz@... (Yukihiro Matsumoto) 2002/09/06

まつもと ゆきひろです

[#35789] multipart な CGI を速くしたい — Takashi Kanai <kanai@...4u.or.jp>

Windows上でRubyとMySQLを使ってショッピングサイトのようなものを作って

17 messages 2002/08/28

[ruby-list:35677] Re: STR2CSTR()

From: OHARA Shigeki <os@...>
Date: 2002-08-01 04:07:36 UTC
List: ruby-list #35677
大原です。

From: matz@ruby-lang.org (Yukihiro Matsumoto)
Subject: [ruby-list:35671] Re: STR2CSTR()
Message-ID: <1028119102.920933.19088.nullmailer@picachu.netlab.jp>
Date: Wed, 31 Jul 2002 22:44:25 +0900

> |UDPSocket#recvfrom で得た文字列を STR2CSTR() で取り出そうとしたところ、
> |得られた文字列が NULL 終端されていないことがありました。
> |
> |STR2CSTR() で得られた文字列は、
> |NULL 終端されていることが保証されていないのでしょうか?
> 
> 保証しているつもりです。どっかにバグがあったんでしょうか。

ですよね。
とすると、私のプログラムの方にバグがあるのかも知れません……。


#include <ruby.h>

static VALUE
rb_hoge(obj, str)
    VALUE obj;
    VALUE str;
{
    Check_Type(str, T_STRING);
    return rb_str_new2(STR2CSTR(str));
}

Init_hoge()
{
    rb_define_global_function("hoge", rb_hoge, 1);
}


↑こういう拡張ライブラリで、


require "socket"
require "hoge"

s = UDPSocket::open
s.bind("0.0.0.0", 10000)

loop do
  data, addr = s.recvfrom(512)
  response = hoge(data)
  s.send(response, 0x8|0x100, addr[3], addr[1])
  puts "[#{data}] => [#{response}]"
end


↑こういうサーバと、


require "socket"

while data = gets
  data.chomp!

  sock = UDPSocket::open
  sock.connect("localhost", 10000)
  sock.send(data, 0x8)
  response = sock.recv(512)
  puts "[#{data}] => [#{response}]"
  sock.close
end


↑こういうクライアントで通信を試したのですが、


% ruby server.rb
[hoge] => [hoge]
[hoge] => [hoge]
[hoge] => [hogereeBSD: src/etc/hosts,v 1.11.2.2 2001/10/08 09:32:08 ru Exp $
#
# Host Database
# This file should contain the addresses and aliases
# for local hosts that share this file.
# In the presence of the domain name service or NIS, this file may
# not be consulted at all; see /etc/host.conf for the resolution order.
#
#
::1                     localhost localhost.my.domain
127.0.0.1               localhost localhost.my.domain
#
# Imaginary network.
#10.0.0.2               myname.my.domain myname
#10.0.0.3               myfriend.my.domain myfriend
#
# According to R]


↑こんな結果が得られてしまいます。


ruby 1.6.7 (2002-05-23) [i386-freebsd4]
ruby 1.6.7 (2002-03-01) [i386-bsdi4.1]
の、どちらも同様の現象が起こりました。

----
OHARA Shigeki (大原 重樹) <os@iij.ad.jp>

In This Thread