[Vm-dev] [FIXED] SqueakSSL for Windows :)
Levente Uzonyi
leves at elte.hu
Tue Apr 21 17:37:20 UTC 2015
Great news! I dug up a windows machine this morning to do this myself
somewhere in the near future, but you guys were faster.
I found that the sqSetStringPropertySSL function in the Windows branch
still has the memory leaks I patched a while ago on Unix. The function
should be something like this:
sqInt sqSetStringPropertySSL(sqInt handle, int propID, char *propName, sqInt propLen) {
sqSSL *ssl = sslFromHandle(handle);
char *property = NULL;
if(ssl == NULL) return 0;
if(propLen > 0) {
property = malloc(propLen + 1);
memcpy(property, propName, propLen);
property[propLen] = '\0';
};
if(ssl->loglevel) printf("sqSetStringPropertySSL(%d): %s\n", propID, property ? propery : "(null)");
switch(propID) {
case SQSSL_PROP_CERTNAME:
if (ssl->certName) free(ssl->certName);
ssl->certName = property;
break;
case SQSSL_PROP_SERVERNAME:
if (ssl->serverName) free(ssl->serverName);
ssl->serverName = property;
break;
/* Platform specific: Adds a .PFX file to MY certificate store w/o password.
Useful for installing the default test certificate in SqueakSSL. */
case 10001:
if(property) free(property);
return sqAddPfxCertToStore(propName, propLen, NULL, 0);
default:
if(property) free(property);
if(ssl->loglevel) printf("sqSetStringPropertySSL: Unknown property ID %d\n", propID);
return 0;
}
return 1;
}
This version doesn't let null be passed to printf, because that results in
undefined behavior.
It frees property when it's not used to avoid leaking memory.
It frees ssl->certName when it's replaced to avoid leaking memory.
It doesn't try to allocate property, if propLen is negative.
It uses malloc instead of calloc for better performance :).
Levente
On Tue, 21 Apr 2015, Marcel Taeumel wrote:
>
> Hi, there! :)
>
> Tobias and I fixed the SqueakSSL implementation for Windows. Please find the
> modified source code attached and add it to the VM code repository.
>
> sqWin32SSL.c <http://forum.world.st/file/n4820813/sqWin32SSL.c>
>
> The fixes are:
>
> - SNI support
> - setting an Int property via sqSetIntPropertySSL(...)
> - Unicode problems when extracting the correct peerName in sqExtractPeerName
>
> Tobias will send around builds for the shared libraries ASAP. :)
>
> Best,
> Marcel
>
>
>
> --
> View this message in context: http://forum.world.st/FIXED-SqueakSSL-for-Windows-tp4820813.html
> Sent from the Squeak VM mailing list archive at Nabble.com.
>
More information about the Vm-dev
mailing list