summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_strnid.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_strnid.c')
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
index ab8417ffab..04789d1c63 100644
--- a/src/lib/libcrypto/asn1/a_strnid.c
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -65,8 +65,9 @@
65 65
66static STACK_OF(ASN1_STRING_TABLE) *stable = NULL; 66static STACK_OF(ASN1_STRING_TABLE) *stable = NULL;
67static void st_free(ASN1_STRING_TABLE *tbl); 67static void st_free(ASN1_STRING_TABLE *tbl);
68static int sk_table_cmp(ASN1_STRING_TABLE **a, ASN1_STRING_TABLE **b); 68static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
69static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b); 69 const ASN1_STRING_TABLE * const *b);
70static int table_cmp(const void *a, const void *b);
70 71
71 72
72/* This is the global mask for the mbstring functions: this is use to 73/* This is the global mask for the mbstring functions: this is use to
@@ -104,9 +105,9 @@ int ASN1_STRING_set_default_mask_asc(char *p)
104 mask = strtoul(p + 5, &end, 0); 105 mask = strtoul(p + 5, &end, 0);
105 if(*end) return 0; 106 if(*end) return 0;
106 } else if(!strcmp(p, "nombstr")) 107 } else if(!strcmp(p, "nombstr"))
107 mask = ~(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING); 108 mask = ~((unsigned long)(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING));
108 else if(!strcmp(p, "pkix")) 109 else if(!strcmp(p, "pkix"))
109 mask = ~B_ASN1_T61STRING; 110 mask = ~((unsigned long)B_ASN1_T61STRING);
110 else if(!strcmp(p, "utf8only")) mask = B_ASN1_UTF8STRING; 111 else if(!strcmp(p, "utf8only")) mask = B_ASN1_UTF8STRING;
111 else if(!strcmp(p, "default")) 112 else if(!strcmp(p, "default"))
112 mask = 0xFFFFFFFFL; 113 mask = 0xFFFFFFFFL;
@@ -132,7 +133,7 @@ ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in,
132 if(tbl) { 133 if(tbl) {
133 mask = tbl->mask; 134 mask = tbl->mask;
134 if(!(tbl->flags & STABLE_NO_MASK)) mask &= global_mask; 135 if(!(tbl->flags & STABLE_NO_MASK)) mask &= global_mask;
135 ret = ASN1_mbstring_ncopy(out, in, inlen, inform, tbl->mask, 136 ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask,
136 tbl->minsize, tbl->maxsize); 137 tbl->minsize, tbl->maxsize);
137 } else ret = ASN1_mbstring_copy(out, in, inlen, inform, DIRSTRING_TYPE & global_mask); 138 } else ret = ASN1_mbstring_copy(out, in, inlen, inform, DIRSTRING_TYPE & global_mask);
138 if(ret <= 0) return NULL; 139 if(ret <= 0) return NULL;
@@ -169,18 +170,22 @@ static ASN1_STRING_TABLE tbl_standard[] = {
169{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0}, 170{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
170{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0}, 171{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
171{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0}, 172{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
173{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
172{NID_name, 1, ub_name, DIRSTRING_TYPE, 0}, 174{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
173{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK} 175{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
176{NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}
174}; 177};
175 178
176static int sk_table_cmp(ASN1_STRING_TABLE **a, ASN1_STRING_TABLE **b) 179static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
180 const ASN1_STRING_TABLE * const *b)
177{ 181{
178 return (*a)->nid - (*b)->nid; 182 return (*a)->nid - (*b)->nid;
179} 183}
180 184
181static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b) 185static int table_cmp(const void *a, const void *b)
182{ 186{
183 return a->nid - b->nid; 187 const ASN1_STRING_TABLE *sa = a, *sb = b;
188 return sa->nid - sb->nid;
184} 189}
185 190
186ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid) 191ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
@@ -192,7 +197,7 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
192 ttmp = (ASN1_STRING_TABLE *) OBJ_bsearch((char *)&fnd, 197 ttmp = (ASN1_STRING_TABLE *) OBJ_bsearch((char *)&fnd,
193 (char *)tbl_standard, 198 (char *)tbl_standard,
194 sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE), 199 sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE),
195 sizeof(ASN1_STRING_TABLE), (int(*)())table_cmp); 200 sizeof(ASN1_STRING_TABLE), table_cmp);
196 if(ttmp) return ttmp; 201 if(ttmp) return ttmp;
197 if(!stable) return NULL; 202 if(!stable) return NULL;
198 idx = sk_ASN1_STRING_TABLE_find(stable, &fnd); 203 idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
@@ -213,7 +218,7 @@ int ASN1_STRING_TABLE_add(int nid,
213 return 0; 218 return 0;
214 } 219 }
215 if(!(tmp = ASN1_STRING_TABLE_get(nid))) { 220 if(!(tmp = ASN1_STRING_TABLE_get(nid))) {
216 tmp = Malloc(sizeof(ASN1_STRING_TABLE)); 221 tmp = OPENSSL_malloc(sizeof(ASN1_STRING_TABLE));
217 if(!tmp) { 222 if(!tmp) {
218 ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, 223 ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD,
219 ERR_R_MALLOC_FAILURE); 224 ERR_R_MALLOC_FAILURE);
@@ -241,7 +246,7 @@ void ASN1_STRING_TABLE_cleanup(void)
241 246
242static void st_free(ASN1_STRING_TABLE *tbl) 247static void st_free(ASN1_STRING_TABLE *tbl)
243{ 248{
244 if(tbl->flags & STABLE_FLAGS_MALLOC) Free(tbl); 249 if(tbl->flags & STABLE_FLAGS_MALLOC) OPENSSL_free(tbl);
245} 250}
246 251
247IMPLEMENT_STACK_OF(ASN1_STRING_TABLE) 252IMPLEMENT_STACK_OF(ASN1_STRING_TABLE)