GH769: Reuse strndup()
Reviewed-by: Matt Caswell <matt@openssl.org> Signed-off-by: Rich Salz <rsalz@akamai.com>
This commit is contained in:
parent
aacfb134be
commit
5e04cfdef3
2 changed files with 2 additions and 6 deletions
|
@ -577,11 +577,9 @@ static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx)
|
||||||
if ((gen->d.otherName->value = ASN1_generate_v3(p + 1, ctx)) == NULL)
|
if ((gen->d.otherName->value = ASN1_generate_v3(p + 1, ctx)) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
objlen = p - value;
|
objlen = p - value;
|
||||||
objtmp = OPENSSL_malloc(objlen + 1);
|
objtmp = OPENSSL_strndup(value, objlen);
|
||||||
if (objtmp == NULL)
|
if (objtmp == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
strncpy(objtmp, value, objlen);
|
|
||||||
objtmp[objlen] = 0;
|
|
||||||
gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0);
|
gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0);
|
||||||
OPENSSL_free(objtmp);
|
OPENSSL_free(objtmp);
|
||||||
if (!gen->d.otherName->type_id)
|
if (!gen->d.otherName->type_id)
|
||||||
|
|
|
@ -177,13 +177,11 @@ static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
|
||||||
ctmp.value = cnf->value;
|
ctmp.value = cnf->value;
|
||||||
if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0))
|
if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0))
|
||||||
goto err;
|
goto err;
|
||||||
if ((objtmp = OPENSSL_malloc(objlen + 1)) == NULL) {
|
if ((objtmp = OPENSSL_strndup(cnf->name, objlen)) == NULL) {
|
||||||
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
|
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
|
||||||
ERR_R_MALLOC_FAILURE);
|
ERR_R_MALLOC_FAILURE);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
strncpy(objtmp, cnf->name, objlen);
|
|
||||||
objtmp[objlen] = 0;
|
|
||||||
acc->method = OBJ_txt2obj(objtmp, 0);
|
acc->method = OBJ_txt2obj(objtmp, 0);
|
||||||
if (!acc->method) {
|
if (!acc->method) {
|
||||||
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
|
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
|
||||||
|
|
Loading…
Reference in a new issue