Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CMS_get0_signers() badly named?

59 views
Skip to first unread message

Phillip Hellewell

unread,
May 22, 2013, 8:18:36 PM5/22/13
to
Looking at the implementation of CMS_get0_signers(), it looks like it creates a new stack of X509 that I will have to free.

Isn't the convention to use a "1" if the return values needs to be freed, and "0" if not?  So shouldn't this function be named CMS_get1_signers()?  (Note that CMS_get1_crls() is correctly named with a "1".)

Probably too late to change it now though, huh?

Phillip

Dr. Stephen Henson

unread,
May 23, 2013, 7:33:08 AM5/23/13
to
It's midway between 1 and 0 ;-)

The STACK needs to be freed buty not each individual member. So you call
sk_X509_free and NOT sk_X509_pop_free().

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openss...@openssl.org
Automated List Manager majo...@openssl.org

Phillip Hellewell

unread,
May 23, 2013, 11:44:53 AM5/23/13
to
On Thu, May 23, 2013 at 5:33 AM, Dr. Stephen Henson <st...@openssl.org> wrote:
On Wed, May 22, 2013, Phillip Hellewell wrote:

> Looking at the implementation of CMS_get0_signers(), it looks like it
> creates a new stack of X509 that I will have to free.

It's midway between 1 and 0 ;-)

The STACK needs to be freed buty not each individual member. So you call
sk_X509_free and NOT sk_X509_pop_free().

Ah, I see.  Hey, we should come up with a new prefix like "0_5" for that (j/k).

So just to confirm:
    CMS_get0_signers(): free with sk_X509_free()
    CMS_get1_certs(): free with sk_X509_pop_free()
    CMS_get1_crls(): free with sk_X509_CRL_pop_free()

Phillip
0 new messages