diff -ur ../fwtk.dist/fwtk/http-gw/auth.c fwtk/http-gw/auth.c --- ../fwtk.dist/fwtk/http-gw/auth.c Fri Nov 22 16:21:05 1996 +++ fwtk/http-gw/auth.c Tue Nov 14 13:47:47 2000 @@ -23,7 +23,10 @@ }; struct res_chars res_chars[] = { - { TYPE_HTTP, "()%:+/;?=&\r\n"}, + /* Do not unescape "reserved", "unsafe" or "special" characters from RFC1738 + * TRG - 20000714 + */ + { TYPE_HTTP, ";/?:@=&$-_.+!*'(), <>\"#%{}|\\^~[]`\r\n"}, { 0, NULL} }; diff -ur ../fwtk.dist/fwtk/http-gw/ftp.c fwtk/http-gw/ftp.c --- ../fwtk.dist/fwtk/http-gw/ftp.c Sat Jan 18 20:17:37 1997 +++ fwtk/http-gw/ftp.c Tue Nov 14 13:47:47 2000 @@ -216,6 +216,7 @@ int ftp_setup(sockfd, rfd, ftp_listen) int sockfd, rfd, *ftp_listen; { int siteinfo = ftp_siteinfo; + int reply; ftp_siteinfo = -1; if( get_ftp_reply(rfd) != '2') @@ -225,19 +226,24 @@ say(rfd,"USER anonymous"); else say(rfd, ftp_user); - if( get_ftp_reply(rfd) != '3') - goto broken; - - if( ftp_pass[0] == '\0') - sprintf(ftp_reply_buf,"PASS http-gw@%s", ourname); - else - strcpy(ftp_reply_buf, ftp_pass); - say(rfd, ftp_reply_buf); + reply = get_ftp_reply(rfd); + if (reply != '2') { + if( reply != '3') + goto broken; - ftp_siteinfo = siteinfo; + if( ftp_pass[0] == '\0') + sprintf(ftp_reply_buf,"PASS http-gw@%s", ourname); + else + strcpy(ftp_reply_buf, ftp_pass); + say(rfd, ftp_reply_buf); - if( get_ftp_reply(rfd) != '2') - goto broken; + ftp_siteinfo = siteinfo; + + if( get_ftp_reply(rfd) != '2') + goto broken; + } else { + ftp_siteinfo = siteinfo; + } if( ftp_repcnt > 2){ ftp_gensitedir = 1; diff -ur ../fwtk.dist/fwtk/http-gw/hmain.c fwtk/http-gw/hmain.c --- ../fwtk.dist/fwtk/http-gw/hmain.c Fri Feb 6 23:32:16 1998 +++ fwtk/http-gw/hmain.c Tue Nov 14 14:06:27 2000 @@ -857,13 +857,10 @@ if(html_read(fd,(char *)&buf[x],1) != 1) goto done; - /* get \r\n - read a char and throw it away */ - if(buf[x] == '\r') { + /* eat all \r from the stream */ + while(buf[x] == '\r') { if(html_read(fd,(char *)&buf[x],1) != 1) goto done; - buf[x] = '\0'; - ret = x; - goto done; } if(buf[x] == '\n') { @@ -945,9 +942,24 @@ char *s; int n; { - if(net_write(fd,s,n) != n) - return(1); - return(net_write(fd,"\r\n",2) != 2); + char *buff; + int retval; + + /* Attempt to send message in one packet + * Some FTP servers don't like split messages + * TRG - 20001114 + */ + if ( (buff = malloc(n+2)) == NULL) { + if(net_write(fd,s,n) != n) + return(1); + return(net_write(fd,"\r\n",2) != 2); + } + memcpy(buff, s, n); + buff[n]='\r'; + buff[n+1]='\n'; + retval = net_write(fd,buff,n+2); + free(buff); + return(retval); } diff -ur ../fwtk.dist/fwtk/http-gw/http-gw.c fwtk/http-gw/http-gw.c --- ../fwtk.dist/fwtk/http-gw/http-gw.c Fri Feb 6 23:32:25 1998 +++ fwtk/http-gw/http-gw.c Tue Nov 14 14:19:17 2000 @@ -1362,6 +1362,22 @@ }else break; } + /* Check if there is a CRLF left in the buffer. + * Netscape sends CRLF on the end of POST commands. + * TRG - 19990817 + */ + { + char str[2]; + int count; + if (ioctl(rfd, FIONREAD, &count) == 0) { + if (count == 2) { + if (recv(rfd, str, 2, MSG_PEEK) == 2) { + if ((str[0] == '\r') && (str[1] == '\n')) + read(rfd, str, 2); + } + } + } + } } return 0; } @@ -2285,8 +2301,13 @@ seek_and_destroy(value); /* Quote at end removed to avoid double write*/ - p = value + strlen(value) - 1; - if ((*p == '"') || (*p == '\'')) *p = 0; + if (*value == '"' || *value == '\'') { + /* leave single quote intact */ + if (strlen(value) > 1) { + char *p2 = value + strlen(value) - 1; + if (*value == *p2) *p2 = 0; + } + } /* write out the saved (or rewritten) field now */ if (!in_blocked) diff -ur ../fwtk.dist/fwtk/x-gw/fwd.c fwtk/x-gw/fwd.c --- ../fwtk.dist/fwtk/x-gw/fwd.c Tue Jul 22 15:05:01 1997 +++ fwtk/x-gw/fwd.c Tue Nov 14 13:53:09 2000 @@ -30,8 +30,9 @@ if( maxb <=0 ) return bsize; switch( cnt=read(*rfd,&pbuf[bsize],maxb) ) { - case -1: sprintf(buf,"read fd:%d",readfd); + case -1: sprintf(buf,"read fd:%d",*rfd); pmsg(buf,1); + /* FALL THROUGH */ case 0: clear_close_fd(*rfd,rset,wset); cnt= -1; break; @@ -51,8 +52,9 @@ int cnt; switch( (cnt=write(*wfd,pbuf,bsize)) ) { - case -1: sprintf(buf,"write fd:%d",readfd); + case -1: sprintf(buf,"write fd:%d",*wfd); pmsg(buf,1); + /* FALL THROUGH */ case 0: clear_close_fd(*wfd,rset,wset); return -1; default: if(cntid))>= -1 && cb) ret=cb(p->id,data,ret); - if( ret>= -1) + if( ret>= -1) { + ptemp=p->next; pidlist=(list_t*)deleteListItem(pidlist,p->id); - p=p->next; + p=ptemp; + } else { + p=p->next; + } } return pidlist; }