summaryrefslogtreecommitdiff
path: root/ext/etc
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-30 08:35:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-30 08:35:23 +0000
commit1852b4a8660ee8e71997f81cee4903c6eb23f306 (patch)
tree651e33765db8a4d18ab102ea1ef38fc6f5deafc2 /ext/etc
parentd00c9d7e0609f6d9b6141e1dde6fa9321de70b85 (diff)
ext: check if null byte is contained
[ruby-dev:50267] [Bug #13953] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/etc')
-rw-r--r--ext/etc/etc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 5d964ba..46857c6 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -215,9 +215,10 @@ etc_getpwnam(VALUE obj, VALUE nam)
{
#ifdef HAVE_GETPWENT
struct passwd *pwd;
+ const char *p = StringValueCStr(nam);
- SafeStringValue(nam);
- pwd = getpwnam(RSTRING_PTR(nam));
+ rb_check_safe_obj(nam);
+ pwd = getpwnam(p);
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %"PRIsVALUE, nam);
return setup_passwd(pwd);
#else
@@ -458,9 +459,10 @@ etc_getgrnam(VALUE obj, VALUE nam)
{
#ifdef HAVE_GETGRENT
struct group *grp;
+ const char *p = StringValueCStr(nam);
- SafeStringValue(nam);
- grp = getgrnam(RSTRING_PTR(nam));
+ rb_check_safe_obj(nam);
+ grp = getgrnam(p);
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %"PRIsVALUE, nam);
return setup_group(grp);
#else