Skip to content

Commit c3384f3

Browse files
committed
Fix small correctness issues from pen-test
1 parent 64d6586 commit c3384f3

5 files changed

Lines changed: 19 additions & 1 deletion

File tree

crypto/bio/bio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ int BIO_write(BIO *bio, const void *in, int inl) {
305305
}
306306

307307
int BIO_write_ex(BIO *bio, const void *data, size_t data_len, size_t *written_bytes) {
308+
if (written_bytes != NULL) {
309+
*written_bytes = 0;
310+
}
308311
if (bio == NULL) {
309312
OPENSSL_PUT_ERROR(BIO, BIO_R_NULL_PARAMETER);
310313
return 0;

crypto/conf/conf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,11 @@ int NCONF_load_bio(CONF *conf, BIO *in, long *out_error_line) {
484484
// we now have a line with trailing \r\n removed
485485

486486
// i is the number of bytes
487+
// Ensure addition doesn't overflow and corrupt the signed buffer position
488+
if (i > INT_MAX - bufnum) {
489+
OPENSSL_PUT_ERROR(CONF, ERR_R_OVERFLOW);
490+
goto err;
491+
}
487492
bufnum += i;
488493

489494
v = NULL;

crypto/fipsmodule/bn/bytes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ BIGNUM *BN_le2bn(const uint8_t *in, size_t len, BIGNUM *ret) {
9191
return NULL;
9292
}
9393
ret->width = (int)num_words;
94+
ret->neg = 0;
9495

9596
bn_little_endian_to_words(ret->d, ret->width, in, len);
9697

crypto/pem/pem_lib.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ int PEM_write(FILE *fp, const char *name, const char *header,
483483

484484
int PEM_write_bio(BIO *bp, const char *name, const char *header,
485485
const unsigned char *data, long len) {
486-
int nlen, n, i, j, outl;
486+
int nlen, n, i, outl;
487+
long j;
487488
unsigned char *buf = NULL;
488489
EVP_ENCODE_CTX ctx;
489490
int reason = ERR_R_BUF_LIB;

crypto/x509/x_crl.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
138138
X509_CRL_get_ext_d2i(crl, NID_issuing_distribution_point, &i, NULL);
139139
if (crl->idp != NULL) {
140140
if (!setup_idp(crl, crl->idp)) {
141+
ISSUING_DIST_POINT_free(crl->idp);
142+
crl->idp = NULL;
141143
return 0;
142144
}
143145
} else if (i != -1) {
@@ -147,6 +149,8 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
147149
crl->akid =
148150
X509_CRL_get_ext_d2i(crl, NID_authority_key_identifier, &i, NULL);
149151
if (crl->akid == NULL && i != -1) {
152+
ISSUING_DIST_POINT_free(crl->idp);
153+
crl->idp = NULL;
150154
return 0;
151155
}
152156

@@ -169,6 +173,10 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
169173
}
170174

171175
if (!crl_parse_entry_extensions(crl)) {
176+
AUTHORITY_KEYID_free(crl->akid);
177+
crl->akid = NULL;
178+
ISSUING_DIST_POINT_free(crl->idp);
179+
crl->idp = NULL;
172180
return 0;
173181
}
174182

0 commit comments

Comments
 (0)