4242# include <unistd.h>
4343#endif
4444#include <setjmp.h>
45- #include "mod/server.mod/server.h"
4645
4746#ifdef TLS
4847# include <openssl/err.h>
@@ -894,7 +893,7 @@ int sockread(char *s, int *len, sock_list *slist, int slistmax, int tclonly)
894893 struct timeval t ;
895894 fd_set fdr , fdw , fde ;
896895 int i , x , maxfd_r , maxfd_w , maxfd_e ;
897- int grab = 511 , tclsock = -1 , events = 0 ;
896+ int grab = READMAX , tclsock = -1 , events = 0 ;
898897 struct threaddata * td = threaddata ();
899898 int maxfd ;
900899#ifdef EGG_TDNS
@@ -938,8 +937,7 @@ int sockread(char *s, int *len, sock_list *slist, int slistmax, int tclonly)
938937 if (!tclonly && ((!(slist [i ].flags & (SOCK_UNUSED | SOCK_TCL ))) &&
939938 ((FD_ISSET (slist [i ].sock , & fdr )) ||
940939#ifdef TLS
941- (slist [i ].ssl && (SSL_pending (slist [i ].ssl ) ||
942- !SSL_is_init_finished (slist [i ].ssl ))) ||
940+ (slist [i ].ssl && !SSL_is_init_finished (slist [i ].ssl )) ||
943941#endif
944942 ((slist [i ].sock == STDOUT ) && (!backgrd ) &&
945943 (FD_ISSET (STDIN , & fdr )))))) {
@@ -1102,7 +1100,7 @@ int sockread(char *s, int *len, sock_list *slist, int slistmax, int tclonly)
11021100
11031101int sockgets (char * s , int * len )
11041102{
1105- char xx [RECVLINEMAX ], * p , * px , * p2 ;
1103+ char xx [READMAX + 2 ], * p , * px , * p2 ;
11061104 int ret , i , data = 0 ;
11071105 size_t len2 ;
11081106 struct threaddata * td = threaddata ();
@@ -1129,7 +1127,7 @@ int sockgets(char *s, int *len)
11291127 p ++ ;
11301128 * p2 = 0 ;
11311129
1132- strlcpy (s , socklist [i ].handler .sock .inbuf , RECVLINEMAX - 1 );
1130+ strlcpy (s , socklist [i ].handler .sock .inbuf , READMAX + 1 );
11331131 if (* p ) {
11341132 len2 = strlen (p ) + 1 ;
11351133 px = nmalloc (len2 );
@@ -1145,15 +1143,15 @@ int sockgets(char *s, int *len)
11451143 }
11461144 } else {
11471145 /* Handling buffered binary data (must have been SOCK_BUFFER before). */
1148- if (socklist [i ].handler .sock .inbuflen <= RECVLINEMAX - 2 ) {
1146+ if (socklist [i ].handler .sock .inbuflen <= READMAX ) {
11491147 * len = socklist [i ].handler .sock .inbuflen ;
11501148 memcpy (s , socklist [i ].handler .sock .inbuf , socklist [i ].handler .sock .inbuflen );
11511149 nfree (socklist [i ].handler .sock .inbuf );
11521150 socklist [i ].handler .sock .inbuf = NULL ;
11531151 socklist [i ].handler .sock .inbuflen = 0 ;
11541152 } else {
1155- /* Split up into chunks of RECVLINEMAX-2 bytes. */
1156- * len = RECVLINEMAX - 2 ;
1153+ /* Split up into chunks of READMAX bytes. */
1154+ * len = READMAX ;
11571155 memcpy (s , socklist [i ].handler .sock .inbuf , * len );
11581156 memcpy (socklist [i ].handler .sock .inbuf , socklist [i ].handler .sock .inbuf + * len , * len );
11591157 socklist [i ].handler .sock .inbuflen -= * len ;
@@ -1218,17 +1216,17 @@ int sockgets(char *s, int *len)
12181216 strcpy (socklist [ret ].handler .sock .inbuf , p );
12191217 strcat (socklist [ret ].handler .sock .inbuf , xx );
12201218 nfree (p );
1221- if (strlen (socklist [ret ].handler .sock .inbuf ) < RECVLINEMAX ) {
1219+ if (strlen (socklist [ret ].handler .sock .inbuf ) < READMAX + 2 ) {
12221220 strcpy (xx , socklist [ret ].handler .sock .inbuf );
12231221 nfree (socklist [ret ].handler .sock .inbuf );
12241222 socklist [ret ].handler .sock .inbuf = NULL ;
12251223 socklist [ret ].handler .sock .inbuflen = 0 ;
12261224 } else {
12271225 p = socklist [ret ].handler .sock .inbuf ;
1228- socklist [ret ].handler .sock .inbuflen = strlen (p ) - RECVLINEMAX - 2 ;
1226+ socklist [ret ].handler .sock .inbuflen = strlen (p ) - READMAX ;
12291227 socklist [ret ].handler .sock .inbuf = nmalloc (socklist [ret ].handler .sock .inbuflen + 1 );
1230- strcpy (socklist [ret ].handler .sock .inbuf , p + RECVLINEMAX - 2 );
1231- * (p + RECVLINEMAX - 2 ) = 0 ;
1228+ strcpy (socklist [ret ].handler .sock .inbuf , p + READMAX );
1229+ * (p + READMAX ) = 0 ;
12321230 strcpy (xx , p );
12331231 nfree (p );
12341232 /* (leave the rest to be post-pended later) */
@@ -1249,7 +1247,7 @@ int sockgets(char *s, int *len)
12491247/* if (!s[0]) strcpy(s," "); */
12501248 if (!data ) {
12511249 s [0 ] = 0 ;
1252- if (strlen (xx ) >= RECVLINEMAX - 2 ) {
1250+ if (strlen (xx ) >= READMAX ) {
12531251 /* String is too long, so just insert fake \n */
12541252 strcpy (s , xx );
12551253 xx [0 ] = 0 ;
0 commit comments