Skip to content

Commit

Permalink
StringValueCStr() raises an exception if passed a string which contai…
Browse files Browse the repository at this point in the history
…ns null byte
  • Loading branch information
Watson1978 committed Jul 3, 2012
1 parent 12b6f4a commit 507e4a9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 16 deletions.
2 changes: 0 additions & 2 deletions spec/frozen/tags/macruby/core/kernel/Integer_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/frozen/tags/macruby/core/kernel/exec_tags.txt

This file was deleted.

6 changes: 0 additions & 6 deletions spec/frozen/tags/macruby/core/kernel/spawn_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/frozen/tags/macruby/core/process/exec_tags.txt

This file was deleted.

3 changes: 0 additions & 3 deletions spec/frozen/tags/macruby/core/process/spawn_tags.txt

This file was deleted.

11 changes: 9 additions & 2 deletions string.c
Expand Up @@ -6579,13 +6579,20 @@ char *
rb_string_value_cstr(volatile VALUE *ptr)
{
VALUE str = rb_string_value(ptr);
return (char *)rb_str_cstr(str);
const char *s = rb_str_cstr(str);
long len = RSTRING_LEN(str);

if (len != strlen(s)) {
rb_raise(rb_eArgError, "string contains null byte");
}
return (char *)s;
}

char *
rb_string_value_ptr(volatile VALUE *ptr)
{
return rb_string_value_cstr(ptr);
VALUE str = rb_string_value(ptr);
return (char*)rb_str_cstr(str);
}

VALUE
Expand Down

0 comments on commit 507e4a9

Please sign in to comment.