From: Michal Rokos Date: 2002-08-28T01:05:55+09:00 Subject: [Safer] rb_class_path Hello, about month ago I prepared this cleanup, but forgot it :-) So: this patch get rid of fixed len buffer in variable.c. If you think that could be valuable I can try to remove other fixed len buffer as well. Michal PS: signal.c: Whole code in signal.c counts with SIGINT is defined. No need for ifdef here. Index: signal.c =================================================================== RCS file: /src/ruby/signal.c,v retrieving revision 1.36 diff -u -p -r1.36 signal.c --- signal.c 2002/08/16 07:23:04 1.36 +++ signal.c 2002/08/27 15:58:33 @@ -36,9 +36,7 @@ static struct signals { #ifdef SIGHUP {"HUP", SIGHUP}, #endif -#ifdef SIGINT {"INT", SIGINT}, -#endif #ifdef SIGQUIT {"QUIT", SIGQUIT}, #endif Index: variable.c =================================================================== RCS file: /src/ruby/variable.c,v retrieving revision 1.65 diff -u -p -r1.65 variable.c --- variable.c 2002/05/14 06:22:26 1.65 +++ variable.c 2002/08/27 15:58:35 @@ -188,17 +188,21 @@ rb_class_path(klass) if (path) return path; else { - char buf[256]; + VALUE str; char *s = "Class"; if (TYPE(klass) == T_MODULE) { - if (rb_obj_class(klass) == rb_cModule) + if (rb_obj_class(klass) == rb_cModule) { s = "Module"; - else + } + else { s = rb_class2name(RBASIC(klass)->klass); + } } - sprintf(buf, "#<%s:0x%lx>", s, klass); - return rb_str_new2(buf); + str = rb_str_new(0, 2 + strlen(s) + 3 + SIZEOF_LONG + 1 + 1); + snprintf(RSTRING(str)->ptr, RSTRING(str)->len, "#<%s:0x%lx>", s, klass); + + return str; } } -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Michal Rokos Czech Technical University, Prague E-mail:m.rokos@sh.cvut.cz ICQ:36118339 Jabber:majkl@jabber.cz -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-