Skip to content
Snippets Groups Projects
Commit cc63360c authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Some more Coverity paranoia.

This ones does require SSIZE_MAX... so let's see what the pipes say...
parent 1c0d9f01
No related branches found
No related tags found
No related merge requests found
...@@ -188,17 +188,20 @@ off_t sendfilesocket(int sock, int file, off_t *offset, off_t count) ...@@ -188,17 +188,20 @@ off_t sendfilesocket(int sock, int file, off_t *offset, off_t count)
} }
while(total<count) { while(total<count) {
rd=read(file,buf,sizeof(buf)); rd = read(file, buf, sizeof(buf));
if(rd==-1) if (rd < 0)
return(-1); return(-1);
if(rd==0) if (rd == 0)
break; break;
for(i=wr=0;i<rd;i+=wr) { for (i = wr = 0; i < rd; i += wr) {
wr=sendsocket(sock,buf+i,rd-i); wr = sendsocket(sock,buf+i,rd-i);
if(wr>0) if (wr > 0) {
if ((SSIZE_MAX - i) < wr)
wr = SSIZE_MAX - i;
continue; continue;
if(wr==SOCKET_ERROR && SOCKET_ERRNO==EWOULDBLOCK) { }
wr=0; if (wr == SOCKET_ERROR && SOCKET_ERRNO == EWOULDBLOCK) {
wr = 0;
SLEEP(1); SLEEP(1);
continue; continue;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment