diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-09 04:06:45 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-09 04:06:45 +0000 |
commit | dfb44feefeb837bae561769e5f1a30276e70b0a8 (patch) | |
tree | 15b7d1fa3fcde6a75cacd1c8a025ec5348dc0204 /string.c | |
parent | 1c0323adbc390c40453c4ad02150e26b55e0dbf5 (diff) | |
download | ruby-dfb44feefeb837bae561769e5f1a30276e70b0a8.tar.gz |
* 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
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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; |