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

* ext/syck/syck.h: Parser definition problems on HP-UX. [ruby-talk:79389]

* ext/syck/handler.c (syck_hdlr_get_anchor): Memory leak.

* ext/syck/syck.s (syck_io_file_read): Bad arguments to fread.

* ext/syck/rubyext.c: Tainting issues.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
why 2003-08-19 16:38:02 +00:00
parent 94c2e6f18a
commit 360b0a015a
5 changed files with 63 additions and 49 deletions

View file

@ -1,3 +1,13 @@
Wed Aug 20 01:31:17 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
* ext/syck/syck.h: Parser definition problems on HP-UX. [ruby-talk:79389]
* ext/syck/handler.c (syck_hdlr_get_anchor): Memory leak.
* ext/syck/syck.s (syck_io_file_read): Bad arguments to fread.
* ext/syck/rubyext.c: Tainting issues.
Tue Aug 19 23:20:00 2003 Shigeo Kobayashi <shigek@ruby-lang.org>
* ext/bigdecimal/bigdecimal.c .h .html: to_s("+") implemented.

View file

@ -1,5 +1,5 @@
/*
* handler.h
* handler.c
*
* $Author$
* $Date$
@ -73,6 +73,7 @@ syck_hdlr_get_anchor( SyckParser *p, char *a )
{
if ( n != (void *)1 )
{
S_FREE( a );
return n;
}
else
@ -94,7 +95,16 @@ syck_hdlr_get_anchor( SyckParser *p, char *a )
{
n = (p->bad_anchor_handler)( p, a );
}
n->anchor = a;
if ( n->anchor )
{
S_FREE( a );
}
else
{
n->anchor = a;
}
return n;
}

View file

@ -68,6 +68,7 @@ void rb_syck_output_handler _((SyckEmitter *, char *, long));
struct parser_xtra {
VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */
VALUE proc;
int taint;
};
/*
@ -103,31 +104,29 @@ rb_syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
/*
* determine: are we reading from a string or io?
* (returns tainted? boolean)
*/
void
int
syck_parser_assign_io(parser, port)
SyckParser *parser;
VALUE port;
{
int taint = Qtrue;
if (rb_respond_to(port, rb_intern("to_str"))) {
#if 0
arg.taint = OBJ_TAINTED(port); /* original taintedness */
taint = OBJ_TAINTED(port); /* original taintedness */
StringValue(port); /* possible conversion */
#endif
syck_parser_str( parser, RSTRING(port)->ptr, RSTRING(port)->len, NULL );
}
else if (rb_respond_to(port, s_read)) {
if (rb_respond_to(port, s_binmode)) {
rb_funcall2(port, s_binmode, 0, 0);
}
#if 0
arg.taint = Qfalse;
#endif
syck_parser_str( parser, (char *)port, 0, rb_syck_io_str_read );
}
else {
rb_raise(rb_eTypeError, "instance of IO needed");
}
return taint;
}
/*
@ -283,10 +282,8 @@ rb_syck_parse_handler(p, n)
}
bonus = (struct parser_xtra *)p->bonus;
if ( bonus->proc != 0 )
{
rb_funcall(bonus->proc, s_call, 1, v);
}
if ( bonus->taint) OBJ_TAINT( obj );
if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, v);
rb_iv_set(obj, "@value", v);
rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj);
@ -481,10 +478,8 @@ rb_syck_load_handler(p, n)
}
bonus = (struct parser_xtra *)p->bonus;
if ( bonus->proc != 0 )
{
rb_funcall(bonus->proc, s_call, 1, obj);
}
if ( bonus->taint) OBJ_TAINT( obj );
if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj);
if ( check_transfers == 1 && n->type_id != NULL )
{
@ -617,11 +612,11 @@ syck_parser_load(argc, argv, self)
rb_scan_args(argc, argv, "11", &port, &proc);
Data_Get_Struct(self, SyckParser, parser);
syck_parser_assign_io(parser, port);
model = rb_hash_aref( rb_iv_get( self, "@options" ), sym_model );
syck_set_model( parser, model );
bonus.taint = syck_parser_assign_io(parser, port);
bonus.data = hash = rb_hash_new();
if ( NIL_P( proc ) ) bonus.proc = 0;
else bonus.proc = proc;
@ -647,11 +642,11 @@ syck_parser_load_documents(argc, argv, self)
rb_scan_args(argc, argv, "1&", &port, &proc);
Data_Get_Struct(self, SyckParser, parser);
syck_parser_assign_io(parser, port);
model = rb_hash_aref( rb_iv_get( self, "@options" ), sym_model );
syck_set_model( parser, model );
bonus.taint = syck_parser_assign_io(parser, port);
while ( 1 )
{
/* Reset hash for tracking nodes */
@ -822,10 +817,6 @@ syck_loader_transfer( self, type, val )
{
char *taguri = NULL;
#if 0
rb_p(rb_str_new2( "-- TYPE --" ));
rb_p(type);
#endif
if (NIL_P(type) || !RSTRING(type)->ptr || RSTRING(type)->len == 0)
{
/*
@ -849,9 +840,6 @@ syck_loader_transfer( self, type, val )
VALUE str_taguri = rb_str_new2("taguri");
VALUE str_xprivate = rb_str_new2("x-private");
VALUE parts = rb_str_split( type_uri, ":" );
#if 0
rb_p(parts);
#endif
scheme = rb_ary_shift( parts );
@ -884,10 +872,6 @@ syck_loader_transfer( self, type, val )
name = rb_ary_shift( col );
type_proc = rb_ary_shift( col );
}
#if 0
rb_p(name);
rb_p(type_proc);
#endif
}
if ( rb_respond_to( type_proc, s_call ) )
@ -1108,7 +1092,7 @@ syck_emitter_write_m( self, str )
{
SyckEmitter *emitter;
Data_Get_Struct(self, SyckEmitter, emitter);
Data_Get_Struct(self, SyckEmitter, emitter);
syck_emitter_write( emitter, RSTRING(str)->ptr, RSTRING(str)->len );
return self;
}
@ -1122,7 +1106,7 @@ syck_emitter_simple_write( self, str )
{
SyckEmitter *emitter;
Data_Get_Struct(self, SyckEmitter, emitter);
Data_Get_Struct(self, SyckEmitter, emitter);
syck_emitter_simple( emitter, RSTRING(str)->ptr, RSTRING(str)->len );
return self;
}

View file

@ -50,7 +50,7 @@ syck_io_file_read( char *buf, SyckIoFile *file, long max_size, long skip )
ASSERT( file != NULL );
max_size -= skip;
len = fread( buf + skip, max_size, sizeof( char ), file->ptr );
len = fread( buf + skip, sizeof( char ), max_size, file->ptr );
len += skip;
buf[len] = '\0';
@ -181,7 +181,7 @@ syck_add_sym( SyckParser *p, char *data )
{
p->syms = st_init_numtable();
}
id = p->syms->num_entries;
id = p->syms->num_entries + 1;
st_insert( p->syms, id, (st_data_t)data );
return id;
}

View file

@ -13,7 +13,7 @@
#define SYCK_YAML_MAJOR 1
#define SYCK_YAML_MINOR 0
#define SYCK_VERSION "0.38"
#define SYCK_VERSION "0.39"
#define YAML_DOMAIN "yaml.org,2002"
#include <stdio.h>
@ -152,8 +152,28 @@ enum syck_level_status {
};
/*
* Parser struct
* Parser structs
*/
struct _syck_file {
/* File pointer */
FILE *ptr;
/* Function which FILE -> buffer */
SyckIoFileRead read;
};
struct _syck_str {
/* String buffer pointers */
char *beg, *ptr, *end;
/* Function which string -> buffer */
SyckIoStrRead read;
};
struct _syck_level {
int spaces;
char *domain;
enum syck_level_status status;
};
struct _syck_parser {
/* Root node */
SYMID root, root_on_error;
@ -180,25 +200,15 @@ struct _syck_parser {
/* EOF flag */
int eof;
union {
struct _syck_file {
FILE *ptr;
SyckIoFileRead read;
} *file;
struct _syck_str {
char *beg, *ptr, *end;
SyckIoStrRead read;
} *str;
SyckIoFile *file;
SyckIoStr *str;
} io;
/* Symbol table for anchors */
st_table *anchors, *bad_anchors;
/* Optional symbol table for SYMIDs */
st_table *syms;
/* Levels of indentation */
struct _syck_level {
int spaces;
char *domain;
enum syck_level_status status;
} *levels;
SyckLevel *levels;
int lvl_idx;
int lvl_capa;
void *bonus;