1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (rb_str_crypt): crypt(3) may return NULL.

Latest glibc (2.16?) crypt(3) actually returns NULL. [Bug #7312]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-11-09 04:06:45 +00:00
parent 1c0323adbc
commit dfb44feefe
2 changed files with 11 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Fri Nov 9 12:58:13 2012 NARUSE, Yui <naruse@ruby-lang.org>
* string.c (rb_str_crypt): crypt(3) may return NULL.
Latest glibc (2.16?) crypt(3) actually returns NULL. [Bug #7312]
Fri Nov 9 12:07:06 2012 Akinori MUSHA <knu@iDaemons.org>
* include/ruby/ruby.h (alloca), eval_intern.h (alloca), gc.c

View file

@ -6909,6 +6909,7 @@ rb_str_crypt(VALUE str, VALUE salt)
extern char *crypt(const char *, const char *);
VALUE result;
const char *s, *saltp;
char *res;
#ifdef BROKEN_CRYPT
char salt_8bit_clean[3];
#endif
@ -6928,7 +6929,11 @@ rb_str_crypt(VALUE str, VALUE salt)
saltp = salt_8bit_clean;
}
#endif
result = rb_str_new2(crypt(s, saltp));
res = crypt(s, saltp);
if (!res) {
rb_sys_fail("crypt");
}
result = rb_str_new2(res);
OBJ_INFECT(result, str);
OBJ_INFECT(result, salt);
return result;