Skip to content
Snippets Groups Projects
Commit 1e5bbbdf authored by rswindell's avatar rswindell
Browse files

Address Coverity-scan reported issues.

parent e7aec24a
No related branches found
No related tags found
No related merge requests found
......@@ -1332,6 +1332,7 @@ static int receive_files(char** fname_list, int fnames)
if(fwrite(block,1,wr,fp)!=wr) {
lprintf(LOG_ERR,"ERROR %d writing %u bytes at file offset %"PRIu64
,errno, wr, (uint64_t)ftello(fp));
fclose(fp);
xmodem_cancel(&xm);
return(1);
}
......@@ -1884,7 +1885,7 @@ int main(int argc, char **argv)
if(!stdio) {
#endif
lprintf(LOG_DEBUG,"Setting TCP_NODELAY to %d",tcp_nodelay);
setsockopt(sock,IPPROTO_TCP,TCP_NODELAY,(char*)&tcp_nodelay,sizeof(tcp_nodelay));
(void)setsockopt(sock,IPPROTO_TCP,TCP_NODELAY,(char*)&tcp_nodelay,sizeof(tcp_nodelay));
#ifdef __unix__
}
#endif
......@@ -1892,7 +1893,7 @@ int main(int argc, char **argv)
/* Set non-blocking mode */
#ifdef __unix__
if(stdio) {
fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL) | O_NONBLOCK);
(void)fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL) | O_NONBLOCK);
}
else
#endif
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -233,6 +233,7 @@ int xmodem_get_block(xmodem_t* xm, uchar* block, unsigned expected_block_num)
default:
lprintf(xm,LOG_WARNING,"Block %u: Received %s Expected SOH, STX, or EOT"
,expected_block_num, chr((uchar)i));
/* Fall-through */
case NOINP: /* Nothing came in */
if(eot)
return(EOT);
......@@ -492,7 +493,10 @@ BOOL xmodem_send_file(xmodem_t* xm, const char* fname, FILE* fp, time_t* start,
if(start!=NULL)
*start=time(NULL);
fstat(fileno(fp),&st);
if(fstat(fileno(fp),&st) != 0) {
lprintf(xm,LOG_ERR,"Failed to fstat file");
return FALSE;
}
if(xm->total_files==0)
xm->total_files=1;
......
......@@ -2013,6 +2013,10 @@ int zmodem_recv_files(zmodem_t* zm, const char* download_dir, uint64_t* bytes_re
break;
}
start_bytes=filelength(fileno(fp));
if(start_bytes < 0) {
lprintf(zm,LOG_ERR,"Invalid file length %"PRId64": %s", start_bytes, fpath);
break;
}
skip=FALSE;
errors=zmodem_recv_file_data(zm,fp,start_bytes);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment