Received: (at submit) by bugs.debian.org; 11 Jul 1998 06:10:43 +0000 Received: (qmail 11411 invoked from network); 11 Jul 1998 06:10:42 -0000 Received: from dalasc7-72.flash.net (HELO adam.hackers-net.com) (mail@209.30.166.72) by debian.novare.net with SMTP; 11 Jul 1998 06:10:42 -0000 Received: from adam.hackers-net.com [192.168.0.3] (adam) by adam.hackers-net.com with smtp (Exim 1.92 #1 (Debian)) id 0yusrp-00024W-00; Sat, 11 Jul 1998 01:10:41 -0500 Date: Sat, 11 Jul 1998 01:10:41 -0500 (CDT) From: Adam Heath X-Sender: adam@adam.hackers-net.com Reply-To: Adam Heath To: submit@bugs.debian.org Subject: ftplib prints perror msgs, and should check ftplib_debug first(patch included) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Package: ftplib3 Version: 3.1-1 Severity: normal While writing a replacement ftp method for apt-get, and doing some testing, I changed the server to something non-existant. When ftplib tried to connect, it printed 'gethostbyname: success,' which will mess apt-get up(or at least cause confusion). The attached patch will only print perror() msgs when ftplib_debug > 1. Adam --- ftplib.c.orig Tue Jun 23 15:39:52 1998 +++ ftplib.c Sat Jul 11 00:53:38 1998 @@ -238,7 +238,7 @@ return retval; if ((x = net_read(ctl->handle,ctl->cput,ctl->cleft)) == -1) { - perror("read"); + if(ftplib_debug > 1) perror("read"); retval = -1; break; } @@ -323,7 +323,7 @@ char match[5]; if (readline(nControl->response,256,nControl) == -1) { - perror("Control socket read failed"); + if(ftplib_debug > 1) perror("Control socket read failed"); return 0; } if (ftplib_debug > 1) @@ -337,7 +337,7 @@ { if (readline(nControl->response,256,nControl) == -1) { - perror("Control socket read failed"); + if(ftplib_debug > 1) perror("Control socket read failed"); return 0; } if (ftplib_debug > 1) @@ -402,7 +402,7 @@ #else if ((pse = getservbyname("ftp","tcp")) == NULL) { - perror("getservbyname"); + if(ftplib_debug > 1) perror("getservbyname"); return 0; } sin.sin_port = pse->s_port; @@ -423,7 +423,7 @@ { if ((phe = gethostbyname(lhost)) == NULL) { - perror("gethostbyname"); + if(ftplib_debug > 1) perror("gethostbyname"); return 0; } memcpy((char *)&sin.sin_addr, phe->h_addr, phe->h_length); @@ -432,33 +432,33 @@ sControl = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sControl == -1) { - perror("socket"); + if(ftplib_debug > 1) perror("socket"); return 0; } if (setsockopt(sControl,SOL_SOCKET,SO_REUSEADDR, SETSOCKOPT_OPTVAL_TYPE &on, sizeof(on)) == -1) { - perror("setsockopt"); + if(ftplib_debug > 1) perror("setsockopt"); net_close(sControl); return 0; } if (connect(sControl, (struct sockaddr *)&sin, sizeof(sin)) == -1) { - perror("connect"); + if(ftplib_debug > 1) perror("connect"); net_close(sControl); return 0; } ctrl = calloc(1,sizeof(netbuf)); if (ctrl == NULL) { - perror("calloc"); + if(ftplib_debug > 1) perror("calloc"); net_close(sControl); return 0; } ctrl->buf = malloc(FTPLIB_BUFSIZ); if (ctrl->buf == NULL) { - perror("calloc"); + if(ftplib_debug > 1) perror("calloc"); net_close(sControl); free(ctrl); return 0; @@ -541,7 +541,7 @@ sprintf(buf,"%s\r\n",cmd); if (net_write(nControl->handle,buf,strlen(buf)) <= 0) { - perror("write"); + if(ftplib_debug > 1) perror("write"); return 0; } return readresp(expresp, nControl); @@ -625,27 +625,27 @@ { if (getsockname(nControl->handle, &sin.sa, &l) < 0) { - perror("getsockname"); + if(ftplib_debug > 1) perror("getsockname"); return 0; } } sData = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP); if (sData == -1) { - perror("socket"); + if(ftplib_debug > 1) perror("socket"); return -1; } if (setsockopt(sData,SOL_SOCKET,SO_REUSEADDR, SETSOCKOPT_OPTVAL_TYPE &on,sizeof(on)) == -1) { - perror("setsockopt"); + if(ftplib_debug > 1) perror("setsockopt"); net_close(sData); return -1; } if (setsockopt(sData,SOL_SOCKET,SO_LINGER, SETSOCKOPT_OPTVAL_TYPE &lng,sizeof(lng)) == -1) { - perror("setsockopt"); + if(ftplib_debug > 1) perror("setsockopt"); net_close(sData); return -1; } @@ -653,7 +653,7 @@ { if (connect(sData, &sin.sa, sizeof(sin.sa)) == -1) { - perror("connect"); + if(ftplib_debug > 1) perror("connect"); net_close(sData); return -1; } @@ -663,13 +663,13 @@ sin.in.sin_port = 0; if (bind(sData, &sin.sa, sizeof(sin)) == -1) { - perror("bind"); + if(ftplib_debug > 1) perror("bind"); net_close(sData); return 0; } if (listen(sData, 1) < 0) { - perror("listen"); + if(ftplib_debug > 1) perror("listen"); net_close(sData); return 0; } @@ -691,13 +691,13 @@ ctrl = calloc(1,sizeof(netbuf)); if (ctrl == NULL) { - perror("calloc"); + if(ftplib_debug > 1) perror("calloc"); net_close(sData); return -1; } if ((mode == 'A') && ((ctrl->buf = malloc(FTPLIB_BUFSIZ)) == NULL)) { - perror("calloc"); + if(ftplib_debug > 1) perror("calloc"); net_close(sData); free(ctrl); return -1; @@ -1104,7 +1104,7 @@ while ((l = FtpRead(dbuf, FTPLIB_BUFSIZ, nData)) > 0) if (fwrite(dbuf, 1, l, local) <= 0) { - perror("localfile write"); + if(ftplib_debug > 1) perror("localfile write"); break; } } ---