From: FdaSilvaYY Date: Sun, 3 Jul 2016 20:09:02 +0000 (+0200) Subject: Constify ASN1_TYPE_get, ASN1_STRING_type, ASN1_STRING_to_UTF8, ASN1_TYPE_get_octetstr... X-Git-Tag: OpenSSL_1_1_0-pre6~103 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=08275a29c10b23a5f38597d58f823c3ccb9540ab;p=oweals%2Fopenssl.git Constify ASN1_TYPE_get, ASN1_STRING_type, ASN1_STRING_to_UTF8, ASN1_TYPE_get_octetstring & co... Reviewed-by: Matt Caswell Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/1300) --- diff --git a/crypto/asn1/a_strex.c b/crypto/asn1/a_strex.c index eb55c6b5d7..7bcc6cda8e 100644 --- a/crypto/asn1/a_strex.c +++ b/crypto/asn1/a_strex.c @@ -569,7 +569,7 @@ int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags) * in output string or a negative error code */ -int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in) +int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in) { ASN1_STRING stmp, *str = &stmp; int mbflag, type, ret; diff --git a/crypto/asn1/a_type.c b/crypto/asn1/a_type.c index 8547513e3a..42dbcbfffc 100644 --- a/crypto/asn1/a_type.c +++ b/crypto/asn1/a_type.c @@ -13,7 +13,7 @@ #include #include "asn1_locl.h" -int ASN1_TYPE_get(ASN1_TYPE *a) +int ASN1_TYPE_get(const ASN1_TYPE *a) { if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL)) return (a->type); diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c index aecb4adb5b..92604ead86 100644 --- a/crypto/asn1/asn1_lib.c +++ b/crypto/asn1/asn1_lib.c @@ -354,7 +354,7 @@ void ASN1_STRING_length_set(ASN1_STRING *x, int len) x->length = len; } -int ASN1_STRING_type(ASN1_STRING *x) +int ASN1_STRING_type(const ASN1_STRING *x) { return x->type; } diff --git a/crypto/asn1/evp_asn1.c b/crypto/asn1/evp_asn1.c index f7416e5550..ad3a5bc7a0 100644 --- a/crypto/asn1/evp_asn1.c +++ b/crypto/asn1/evp_asn1.c @@ -27,7 +27,7 @@ int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len) } /* int max_len: for returned value */ -int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len) +int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len) { int ret, num; unsigned char *p; @@ -80,7 +80,7 @@ int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data, * we return the actual length... */ /* int max_len: for returned value */ -int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, +int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num, unsigned char *data, int max_len) { asn1_int_oct *atmp = NULL; diff --git a/crypto/x509/x_name.c b/crypto/x509/x_name.c index ebb66a1aef..a2eb709c83 100644 --- a/crypto/x509/x_name.c +++ b/crypto/x509/x_name.c @@ -35,7 +35,7 @@ static void x509_name_ex_free(ASN1_VALUE **val, const ASN1_ITEM *it); static int x509_name_encode(X509_NAME *a); static int x509_name_canon(X509_NAME *a); -static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in); +static int asn1_string_canon(ASN1_STRING *out, const ASN1_STRING *in); static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) * intname, unsigned char **in); @@ -380,7 +380,7 @@ static int x509_name_canon(X509_NAME *a) | B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_IA5STRING \ | B_ASN1_VISIBLESTRING) -static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in) +static int asn1_string_canon(ASN1_STRING *out, const ASN1_STRING *in) { unsigned char *to, *from; int len, i; diff --git a/doc/crypto/ASN1_STRING_length.pod b/doc/crypto/ASN1_STRING_length.pod index a51d984454..a57de1c093 100644 --- a/doc/crypto/ASN1_STRING_length.pod +++ b/doc/crypto/ASN1_STRING_length.pod @@ -19,9 +19,9 @@ ASN1_STRING utility functions int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); - int ASN1_STRING_type(ASN1_STRING *x); + int ASN1_STRING_type(const ASN1_STRING *x); - int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); + int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in); =head1 DESCRIPTION diff --git a/doc/crypto/ASN1_TYPE_get.pod b/doc/crypto/ASN1_TYPE_get.pod index d4233039e8..70c56878b8 100644 --- a/doc/crypto/ASN1_TYPE_get.pod +++ b/doc/crypto/ASN1_TYPE_get.pod @@ -9,7 +9,7 @@ functions #include - int ASN1_TYPE_get(ASN1_TYPE *a); + int ASN1_TYPE_get(const ASN1_TYPE *a); void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); diff --git a/include/openssl/asn1.h b/include/openssl/asn1.h index e313109d22..f1c00587a7 100644 --- a/include/openssl/asn1.h +++ b/include/openssl/asn1.h @@ -516,7 +516,7 @@ typedef struct BIT_STRING_BITNAME_st { DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) -int ASN1_TYPE_get(ASN1_TYPE *a); +int ASN1_TYPE_get(const ASN1_TYPE *a); void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); @@ -549,7 +549,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); int ASN1_STRING_length(const ASN1_STRING *x); void ASN1_STRING_length_set(ASN1_STRING *x, int n); -int ASN1_STRING_type(ASN1_STRING *x); +int ASN1_STRING_type(const ASN1_STRING *x); unsigned char *ASN1_STRING_data(ASN1_STRING *x); DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) @@ -723,7 +723,7 @@ int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); # endif -int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); +int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in); void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x); @@ -765,10 +765,10 @@ const char *ASN1_tag2str(int tag); int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len); -int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len); +int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len); int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data, int len); -int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, +int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num, unsigned char *data, int max_len); void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);