Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merge revision(s) 37572,37622,37766,37773: [Backport #7527]

	* string.c (rb_str_crypt): crypt(3) may return NULL.
	  Latest glibc (2.16?) crypt(3) actually returns NULL. [Bug #7312]

	* test/ruby/test_m17n_comb.rb (test_str_crypt): Use RbConfig to get
	  libc's directory. Patched by Vit Ondruch [ruby-core:49763] [Bug #7312]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@38503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit d92d9a2661d62faf4a95a400109fd0c9f0ece256 1 parent e85d6f8
unak unak authored
Showing with 27 additions and 2 deletions.
  1. +10 −0 ChangeLog
  2. +6 −1 string.c
  3. +10 −0 test/ruby/test_m17n_comb.rb
  4. +1 −1  version.h
10 ChangeLog
View
@@ -1,3 +1,13 @@
+Thu Dec 20 18:37:45 2012 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * test/ruby/test_m17n_comb.rb (test_str_crypt): Use RbConfig to get
+ libc's directory. Patched by Vit Ondruch [ruby-core:49763] [Bug #7312]
+
+Thu Dec 20 18:37:45 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]
+
Thu Dec 20 18:36:19 2012 Naohisa Goto <ngotogenome@gmail.com>
* ext/dl/lib/dl/func.rb (DL::Function#bind): When Fiddle is used,
7 string.c
View
@@ -6775,6 +6775,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
@@ -6794,7 +6795,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;
10 test/ruby/test_m17n_comb.rb
View
@@ -777,7 +777,17 @@ def test_str_count
end
def test_str_crypt
+ begin
+ # glibc 2.16 or later denies salt contained other than [0-9A-Za-z./] #7312
+ glibcver = `#{RbConfig::CONFIG["libdir"]}/libc.so.6`[/\AGNU C Library.*version ([0-9.]+)/, 1].split('.').map(&:to_i)
+ strict_crypt = (glibcver <=> [2, 16]) > -1
+ rescue
+ end
+
combination(STRINGS, STRINGS) {|str, salt|
+ if strict_crypt
+ next unless salt.ascii_only? && /\A[0-9a-zA-Z.\/]+\z/ =~ salt
+ end
if a(salt).length < 2
assert_raise(ArgumentError) { str.crypt(salt) }
next
2  version.h
View
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 349
+#define RUBY_PATCHLEVEL 350
#define RUBY_RELEASE_DATE "2012-12-20"
#define RUBY_RELEASE_YEAR 2012
Please sign in to comment.
Something went wrong with that request. Please try again.