Hi,

I trying to use openssl stack to store structure, but I have an issue that
latest push always rewrites previous entries, so I have multiple same
entries.
Now I am not sure if I have the push or the print written wrong.

I have a following code:

Header file:
typedef struct MyStrucS_st
{
        int type;
        union {
                X509    *cert;
                ASN1_OBJECT *object;
                } value;
} MyStrucS;
DECLARE_STACK_OF(MyStrucS)
DECLARE_ASN1_FUNCTIONS(MyStrucS)

Source file:

ASN1_CHOICE(MyStrucS) = {
        ASN1_EXP(MyStrucS, value.cert, X509, 0),
        ASN1_EXP(MyStrucS, value.object, ASN1_OBJECT, 1)
} ASN1_CHOICE_END(MyStrucS)

IMPLEMENT_ASN1_FUNCTIONS(MyStrucS)

STACK_OF(MyStrucS) *mystruc = NULL;
mystruc = sk_MyStrucS_new_null();

static int add_new(STACK_OF(MyStrucS) *mystruc, X509 *cert)
{
        RefStruc *certRef0 = RefStruc_new();
        certRef0 = make_me_new_ref(cert);
        if(!sk_MyStrucS_push(mystruc, certRef0)) BIO_printf(bio_err, "push
error\n");

        int t_type;
        for(t_type = 0; t_type < sk_MyStrucS_num(mystruc);t_type++)
        {
                BIO_printf(bio_err, "%i\n", t_type);
                X509_print(bio_err, sk_MyStrucS_value(mystruc,
t_type)->value.cert);
        }
}

certRef0 contains right information everytime, I checked that.

I am calling this function as:

add_new(mystruc, cert1);
<some code - no using anything above>
Add_new(mystruc, cert2);

After first call, I can see info from cert1 printed out.
But when it print stack after 2nd call, both 2 positions are containing info
from cert2, means I get same info written twice.

Any help ? I am lost at this point.

I am using OpenSSl 0.9.8l

Peter
 

__________ Information from ESET Smart Security, version of virus signature
database 4662 (20091205) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to