Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > BUG: Ruby 1.8.7 - io.c Argument Error in syscall,"string containsnull byte"

Reply
Thread Tools

BUG: Ruby 1.8.7 - io.c Argument Error in syscall,"string containsnull byte"

 
 
John Carter
Guest
Posts: n/a
 
      06-30-2008
I have opened this as bug...
http://rubyforge.org/tracker/index.p...=426&atid=1698


The following snippet invokes the statfs64 syscall.
bug.rb============================================ ====================
string = " "* 84
p syscall( 268, "/", string.size, string)
string = "\0"* 84
p syscall( 268, "/", string.size, string)
================================================== ====================

If I run this under ruby 1.8.6, both invocations work.

If I run this under ruby 1.8.7, the second one fails with...
ruby -w bug.rb
0
bug.rb:4:in `syscall': string contains null byte (ArgumentError)
from bug.rb:4

The reason is in ruby-1.8.7-p22/io.c in the function rb_f_syscall
there is this code....

if (!NIL_P(v)) {
StringValue(v);
rb_str_modify(v);
arg[i] = (unsigned long)StringValueCStr(v);
}

In ruby 1.8.6 is was

if (!NIL_P(v)) {
StringValue(v);
rb_str_modify(v);
arg[i] = (unsigned long)RSTRING(v)->ptr;
}

The macro StringValueCStr is defined in ruby.h as....
#define StringValueCStr(v) rb_string_value_cstr(&(v))

The function rb_string_value_cstr is defined in string.c as ....

rb_string_value_cstr(ptr)
volatile VALUE *ptr;
{
VALUE str = rb_string_value(ptr);
char *s = RSTRING(str)->ptr;

if (!s || RSTRING(str)->len != strlen(s)) {
rb_raise(rb_eArgError, "string contains null byte");
}
return s;
}

I believe the original 1.8.6 implementation was correct and this
particular changed should be rolled back.

Thanks.



John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : http://www.velocityreviews.com/forums/(E-Mail Removed)
New Zealand


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
function argument dependent on another function argument? Reckoner Python 11 01-19-2009 03:31 AM
Template argument as template argument nw C++ 0 04-14-2008 01:36 PM
Function pointers, variable argument functions calling other variable-argument functions (sort of) S?ren Gammelmark C Programming 1 01-07-2005 09:41 PM
How to pass variable argument list to another function w/ variable argument list? Ben Kial C Programming 1 11-15-2004 01:51 AM
defaulting argument to previous argument Bhushit Joshipura C++ 5 12-30-2003 03:21 PM



Advertisments