Skip to content

Commit

Permalink
Add return value check of X509V3_add_value() in X509V3_parse_list()
Browse files Browse the repository at this point in the history
X509V3_add_value() will return 0 on malloc failure, which could lead to
err logic in X509V3_parse_list().

Fix this by adding return value check of X509V3_add_value().

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#18077)
  • Loading branch information
zhou1615 authored and t8m committed Apr 12, 2022
1 parent 42f111a commit bcd5645
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions crypto/x509/v3_utl.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line)
ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_EMPTY_NAME);
goto err;
}
X509V3_add_value(ntmp, NULL, &values);
if (!X509V3_add_value(ntmp, NULL, &values)) {
goto err;
}
}
break;

Expand All @@ -362,7 +364,9 @@ STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line)
ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NULL_VALUE);
goto err;
}
X509V3_add_value(ntmp, vtmp, &values);
if (!X509V3_add_value(ntmp, vtmp, &values)) {
goto err;
}
ntmp = NULL;
q = p + 1;
}
Expand All @@ -376,14 +380,18 @@ STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line)
ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NULL_VALUE);
goto err;
}
X509V3_add_value(ntmp, vtmp, &values);
if (!X509V3_add_value(ntmp, vtmp, &values)) {
goto err;
}
} else {
ntmp = strip_spaces(q);
if (!ntmp) {
ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_EMPTY_NAME);
goto err;
}
X509V3_add_value(ntmp, NULL, &values);
if (!X509V3_add_value(ntmp, NULL, &values)) {
goto err;
}
}
OPENSSL_free(linebuf);
return values;
Expand Down

0 comments on commit bcd5645

Please sign in to comment.