From e5e932d212aea2f9acceb4779b44f123050347a7 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Sun, 30 May 1999 15:40:21 +0000 Subject: [PATCH] Another safe stack. --- apps/nseq.c | 10 +++++----- crypto/asn1/nsseq.c | 20 +++++++++++--------- crypto/x509/x509.h | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/apps/nseq.c b/apps/nseq.c index 5e74082cad..2fdba2d6b9 100644 --- a/apps/nseq.c +++ b/apps/nseq.c @@ -123,11 +123,11 @@ int MAIN(int argc, char **argv) if (toseq) { seq = NETSCAPE_CERT_SEQUENCE_new(); - seq->certs = sk_new(NULL); + seq->certs = sk_X509_new(NULL); while((x509 = PEM_read_bio_X509(in, NULL, NULL))) - sk_push(seq->certs, (char *)x509); + sk_X509_push(seq->certs,x509); - if(!sk_num(seq->certs)) + if(!sk_X509_num(seq->certs)) { BIO_printf (bio_err, "Error reading certs file %s\n", infile); ERR_print_errors(bio_err); @@ -144,8 +144,8 @@ int MAIN(int argc, char **argv) goto end; } - for(i = 0; i < sk_num(seq->certs); i++) { - x509 = (X509 *) sk_value(seq->certs, i); + for(i = 0; i < sk_X509_num(seq->certs); i++) { + x509 = sk_X509_value(seq->certs, i); dump_cert_text(out, x509); PEM_write_bio_X509(out, x509); } diff --git a/crypto/asn1/nsseq.c b/crypto/asn1/nsseq.c index bb447d76e8..417d024b81 100644 --- a/crypto/asn1/nsseq.c +++ b/crypto/asn1/nsseq.c @@ -70,14 +70,14 @@ int i2d_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE *a, unsigned char **pp) int v = 0; M_ASN1_I2D_vars(a); M_ASN1_I2D_len (a->type, i2d_ASN1_OBJECT); - M_ASN1_I2D_len_EXP_SEQUENCE_opt(a->certs, i2d_X509, 0, - V_ASN1_SEQUENCE, v); + M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(X509,a->certs,i2d_X509,0, + V_ASN1_SEQUENCE,v); M_ASN1_I2D_seq_total(); M_ASN1_I2D_put (a->type, i2d_ASN1_OBJECT); - M_ASN1_I2D_put_EXP_SEQUENCE_opt(a->certs, i2d_X509, 0, - V_ASN1_SEQUENCE, v); + M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509,a->certs,i2d_X509,0, + V_ASN1_SEQUENCE,v); M_ASN1_I2D_finish(); } @@ -102,15 +102,17 @@ NETSCAPE_CERT_SEQUENCE *d2i_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE **a, M_ASN1_D2I_Init(); M_ASN1_D2I_start_sequence(); M_ASN1_D2I_get (ret->type, d2i_ASN1_OBJECT); - M_ASN1_D2I_get_EXP_set_opt(ret->certs, d2i_X509, X509_free, 0, - V_ASN1_SEQUENCE); - M_ASN1_D2I_Finish(a, NETSCAPE_CERT_SEQUENCE_free, ASN1_F_D2I_NETSCAPE_CERT_SEQUENCE); + M_ASN1_D2I_get_EXP_set_opt_type(X509,ret->certs,d2i_X509,X509_free,0, + V_ASN1_SEQUENCE); + M_ASN1_D2I_Finish(a, NETSCAPE_CERT_SEQUENCE_free, + ASN1_F_D2I_NETSCAPE_CERT_SEQUENCE); } void NETSCAPE_CERT_SEQUENCE_free (NETSCAPE_CERT_SEQUENCE *a) { if (a == NULL) return; ASN1_OBJECT_free(a->type); - if(a->certs) sk_pop_free(a->certs, X509_free); - Free ((char *)a); + if(a->certs) + sk_X509_pop_free(a->certs, X509_free); + Free (a); } diff --git a/crypto/x509/x509.h b/crypto/x509/x509.h index 30de3950f5..693d42113c 100644 --- a/crypto/x509/x509.h +++ b/crypto/x509/x509.h @@ -331,7 +331,7 @@ typedef struct Netscape_spki_st typedef struct Netscape_certificate_sequence { ASN1_OBJECT *type; - STACK /* X509 */ *certs; + STACK_OF(X509) *certs; } NETSCAPE_CERT_SEQUENCE; #ifndef HEADER_BN_H -- 2.25.1