[FIXED] SqueakSSL for Windows :)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[FIXED] SqueakSSL for Windows :)

marcel.taeumel (old)
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

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
Reply | Threaded
Open this post in threaded view
|

Re: [FIXED] SqueakSSL for Windows :)

Levente Uzonyi-2
 
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.
>
Reply | Threaded
Open this post in threaded view
|

Re: [FIXED] SqueakSSL for Windows :)

Levente Uzonyi-2
 
I just took a look at the Mac version of the function, and that's also
missing some of these fixes.

Levente

On Tue, 21 Apr 2015, Levente Uzonyi wrote:

>
> 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.
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: [FIXED] SqueakSSL for Windows :)

Eliot Miranda-2
In reply to this post by marcel.taeumel (old)
 
thanks both!  I've integrated but am not ready to commit yet.  

On Tue, Apr 21, 2015 at 5:56 AM, Marcel Taeumel <[hidden email]> 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.



--
best,
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: [FIXED] SqueakSSL for Windows :)

marcel.taeumel (old)
In reply to this post by Levente Uzonyi-2
Ah, okay. I can integrate that tomorrow and make another build.

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: [FIXED] SqueakSSL for Windows :)

David T. Lewis
In reply to this post by Eliot Miranda-2
 
FYI, we have a couple of Mantis issues related to Levente's updates:

http://bugs.squeak.org/view.php?id=7793

http://bugs.squeak.org/view.php?id=7824

Dave

>  thanks both!  I've integrated but am not ready to commit yet.
>
> On Tue, Apr 21, 2015 at 5:56 AM, Marcel Taeumel <
> [hidden email]> 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.
>>
>
>
>
> --
> best,
> Eliot
>


Reply | Threaded
Open this post in threaded view
|

Re: [FIXED] SqueakSSL for Windows :)

Tobias Pape
In reply to this post by Eliot Miranda-2

Hey Eliot

On 21.04.2015, at 19:46, Eliot Miranda <[hidden email]> wrote:

> thanks both!  I've integrated but am not ready to commit yet.  

Please hold back a minute, I'll post updated stuff to Ron's github
very soon-ish.

Best regards
        -Tobias


>
> On Tue, Apr 21, 2015 at 5:56 AM, Marcel Taeumel <[hidden email]> 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