Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssl.c unreachable code in PemToDer function #137

Closed
petervas opened this issue Dec 21, 2014 · 1 comment
Closed

ssl.c unreachable code in PemToDer function #137

petervas opened this issue Dec 21, 2014 · 1 comment

Comments

@petervas
Copy link

Hi,

in the following for loop the header and footer can never be assigned BEGIN_DSA_PRIV and END_DSA_PRIV, respectively.

    /* find header */
    for (;;) {
        headerEnd = XSTRNSTR((char*)buff, header, sz);

        if (headerEnd || type != PRIVATEKEY_TYPE) {
            break;
        } else if (header == BEGIN_RSA_PRIV) {
                   header =  BEGIN_PRIV_KEY;       footer = END_PRIV_KEY;
        } else if (header == BEGIN_PRIV_KEY) {
                   header =  BEGIN_ENC_PRIV_KEY;   footer = END_ENC_PRIV_KEY;
        } else if (header == BEGIN_ENC_PRIV_KEY) {
                   header =  BEGIN_EC_PRIV;        footer = END_EC_PRIV;
        } else if (header == BEGIN_ENC_PRIV_KEY) {
                   header =  BEGIN_DSA_PRIV;       footer = END_DSA_PRIV;
        } else
            break;
    }

There are two (header == BEGIN_ENC_PRIV_KEY) checks. It might be better if someone familiar with the code could have a look to clarify if this is intentional or maybe an issue.

@moisesguimaraes
Copy link
Contributor

Hi Peter,

It should be BEGIN_EC_PRIV instead, thanks for the catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants