aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--ossl.c5
-rw-r--r--ossl.h1
-rw-r--r--ossl_bn.c4
-rw-r--r--ossl_config.c4
-rw-r--r--ossl_pkey.c2
-rw-r--r--ossl_rand.c8
-rw-r--r--ossl_x509attr.c6
-rw-r--r--ossl_x509cert.c2
-rw-r--r--ossl_x509store.c2
10 files changed, 21 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 96728b3..c348b5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@ ChangeLog for
### CHANGE LOG ###
+Tue, 09 Jul 2002 17:17:43 +0100 -- Michal Rokos <m.rokos@sh.cvut.cz>
+ * Some minor cleanups (bring back RSTRING macro (instead of StringValuePtr) where tested by StringValue)
+
Mon, 1 Jul 2002 15:36:28 +0100 -- Michal Rokos <m.rokos@sh.cvut.cz>
* tc_x509name.rb: NEW (TestCase)
* tc_x509req.rb: NEW (TestCase)
diff --git a/ossl.c b/ossl.c
index c276dd5..0b20b99 100644
--- a/ossl.c
+++ b/ossl.c
@@ -56,7 +56,7 @@ asn1time_to_time(ASN1_TIME *time)
struct tm tm;
if (!time) {
- rb_bug("ASN1_TIME is NULL!");
+ ossl_raise(rb_eTypeError, "ASN1_TIME is NULL!");
}
memset(&tm, 0, sizeof(struct tm));
@@ -102,7 +102,7 @@ string2hex(char *buf, int buf_len, char **hexbuf, int *hexbuf_len)
if (buf_len < 0 || len < buf_len) { /* PARANOIA? */
return -1;
}
- if (!hexbuf) {
+ if (!hexbuf) { /* if no buf, return calculated len */
if (hexbuf_len) {
*hexbuf_len = len;
}
@@ -162,6 +162,7 @@ ossl_raise(VALUE exc, const char *fmt, ...)
* Debug
*/
VALUE dOSSL;
+
#if defined(NT)
void ossl_debug(const char *fmt, ...)
{
diff --git a/ossl.h b/ossl.h
index 4dcbc6d..d81d046 100644
--- a/ossl.h
+++ b/ossl.h
@@ -97,6 +97,7 @@ void ossl_raise(VALUE, const char *, ...);
* Debug
*/
extern VALUE dOSSL;
+
#if !defined(NT)
# define OSSL_Debug(fmt, ...) do { \
if (dOSSL == Qtrue) { \
diff --git a/ossl_bn.c b/ossl_bn.c
index b53b31b..fac4ba3 100644
--- a/ossl_bn.c
+++ b/ossl_bn.c
@@ -115,12 +115,12 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
}
break;
case 10:
- if (!BN_dec2bn(&bn, StringValuePtr(str))) {
+ if (!BN_dec2bn(&bn, RSTRING(str)->ptr)) {
ossl_raise(eBNError, "");
}
break;
case 16:
- if (!BN_hex2bn(&bn, StringValuePtr(str))) {
+ if (!BN_hex2bn(&bn, RSTRING(str)->ptr)) {
ossl_raise(eBNError, "");
}
break;
diff --git a/ossl_config.c b/ossl_config.c
index 4148f8f..a4e46a3 100644
--- a/ossl_config.c
+++ b/ossl_config.c
@@ -45,7 +45,8 @@ ossl_config_s_load(int argc, VALUE *argv, VALUE klass)
VALUE path, obj;
if (rb_scan_args(argc, argv, "01", &path) == 1) {
- filename = StringValuePtr(path);
+ SafeStringValue(path);
+ filename = RSTRING(path)->ptr;
} else {
if (!(filename = CONF_get1_default_config_file())) {
ossl_raise(eConfigError, "");
@@ -75,7 +76,6 @@ ossl_config_s_load(int argc, VALUE *argv, VALUE klass)
err_line, filename);
}
}
-
WrapConfig(klass, obj, conf);
return obj;
diff --git a/ossl_pkey.c b/ossl_pkey.c
index 2301997..d589cb6 100644
--- a/ossl_pkey.c
+++ b/ossl_pkey.c
@@ -54,7 +54,7 @@ ossl_pkey_new_from_file(VALUE filename)
SafeStringValue(filename);
- if (!(fp = fopen(StringValuePtr(filename), "r"))) {
+ if (!(fp = fopen(RSTRING(filename)->ptr, "r"))) {
ossl_raise(ePKeyError, "%s", strerror(errno));
}
/*
diff --git a/ossl_rand.c b/ossl_rand.c
index 5a77856..2e17934 100644
--- a/ossl_rand.c
+++ b/ossl_rand.c
@@ -41,7 +41,7 @@ ossl_rand_load_file(VALUE self, VALUE filename)
{
SafeStringValue(filename);
- if(!RAND_load_file(StringValuePtr(filename), -1)) {
+ if(!RAND_load_file(RSTRING(filename)->ptr, -1)) {
ossl_raise(eRandomError, "");
}
return Qtrue;
@@ -52,7 +52,7 @@ ossl_rand_write_file(VALUE self, VALUE filename)
{
SafeStringValue(filename);
- if (RAND_write_file(StringValuePtr(filename)) == -1) {
+ if (RAND_write_file(RSTRING(filename)->ptr) == -1) {
ossl_raise(eRandomError, "");
}
return Qtrue;
@@ -82,7 +82,7 @@ ossl_rand_egd(VALUE self, VALUE filename)
{
SafeStringValue(filename);
- if(!RAND_egd(StringValuePtr(filename))) {
+ if(!RAND_egd(RSTRING(filename)->ptr)) {
ossl_raise(eRandomError, "");
}
return Qtrue;
@@ -93,7 +93,7 @@ ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len)
{
SafeStringValue(filename);
- if (!RAND_egd_bytes(StringValuePtr(filename), FIX2INT(len))) {
+ if (!RAND_egd_bytes(RSTRING(filename)->ptr, FIX2INT(len))) {
ossl_raise(eRandomError, "");
}
return Qtrue;
diff --git a/ossl_x509attr.c b/ossl_x509attr.c
index db91a64..8e0ae19 100644
--- a/ossl_x509attr.c
+++ b/ossl_x509attr.c
@@ -88,8 +88,8 @@ ossl_x509attr_s_new_from_array(VALUE klass, VALUE ary)
item = RARRAY(ary)->ptr[0];
StringValue(item);
- if (!(nid = OBJ_ln2nid(StringValuePtr(item)))) {
- if (!(nid = OBJ_sn2nid(StringValuePtr(item)))) {
+ if (!(nid = OBJ_ln2nid(RSTRING(item)->ptr))) {
+ if (!(nid = OBJ_sn2nid(RSTRING(item)->ptr))) {
ossl_raise(eX509AttrError, "");
}
}
@@ -98,7 +98,7 @@ ossl_x509attr_s_new_from_array(VALUE klass, VALUE ary)
item = RARRAY(ary)->ptr[1];
StringValuePtr(item);
- if (!(attr = X509_ATTRIBUTE_create(nid, MBSTRING_ASC, StringValuePtr(item)))) {
+ if (!(attr = X509_ATTRIBUTE_create(nid, MBSTRING_ASC, RSTRING(item)->ptr))) {
ossl_raise(eX509AttrError, "");
}
WrapX509Attr(klass, obj, attr);
diff --git a/ossl_x509cert.c b/ossl_x509cert.c
index 7bdc175..343606b 100644
--- a/ossl_x509cert.c
+++ b/ossl_x509cert.c
@@ -64,7 +64,7 @@ ossl_x509_new_from_file(VALUE filename)
SafeStringValue(filename);
- if (!(fp = fopen(StringValuePtr(filename), "r"))) {
+ if (!(fp = fopen(RSTRING(filename)->ptr, "r"))) {
ossl_raise(eX509CertError, "%s", strerror(errno));
}
x509 = PEM_read_X509(fp, NULL, NULL, NULL);
diff --git a/ossl_x509store.c b/ossl_x509store.c
index b941695..4f93753 100644
--- a/ossl_x509store.c
+++ b/ossl_x509store.c
@@ -424,7 +424,7 @@ ossl_x509store_load_locations(VALUE self, VALUE path)
SafeStringValue(path);
- if (!X509_STORE_load_locations(storep->store->ctx, NULL, StringValuePtr(path))) {
+ if (!X509_STORE_load_locations(storep->store->ctx, NULL, RSTRING(path)->ptr)) {
ossl_raise(eX509StoreError, "");
}
return self;