summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-20 17:17:52 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-20 17:17:52 +0000
commite4de8e756634e95ff3cdbd7563153bc8270fca2e (patch)
tree5c3201101689d42be50fa18dae58fa326cf296f3 /bignum.c
parent6a867d33b5aa4ed67800cd64fe19d2902250bd96 (diff)
* string.c: use StringValueCStr to retrieve paths to system calls.
* string.c (rb_string_value_cstr): check null byte in the string before retrieving C ptr. accessed via macro StringValueCStr. * file.c (sys_fail2): raise error for two operand system calls such as rename, link, symlink. (ruby-bugs PR#1047) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/bignum.c b/bignum.c
index 9839f55..a908a5c 100644
--- a/bignum.c
+++ b/bignum.c
@@ -507,7 +507,12 @@ rb_str_to_inum(str, base, badcheck)
long len;
StringValue(str);
- s = RSTRING(str)->ptr;
+ if (badcheck) {
+ s = StringValueCStr(str);
+ }
+ else {
+ s = RSTRING(str)->ptr;
+ }
if (s) {
len = RSTRING(str)->len;
if (s[len]) { /* no sentinel somehow */
@@ -517,9 +522,6 @@ rb_str_to_inum(str, base, badcheck)
p[len] = '\0';
s = p;
}
- if (badcheck && len != strlen(s)) {
- rb_raise(rb_eArgError, "string for Integer contains null byte");
- }
}
return rb_cstr_to_inum(s, base, badcheck);
}