Skip to content

SPKAC functionality per feature request #38917 (part deux)#37

Closed
jas- wants to merge 5 commits intophp:masterfrom
jas-:master
Closed

SPKAC functionality per feature request #38917 (part deux)#37
jas- wants to merge 5 commits intophp:masterfrom
jas-:master

Conversation

@jas-
Copy link
Copy Markdown
Contributor

@jas- jas- commented Apr 4, 2012

Per bug id https://bugs.php.net/bug.php?id=38917, a patch to implement missing SPKAC functionality within the OpenSSL extension.

I have made recommended modifications per closed pull request id #21.

Comment thread ext/openssl/openssl.c Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what this code is for? emalloc never returns NULL and sizeof(s) is a constant and you used s for sprintf anyway earlier.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I don't understand the question. sprintf() gets used after emalloc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this code for: if (sizeof(s)<=0) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure an SPKAC is created, I should modify that to be

if (sizeof(s)!=8) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jas- In which occasions would it not be created? As @smalyshev mentioned, emalloc is infallible. If it can't allocate the memory the program will terminate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't think of that, over engineering it. WIll remove thanks @smalyshev & @nikic

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, sizeof(s) is always the same, it is a constant operation. It does not depend on anything, just returns size of char * type.

Comment thread ext/openssl/openssl.c
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this RETURN leave spki and pkey not freed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would much rather use a macro as I did in my original patch submission to free everything.

if (!NETSCAPE_SPKI_set_pubkey(spki, pkey)) {
    goto cleanup;

I was however told I should move away from using those

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use macro, you can use goto if you're really careful (comment on it!) but you have to free stuff you allocated one way or another.

@lstrojny
Copy link
Copy Markdown
Contributor

lstrojny commented Jan 6, 2013

@jas- ping

@lstrojny
Copy link
Copy Markdown
Contributor

@jas- ping again

@jas-
Copy link
Copy Markdown
Contributor Author

jas- commented Jan 30, 2013

Closing this request. Please refer to branch "issue-38917-spkac" and pull request #267 (#267)

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

Successfully merging this pull request may close these issues.

4 participants