* 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:
parent
94c2e6f18a
commit
360b0a015a
10
ChangeLog
10
ChangeLog
@ -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>
|
Tue Aug 19 23:20:00 2003 Shigeo Kobayashi <shigek@ruby-lang.org>
|
||||||
|
|
||||||
* ext/bigdecimal/bigdecimal.c .h .html: to_s("+") implemented.
|
* ext/bigdecimal/bigdecimal.c .h .html: to_s("+") implemented.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* handler.h
|
* handler.c
|
||||||
*
|
*
|
||||||
* $Author$
|
* $Author$
|
||||||
* $Date$
|
* $Date$
|
||||||
@ -73,6 +73,7 @@ syck_hdlr_get_anchor( SyckParser *p, char *a )
|
|||||||
{
|
{
|
||||||
if ( n != (void *)1 )
|
if ( n != (void *)1 )
|
||||||
{
|
{
|
||||||
|
S_FREE( a );
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -94,7 +95,16 @@ syck_hdlr_get_anchor( SyckParser *p, char *a )
|
|||||||
{
|
{
|
||||||
n = (p->bad_anchor_handler)( p, a );
|
n = (p->bad_anchor_handler)( p, a );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( n->anchor )
|
||||||
|
{
|
||||||
|
S_FREE( a );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
n->anchor = a;
|
n->anchor = a;
|
||||||
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ void rb_syck_output_handler _((SyckEmitter *, char *, long));
|
|||||||
struct parser_xtra {
|
struct parser_xtra {
|
||||||
VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */
|
VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */
|
||||||
VALUE proc;
|
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?
|
* determine: are we reading from a string or io?
|
||||||
|
* (returns tainted? boolean)
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
syck_parser_assign_io(parser, port)
|
syck_parser_assign_io(parser, port)
|
||||||
SyckParser *parser;
|
SyckParser *parser;
|
||||||
VALUE port;
|
VALUE port;
|
||||||
{
|
{
|
||||||
|
int taint = Qtrue;
|
||||||
if (rb_respond_to(port, rb_intern("to_str"))) {
|
if (rb_respond_to(port, rb_intern("to_str"))) {
|
||||||
#if 0
|
taint = OBJ_TAINTED(port); /* original taintedness */
|
||||||
arg.taint = OBJ_TAINTED(port); /* original taintedness */
|
|
||||||
StringValue(port); /* possible conversion */
|
StringValue(port); /* possible conversion */
|
||||||
#endif
|
|
||||||
syck_parser_str( parser, RSTRING(port)->ptr, RSTRING(port)->len, NULL );
|
syck_parser_str( parser, RSTRING(port)->ptr, RSTRING(port)->len, NULL );
|
||||||
}
|
}
|
||||||
else if (rb_respond_to(port, s_read)) {
|
else if (rb_respond_to(port, s_read)) {
|
||||||
if (rb_respond_to(port, s_binmode)) {
|
if (rb_respond_to(port, s_binmode)) {
|
||||||
rb_funcall2(port, s_binmode, 0, 0);
|
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 );
|
syck_parser_str( parser, (char *)port, 0, rb_syck_io_str_read );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_raise(rb_eTypeError, "instance of IO needed");
|
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;
|
bonus = (struct parser_xtra *)p->bonus;
|
||||||
if ( bonus->proc != 0 )
|
if ( bonus->taint) OBJ_TAINT( obj );
|
||||||
{
|
if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, v);
|
||||||
rb_funcall(bonus->proc, s_call, 1, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
rb_iv_set(obj, "@value", v);
|
rb_iv_set(obj, "@value", v);
|
||||||
rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj);
|
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;
|
bonus = (struct parser_xtra *)p->bonus;
|
||||||
if ( bonus->proc != 0 )
|
if ( bonus->taint) OBJ_TAINT( obj );
|
||||||
{
|
if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj);
|
||||||
rb_funcall(bonus->proc, s_call, 1, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( check_transfers == 1 && n->type_id != NULL )
|
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);
|
rb_scan_args(argc, argv, "11", &port, &proc);
|
||||||
Data_Get_Struct(self, SyckParser, parser);
|
Data_Get_Struct(self, SyckParser, parser);
|
||||||
syck_parser_assign_io(parser, port);
|
|
||||||
|
|
||||||
model = rb_hash_aref( rb_iv_get( self, "@options" ), sym_model );
|
model = rb_hash_aref( rb_iv_get( self, "@options" ), sym_model );
|
||||||
syck_set_model( parser, model );
|
syck_set_model( parser, model );
|
||||||
|
|
||||||
|
bonus.taint = syck_parser_assign_io(parser, port);
|
||||||
bonus.data = hash = rb_hash_new();
|
bonus.data = hash = rb_hash_new();
|
||||||
if ( NIL_P( proc ) ) bonus.proc = 0;
|
if ( NIL_P( proc ) ) bonus.proc = 0;
|
||||||
else bonus.proc = proc;
|
else bonus.proc = proc;
|
||||||
@ -647,11 +642,11 @@ syck_parser_load_documents(argc, argv, self)
|
|||||||
|
|
||||||
rb_scan_args(argc, argv, "1&", &port, &proc);
|
rb_scan_args(argc, argv, "1&", &port, &proc);
|
||||||
Data_Get_Struct(self, SyckParser, parser);
|
Data_Get_Struct(self, SyckParser, parser);
|
||||||
syck_parser_assign_io(parser, port);
|
|
||||||
|
|
||||||
model = rb_hash_aref( rb_iv_get( self, "@options" ), sym_model );
|
model = rb_hash_aref( rb_iv_get( self, "@options" ), sym_model );
|
||||||
syck_set_model( parser, model );
|
syck_set_model( parser, model );
|
||||||
|
|
||||||
|
bonus.taint = syck_parser_assign_io(parser, port);
|
||||||
while ( 1 )
|
while ( 1 )
|
||||||
{
|
{
|
||||||
/* Reset hash for tracking nodes */
|
/* Reset hash for tracking nodes */
|
||||||
@ -822,10 +817,6 @@ syck_loader_transfer( self, type, val )
|
|||||||
{
|
{
|
||||||
char *taguri = NULL;
|
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)
|
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_taguri = rb_str_new2("taguri");
|
||||||
VALUE str_xprivate = rb_str_new2("x-private");
|
VALUE str_xprivate = rb_str_new2("x-private");
|
||||||
VALUE parts = rb_str_split( type_uri, ":" );
|
VALUE parts = rb_str_split( type_uri, ":" );
|
||||||
#if 0
|
|
||||||
rb_p(parts);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
scheme = rb_ary_shift( parts );
|
scheme = rb_ary_shift( parts );
|
||||||
|
|
||||||
@ -884,10 +872,6 @@ syck_loader_transfer( self, type, val )
|
|||||||
name = rb_ary_shift( col );
|
name = rb_ary_shift( col );
|
||||||
type_proc = 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 ) )
|
if ( rb_respond_to( type_proc, s_call ) )
|
||||||
|
@ -50,7 +50,7 @@ syck_io_file_read( char *buf, SyckIoFile *file, long max_size, long skip )
|
|||||||
ASSERT( file != NULL );
|
ASSERT( file != NULL );
|
||||||
|
|
||||||
max_size -= skip;
|
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;
|
len += skip;
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ syck_add_sym( SyckParser *p, char *data )
|
|||||||
{
|
{
|
||||||
p->syms = st_init_numtable();
|
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 );
|
st_insert( p->syms, id, (st_data_t)data );
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#define SYCK_YAML_MAJOR 1
|
#define SYCK_YAML_MAJOR 1
|
||||||
#define SYCK_YAML_MINOR 0
|
#define SYCK_YAML_MINOR 0
|
||||||
|
|
||||||
#define SYCK_VERSION "0.38"
|
#define SYCK_VERSION "0.39"
|
||||||
#define YAML_DOMAIN "yaml.org,2002"
|
#define YAML_DOMAIN "yaml.org,2002"
|
||||||
|
|
||||||
#include <stdio.h>
|
#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 {
|
struct _syck_parser {
|
||||||
/* Root node */
|
/* Root node */
|
||||||
SYMID root, root_on_error;
|
SYMID root, root_on_error;
|
||||||
@ -180,25 +200,15 @@ struct _syck_parser {
|
|||||||
/* EOF flag */
|
/* EOF flag */
|
||||||
int eof;
|
int eof;
|
||||||
union {
|
union {
|
||||||
struct _syck_file {
|
SyckIoFile *file;
|
||||||
FILE *ptr;
|
SyckIoStr *str;
|
||||||
SyckIoFileRead read;
|
|
||||||
} *file;
|
|
||||||
struct _syck_str {
|
|
||||||
char *beg, *ptr, *end;
|
|
||||||
SyckIoStrRead read;
|
|
||||||
} *str;
|
|
||||||
} io;
|
} io;
|
||||||
/* Symbol table for anchors */
|
/* Symbol table for anchors */
|
||||||
st_table *anchors, *bad_anchors;
|
st_table *anchors, *bad_anchors;
|
||||||
/* Optional symbol table for SYMIDs */
|
/* Optional symbol table for SYMIDs */
|
||||||
st_table *syms;
|
st_table *syms;
|
||||||
/* Levels of indentation */
|
/* Levels of indentation */
|
||||||
struct _syck_level {
|
SyckLevel *levels;
|
||||||
int spaces;
|
|
||||||
char *domain;
|
|
||||||
enum syck_level_status status;
|
|
||||||
} *levels;
|
|
||||||
int lvl_idx;
|
int lvl_idx;
|
||||||
int lvl_capa;
|
int lvl_capa;
|
||||||
void *bonus;
|
void *bonus;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user