1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* pack.c (pack_pack): raises RangeError if uv is out of UTF8 value

range.  [ruby-dev:23281]

* io.c (rb_io_binmode): stdio buffer should be empty when calling
  IO#binmode.  [ruby-talk:96155]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-03-31 02:59:57 +00:00
parent d3bb9ea112
commit 189febdf24
4 changed files with 32 additions and 8 deletions

View file

@ -3,6 +3,14 @@ Wed Mar 31 11:52:39 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/delegate.rb (DelegateClass): define internal methods of the
result class, but not metaclass of the caller.
Wed Mar 31 11:17:16 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_pack): raises RangeError if uv is out of UTF8 value
range. [ruby-dev:23281]
* io.c (rb_io_binmode): stdio buffer should be empty when calling
IO#binmode. [ruby-talk:96155]
Tue Mar 30 20:25:34 2004 Tanaka Akira <akr@m17n.org>
* time.c (search_time_t): limit guess range by mktime if it is

View file

@ -528,6 +528,15 @@ bsock_do_not_rev_lookup_set(self, val)
return val;
}
static void
raise_socket_error(reason, error)
char *reason;
int error;
{
if (error == EAI_SYSTEM) rb_sys_fail(reason);
rb_raise(rb_eSocket, "%s: %s", reason, gai_strerror(error));
}
static void
make_ipaddr0(addr, buf, len)
struct sockaddr *addr;
@ -538,7 +547,7 @@ make_ipaddr0(addr, buf, len)
error = getnameinfo(addr, SA_LEN(addr), buf, len, NULL, 0, NI_NUMERICHOST);
if (error) {
rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
raise_socket_error("getnameinfo", error);
}
}
@ -680,7 +689,7 @@ sock_addrinfo(host, port, socktype, flags)
if (hostp && hostp[strlen(hostp)-1] == '\n') {
rb_raise(rb_eSocket, "newline at the end of hostname");
}
rb_raise(rb_eSocket, "getaddrinfo: %s", gai_strerror(error));
raise_socket_error("getaddrinfo", error);
}
#if defined(__APPLE__) && defined(__MACH__)
@ -744,14 +753,14 @@ ipaddr(sockaddr, norevlookup)
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
NULL, 0, 0);
if (error) {
rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
raise_socket_error("getnameinfo", error);
}
addr1 = rb_str_new2(hbuf);
}
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
raise_socket_error("getnameinfo", error);
}
addr2 = rb_str_new2(hbuf);
if (norevlookup) {
@ -2210,7 +2219,7 @@ sock_s_getaddrinfo(argc, argv)
}
error = getaddrinfo(hptr, pptr, &hints, &res);
if (error) {
rb_raise(rb_eSocket, "getaddrinfo: %s", gai_strerror(error));
raise_socket_error("getaddrinfo", error);
}
ret = make_addrinfo(res);
@ -2347,11 +2356,11 @@ sock_s_getnameinfo(argc, argv)
error_exit_addr:
if (res) freeaddrinfo(res);
rb_raise(rb_eSocket, "getaddrinfo: %s", gai_strerror(error));
raise_socket_error("getaddrinfo", error);
error_exit_name:
if (res) freeaddrinfo(res);
rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
raise_socket_error("getnameinfo", error);
}
static VALUE

3
io.c
View file

@ -2133,6 +2133,9 @@ rb_io_binmode(io)
OpenFile *fptr;
GetOpenFile(io, fptr);
if ((fptr->mode & FMODE_BINMODE) && READ_DATA_BUFFERED(fptr->f)) {
rb_raise(rb_eIOError, "buffer already filled with text-mode content");
}
#ifdef __human68k__
if (fptr->f)
fmode(fptr->f, _IOBIN);

6
pack.c
View file

@ -866,8 +866,12 @@ pack_pack(ary, fmt)
int le;
from = NEXTFROM;
from = rb_to_int(from);
l = num2i32(from);
le = uv_to_utf8(buf, l);
if (TYPE(from) == T_BIGNUM) {
rb_raise(rb_eRangeError, "pack(U): value out of range");
}
rb_str_buf_cat(res, (char*)buf, le);
}
break;
@ -2024,7 +2028,7 @@ uv_to_utf8(buf, uv)
buf[5] = (uv&0x3f)|0x80;
return 6;
}
rb_raise(rb_eArgError, "pack(U): value out of range");
rb_raise(rb_eRangeError, "pack(U): value out of range");
}
static const long utf8_limits[] = {