]> gitweb.factorcode.org Git - factor.git/commitdiff
io.sockets.secure.openssl: If server disconnects us, throw
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 27 Dec 2021 17:03:02 +0000 (11:03 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 27 Dec 2021 17:11:22 +0000 (11:11 -0600)
basis/io/sockets/secure/openssl/openssl.factor
basis/io/sockets/secure/secure.factor

index d88c4fd8bb374b693c969349d5868237368e114c..4a55bf3b2932e27e8d65fead43a674025041d5b5 100644 (file)
@@ -279,12 +279,12 @@ PRIVATE>
     t >>terminated drop
     ERR_get_error {
         { -1 [
-            errno { [ ECONNRESET = ] [ EPIPE = ] } 1||
-            [ premature-close ] [ throw-errno ] if f
+            errno ECONNRESET =
+            [ premature-close-error ] [ throw-errno ] if f
         ] }
         ! https://stackoverflow.com/questions/13686398/ssl-read-failing-with-ssl-error-syscall-error
         ! 0 means EOF
-        { 0 [ f ] }
+        { 0 [ premature-close-error f ] }
     } case ;
 
 : check-ssl-error ( ssl-handle ret -- event/f )
@@ -297,7 +297,7 @@ PRIVATE>
         { SSL_ERROR_SSL [ drop throw-ssl-error ] }
         ! https://stackoverflow.com/questions/50223224/ssl-read-returns-ssl-error-zero-return-but-err-get-error-is-0
         ! we got disconnected
-        { SSL_ERROR_ZERO_RETURN [ t >>terminated f >>connected drop f ] }
+        { SSL_ERROR_ZERO_RETURN [ f >>connected t >>terminated premature-close-error ] }
         { SSL_ERROR_WANT_ACCEPT [ drop +input+ ] }
     } case ;
 
index a352e1de6ace850c35c615bc544adfd7a51beb81..c2993069855c49e42220c2985cdf9f4458bf88bb 100644 (file)
@@ -85,10 +85,10 @@ M: secure-inet (client)
 
 PRIVATE>
 
-ERROR: premature-close ;
+ERROR: premature-close-error ;
 
-M: premature-close summary
-    drop "Connection closed prematurely - potential truncation attack" ;
+M: premature-close-error summary
+    drop "Connection closed prematurely" ;
 
 ERROR: certificate-verify-error result ;