Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Naur openssl-1.0.1q-clean/crypto/asn1/a_strnid.c openssl-1.0.1q-modified/crypto/asn1/a_strnid.c
- --- openssl-1.0.1q-clean/crypto/asn1/a_strnid.c 2015-12-03 14:04:23.000000000 +0000
- +++ openssl-1.0.1q-modified/crypto/asn1/a_strnid.c 2015-12-10 10:34:02.436653664 +0000
- @@ -133,7 +133,7 @@
- ASN1_STRING_TABLE *tbl;
- ASN1_STRING *str = NULL;
- unsigned long mask;
- - int ret;
- + int ret = 0;
- if (!out)
- out = &str;
- tbl = ASN1_STRING_TABLE_get(nid);
- @@ -141,8 +141,64 @@
- mask = tbl->mask;
- if (!(tbl->flags & STABLE_NO_MASK))
- mask &= global_mask;
- - ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask,
- - tbl->minsize, tbl->maxsize);
- + if (mask & B_ASN1_BIT_STRING) {
- + int len = (inlen < 0 ? strlen((const char*)in) : inlen);
- + unsigned char *dest = NULL;
- + unsigned char *source = (unsigned char*)in;
- + int i = 0;
- + if (len > 2 && source[0]=='0' && source[1]=='x') {
- + for (i = 2; i < len; i++) {
- + if (!isxdigit(source[i])) {
- + ret = -1;
- + break;
- + }
- + }
- + if (ret >= 0) {
- + /* we have a hex string */
- + int newlen = ((len - 2) / 2) + (len % 2);
- + source = (unsigned char *)OPENSSL_malloc(newlen);
- + for (i = len - 2; i > 0 && ret >= 0; i = i - 2) {
- + unsigned char buf[3];
- + char *endptr = NULL;
- + buf[0] = i == 1 ? '0' : in[i];
- + buf[1] = in[i+1];
- + buf[2] = '\0';
- + source[(i - 2 + (i % 2)) / 2] = (unsigned int)strtoul((const char*)buf,&endptr,16);
- + if (*endptr != '\0') {
- + ret = -1;
- + }
- + }
- + len = newlen;
- + }
- + }
- +
- + if (ret >= 0) {
- + dest = (unsigned char *)OPENSSL_malloc(len);
- + if (dest == NULL) {
- + ret = ERR_R_MALLOC_FAILURE;
- + } else {
- + memcpy(dest, source, len);
- +
- + if (source != (unsigned char*)in) {
- + OPENSSL_free(source);
- + source = NULL;
- + }
- +
- + (*out)->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear */
- + (*out)->flags |= ASN1_STRING_FLAG_BITS_LEFT; /* set */
- +
- + (*out)->length = len;
- + if ((*out)->data != NULL)
- + OPENSSL_free((*out)->data);
- + (*out)->data = dest;
- + (*out)->type = V_ASN1_BIT_STRING;
- + ret = 1;
- + }
- + }
- + } else {
- + ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask,
- + tbl->minsize, tbl->maxsize);
- + }
- } else
- ret =
- ASN1_mbstring_copy(out, in, inlen, inform,
- @@ -192,7 +248,8 @@
- {NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
- {NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
- {NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK},
- - {NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}
- + {NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
- + {NID_x500UniqueIdentifier, 0, 0, B_ASN1_BIT_STRING, STABLE_NO_MASK}
- };
- static int sk_table_cmp(const ASN1_STRING_TABLE *const *a,
Advertisement
Add Comment
Please, Sign In to add comment