Right, that's the bug we found. The statements are in the reverse order.  It's 
not quite that simple as the code below, but it ends up happening in that 
order. 

It's one of the most fundamental things a senior dev asks themselves on every 
call that that differentiates them from a junior dev - "What is the lifetime 
semantics of this thing I'm handing over / getting back?".

You don't even need the documentation for this one after looking at how OpenSSL 
gets the socket handle in the first place - the bug is obvious, I just wasn't 
aware this codepath even existed. (Big product, big team - you know how it 
goes).

- Deon

-----Original Message-----
From: sqlite-users <sqlite-users-boun...@mailinglists.sqlite.org> On Behalf Of 
Olivier Mascia
Sent: Tuesday, April 17, 2018 2:28 PM
To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
Subject: Re: [sqlite] Header corruption

> Le 17 avr. 2018 à 22:07, Deon Brewis <de...@outlook.com> a écrit :
> 
> closesocket(_socket); // posix socket
> SSL_shutdown(_ssl); // openssl (_ssl was initialized using the _socket 
> above)

These two statements are inherently wrong, in this order. First you 
SSL_shutdown(), then you closesocket(). Not the reverse. And in Windows code it 
even is good citizenship to call shutdown() properly in between.  AFAIK it 
should also be on Linux, though I'm told it is not commonly seen.  But please 
check the respective OS'es SDK and OpenSSL documentation for the details.

Called in the right order there is no file descriptor re-use syndrome to fear, 
because the closesocket() rightfully comes as the very last step.

--
Best regards, Meilleures salutations, Met vriendelijke groeten, Olivier Mascia 
(from mobile device)


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to