Package: ruby-password / 0.5.3-4

newer-ruby.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Description: port to newer versions of Ruby
 replace STR2CTR by StringValuePtr and change the way ASCII code of a character
 is computed.
Author: C├ędric Boutillier <boutil@debian.org>
Forwarded: no
Last-Update: 2013-09-26

--- a/rbcrack.c
+++ b/rbcrack.c
@@ -59,12 +59,12 @@
     /* pop the one and only argument we may have been passed */
     dict = rb_ary_pop(args);
 
-    if (dict == Qnil || strcmp(STR2CSTR(dict), "") == 0) {
+    if (dict == Qnil || strcmp(StringValuePtr(dict), "") == 0) {
 	/* no argument passed, so use default location from rbcrack.h */
 	dict = rb_str_new2(CRACK_DICT);
     } else {
-	buffer = malloc(strlen(STR2CSTR(dict)) + 8);
-	strcpy(buffer, STR2CSTR(dict));
+	buffer = malloc(strlen(StringValuePtr(dict)) + 8);
+	strcpy(buffer, StringValuePtr(dict));
 	strcat(buffer, ".pwd");
 
 	if (access(buffer, R_OK) != 0) {
@@ -77,7 +77,7 @@
     }
 
     /* perform check on password */
-    objection = FascistCheck(STR2CSTR(self), STR2CSTR(dict));
+    objection = FascistCheck(StringValuePtr(self), StringValuePtr(dict));
 
     /* return true on success; raise an exception otherwise */
     if (objection) {
--- a/lib/password.rb
+++ b/lib/password.rb
@@ -327,7 +327,7 @@
 	if feature_flags.include? ONE_DIGIT
 
 	  if ! first and rand( 10 ) < 3
-	    pw << ( rand( 10 ) + ?0 ).chr
+	    pw << ( rand( 10 ) + '0'.ord ).chr
 	    feature_flags.delete ONE_DIGIT
 
 	    first = true