1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-16 06:25:03 -05:00

x509asn1: replace single char with an array

Although safe in this context, using a single char as an array may
cause invalid accesses to adjacent memory locations.

Detected by Coverity.
This commit is contained in:
Patrick Monnerat 2019-02-18 15:40:34 +01:00
parent af143ef45e
commit fa86d32d59

View File

@ -417,13 +417,13 @@ static const char *OID2str(const char *beg, const char *end, bool symbolic)
char *buf = (char *) NULL; char *buf = (char *) NULL;
const curl_OID * op; const curl_OID * op;
int n; int n;
char dummy; char dummy[1];
/* Convert an ASN.1 OID into its dotted or symbolic string representation. /* Convert an ASN.1 OID into its dotted or symbolic string representation.
Return the dynamically allocated string, or NULL if an error occurs. */ Return the dynamically allocated string, or NULL if an error occurs. */
if(beg < end) { if(beg < end) {
n = encodeOID(&dummy, 0, beg, end); n = encodeOID(dummy, 0, beg, end);
if(n >= 0) { if(n >= 0) {
buf = malloc(n + 1); buf = malloc(n + 1);
if(buf) { if(buf) {