summaryrefslogtreecommitdiffstats
path: root/crypto/x509
diff options
context:
space:
mode:
authorFdaSilvaYY <fdasilvayy@gmail.com>2016-07-07 23:45:55 +0200
committerRichard Levitte <levitte@openssl.org>2016-08-23 11:47:22 +0200
commit9f5466b9b86607bb62239873e6be2de1fe9f71fb (patch)
tree5726015f77d40cdb31560353bb214eb8d1b24ca5 /crypto/x509
parentbf9d5e483db0683178f43ef74a4ae6577482db83 (diff)
Constify some X509_NAME, ASN1 printing code
ASN1_buf_print, asn1_print_*, X509_NAME_oneline, X509_NAME_print Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/x509')
-rw-r--r--crypto/x509/x509_obj.c4
-rw-r--r--crypto/x509/x509name.c14
-rw-r--r--crypto/x509/x_name.c4
3 files changed, 13 insertions, 9 deletions
diff --git a/crypto/x509/x509_obj.c b/crypto/x509/x509_obj.c
index 76fb0473a9..55dc778bba 100644
--- a/crypto/x509/x509_obj.c
+++ b/crypto/x509/x509_obj.c
@@ -22,9 +22,9 @@
#define NAME_ONELINE_MAX (1024 * 1024)
-char *X509_NAME_oneline(X509_NAME *a, char *buf, int len)
+char *X509_NAME_oneline(const X509_NAME *a, char *buf, int len)
{
- X509_NAME_ENTRY *ne;
+ const X509_NAME_ENTRY *ne;
int i;
int n, lold, l, l1, l2, num, j, type;
const char *s;
diff --git a/crypto/x509/x509name.c b/crypto/x509/x509name.c
index fa84bff434..ae39c75e58 100644
--- a/crypto/x509/x509name.c
+++ b/crypto/x509/x509name.c
@@ -30,7 +30,7 @@ int X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, char *buf
int len)
{
int i;
- ASN1_STRING *data;
+ const ASN1_STRING *data;
i = X509_NAME_get_index_by_OBJ(name, obj, -1);
if (i < 0)
@@ -176,7 +176,7 @@ int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
* if set is -1, append to previous set, 0 'a new one', and 1, prepend to the
* guy we are about to stomp on.
*/
-int X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc,
+int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc,
int set)
{
X509_NAME_ENTRY *new_name = NULL;
@@ -214,7 +214,11 @@ int X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc,
inc = (set == 0) ? 1 : 0;
}
- if ((new_name = X509_NAME_ENTRY_dup(ne)) == NULL)
+ /*
+ * X509_NAME_ENTRY_dup is ASN1 generated code, that can't be easily
+ * const'ified; harmless cast as dup() don't modify its input.
+ */
+ if ((new_name = X509_NAME_ENTRY_dup((X509_NAME_ENTRY *)ne)) == NULL)
goto err;
new_name->set = set;
if (!sk_X509_NAME_ENTRY_insert(sk, new_name, loc)) {
@@ -334,14 +338,14 @@ int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
return (1);
}
-ASN1_OBJECT *X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne)
+ASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne)
{
if (ne == NULL)
return (NULL);
return (ne->object);
}
-ASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne)
+ASN1_STRING *X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne)
{
if (ne == NULL)
return (NULL);
diff --git a/crypto/x509/x_name.c b/crypto/x509/x_name.c
index a7ae31e61e..44307f7c98 100644
--- a/crypto/x509/x_name.c
+++ b/crypto/x509/x_name.c
@@ -290,7 +290,7 @@ static int x509_name_ex_print(BIO *out, ASN1_VALUE **pval,
int indent,
const char *fname, const ASN1_PCTX *pctx)
{
- if (X509_NAME_print_ex(out, (X509_NAME *)*pval,
+ if (X509_NAME_print_ex(out, (const X509_NAME *)*pval,
indent, pctx->nm_flags) <= 0)
return 0;
return 2;
@@ -494,7 +494,7 @@ int X509_NAME_set(X509_NAME **xn, X509_NAME *name)
return (*xn != NULL);
}
-int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
+int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase)
{
char *s, *c, *b;
int l, i;