From afafff2f19e995876da792ea605684be1bb1c17b Mon Sep 17 00:00:00 2001 From: deuce <> Date: Fri, 16 Mar 2018 15:01:15 +0000 Subject: [PATCH] Update Socket.recvline() for new js_socket_recv() TLS semantics. Fixes recvline() returning an zero-length "line" on timeouts, which causes infinite loops and 100% CPU utilization with IMAPv4-TLS service (and likely any other service that uses recvline with a short timeout). --- src/sbbs3/js_socket.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/sbbs3/js_socket.c b/src/sbbs3/js_socket.c index 70efee6226..6b6c2a7675 100644 --- a/src/sbbs3/js_socket.c +++ b/src/sbbs3/js_socket.c @@ -1331,7 +1331,6 @@ js_recvline(JSContext *cx, uintN argc, jsval *arglist) start=time(NULL); rc=JS_SUSPENDREQUEST(cx); for(i=0;i<len;) { - if(p->session==-1) { switch(js_sock_read_check(p,start,timeout,i)) { case 1: @@ -1353,22 +1352,14 @@ js_recvline(JSContext *cx, uintN argc, jsval *arglist) break; } else { + if (got == 0) { + free(buf); + return(JS_TRUE); /* time-out */ + } if (got == -1) { len = 0; continue; } - switch(js_sock_read_check(p,start,timeout,i)) { - case 1: - JS_SET_RVAL(cx, arglist, JSVAL_NULL); - JS_RESUMEREQUEST(cx, rc); - free(buf); - return(JS_TRUE); /* time-out */ - case 2: - len=0; - continue; - case 3: - continue; - } } } -- GitLab