From 364207ee3753fb938b278dc7eed9ec26cf8d9e86 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Sat, 12 Feb 2005 02:42:19 +0000 Subject: [PATCH] Cleaned-up sendfilesocket() - possible use of variable (wr) without initialization, sanity checking of count, etc. --- src/xpdev/sockwrap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xpdev/sockwrap.c b/src/xpdev/sockwrap.c index d372e2b89c..08b70e2f79 100644 --- a/src/xpdev/sockwrap.c +++ b/src/xpdev/sockwrap.c @@ -87,8 +87,13 @@ int sendfilesocket(int sock, int file, long *offset, long count) count-=tell(file); /* don't try to read beyond EOF */ } + if(count<0) { + errno=EINVAL; + return(-1); + } + total=0; - while(total!=count) { + while(total<count) { rd=read(file,buf,sizeof(buf)); if(rd==-1) return(-1); @@ -113,9 +118,6 @@ int sendfilesocket(int sock, int file, long *offset, long count) if(offset!=NULL) (*offset)+=total; - if(wr<1) - return(wr); - return(total); #endif } -- GitLab