FreeBSD Bugzilla – Attachment 87454 Details for
Bug 124062
[patch] net/bounce: command line option -b does not work
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 5.08 KB, created by
Eugene Grosbein
on 2008-05-28 13:20:00 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Eugene Grosbein
Created:
2008-05-28 13:20:00 UTC
Size:
5.08 KB
patch
obsolete
>diff -urN bounce.orig/Makefile bounce/Makefile >--- bounce.orig/Makefile 2007-09-01 06:14:30.000000000 +0800 >+++ bounce/Makefile 2008-05-28 20:03:37.000000000 +0800 >@@ -8,7 +8,7 @@ > > PORTNAME= bounce > PORTVERSION= 1.0 >-PORTREVISION= 6 >+PORTREVISION= 7 > CATEGORIES= net security > MASTER_SITES= http://www.iagora.com/~espel/ \ > ${MASTER_SITE_LOCAL} >diff -urN bounce.orig/files/patch-02 bounce/files/patch-02 >--- bounce.orig/files/patch-02 2006-07-08 06:32:20.000000000 +0800 >+++ bounce/files/patch-02 2008-05-28 19:46:55.000000000 +0800 >@@ -1,15 +1,24 @@ > --- bounce.c.orig Fri Jun 2 12:58:37 2006 > +++ bounce.c Fri Jun 2 13:25:28 2006 >-@@ -138,7 +138,7 @@ >+@@ -138,23 +138,32 @@ > } > > int main(int argc,char *argv[]) { > - int srv_fd, rem_fd, len, cl_fd, on=1; > + int srv_fd, rem_fd, len, cl_fd, on=1, b=0; > int myport=DEFAULT_PORT, remoteport; >- struct sockaddr_in rem_addr, srv_addr, cl_addr; >+- struct sockaddr_in rem_addr, srv_addr, cl_addr; >++ struct sockaddr_in rem_addr, srv_addr, cl_addr, src_addr; > char *myname; >-@@ -153,8 +153,9 @@ >+ struct hostent *hp, *hpLocal; >+ >+ extern char *optarg; >+ extern int optind; >+ char *hostname = NULL; >++ char *sourcename = NULL; >+ char ch; >+ >+ myname=argv[0]; > > /* Process arguments */ > >@@ -17,10 +26,17 @@ > + while( (ch = getopt(argc, argv, "p:a:b:")) != -1 ) { > switch(ch) { > + case 'b': b = 1; >++ sourcename = malloc( strlen(optarg) + 1); >++ if( !sourcename ) { >++ fprintf( stderr, "Can't allocate memory!\n" ); >++ exit(-1); >++ } >++ strcpy( sourcename, optarg ); >++ break; > case 'a': > hostname = malloc( strlen(optarg) + 1); > if( !hostname ) { >-@@ -177,7 +178,7 @@ >+@@ -177,7 +186,7 @@ > argv += optind; > > if (argc!=2) { >@@ -29,7 +45,34 @@ > exit(-1); > } > if ((remoteport=atoi(argv[1]))<=0) { >-@@ -220,6 +221,7 @@ >+@@ -188,6 +197,7 @@ >+ memset((char *) &rem_addr, 0, sizeof(rem_addr)); >+ memset((char *) &srv_addr, 0, sizeof(srv_addr)); >+ memset((char *) &cl_addr, 0, sizeof(cl_addr)); >++ memset((char *) &src_addr, 0, sizeof(src_addr)); >+ >+ cl_addr.sin_family=AF_INET; >+ cl_addr.sin_port=htons(remoteport); >+@@ -211,6 +221,18 @@ >+ srv_addr.sin_addr=*(struct in_addr *)(hp->h_addr_list[0]); >+ } >+ >++ if( sourcename ) { >++ if ((hpLocal=gethostbyname(sourcename))==NULL) { >++ src_addr.sin_addr.s_addr=inet_addr(sourcename); >++ if (src_addr.sin_addr.s_addr==-1) { >++ fprintf(stderr, "Unknown host: %s\n", sourcename); >++ exit(-1); >++ } >++ } else >++ src_addr.sin_addr=*(struct in_addr *)(hp->h_addr_list[0]); >++ } >++ src_addr.sin_family=AF_INET; >++ >+ srv_addr.sin_family=AF_INET; >+ /* srv_addr.sin_addr.s_addr=htonl(INADDR_ANY); */ >+ srv_addr.sin_port=htons(myport); >+@@ -220,6 +242,7 @@ > exit(-1); > } > listen(srv_fd,QLEN); >@@ -37,16 +80,16 @@ > > signal(SIGCHLD, sigchld); > printf("Ready to bounce connections from port %i to %s on port %i\n", >-@@ -254,6 +256,12 @@ >- if ((cl_fd=socket(PF_INET, SOCK_STREAM, 0))<0) { >+@@ -255,6 +278,12 @@ > close(rem_fd); > exit(-1); >-+ } >-+ if (b) { >-+ if (bind(cl_fd,(struct sockaddr *)&srv_addr,sizeof(srv_addr))<0) { >+ } >++ if (b) { src_addr.sin_port=0; >++ if (bind(cl_fd,(struct sockaddr *)&src_addr,sizeof(src_addr))<0) { > + close(rem_fd); > + exit(-1); > + } >- } >++ } > if (connect(cl_fd, (struct sockaddr *)&cl_addr, > sizeof(cl_addr))<0) { >+ close(rem_fd); >diff -urN bounce.orig/files/patch-03 bounce/files/patch-03 >--- bounce.orig/files/patch-03 2007-06-06 19:24:47.000000000 +0800 >+++ bounce/files/patch-03 2008-05-28 19:27:20.000000000 +0800 >@@ -7,9 +7,9 @@ > - int srv_fd, rem_fd, len, cl_fd, on=1, b=0; > + int srv_fd, rem_fd, len, cl_fd, on=1, b=0, d=0; > int myport=DEFAULT_PORT, remoteport; >- struct sockaddr_in rem_addr, srv_addr, cl_addr; >+ struct sockaddr_in rem_addr, srv_addr, cl_addr, src_addr; > char *myname; >-@@ -153,9 +153,10 @@ >+@@ -154,7 +154,7 @@ > > /* Process arguments */ > >@@ -17,11 +17,16 @@ > + while( (ch = getopt(argc, argv, "p:a:b:d")) != -1 ) { > switch(ch) { > case 'b': b = 1; >+ sourcename = malloc( strlen(optarg) + 1); >+@@ -173,6 +173,7 @@ >+ strcpy( hostname, optarg ); >+ break; >+ > + case 'd': d = 1; break; >- case 'a': >- hostname = malloc( strlen(optarg) + 1); >- if( !hostname ) { >-@@ -178,7 +179,7 @@ >+ case 'p': >+ if ((myport=atoi(optarg))==0) { >+ fprintf(stderr,"Bad port number.\n"); >+@@ -186,7 +187,7 @@ > argv += optind; > > if (argc!=2) { >@@ -30,15 +35,15 @@ > exit(-1); > } > if ((remoteport=atoi(argv[1]))<=0) { >-@@ -261,6 +262,11 @@ >- if (bind(cl_fd,(struct sockaddr *)&srv_addr,sizeof(srv_addr))<0) { >- close(rem_fd); >+@@ -284,6 +285,11 @@ > exit(-1); >-+ } >-+ } >+ } >+ } > + if (d) { > + if ((hp=gethostbyname(argv[0]))!=NULL) { > + cl_addr.sin_addr=*(struct in_addr *)(hp->h_addr_list[0]); >- } >- } >++ } >++ } > if (connect(cl_fd, (struct sockaddr *)&cl_addr, >+ sizeof(cl_addr))<0) { >+ close(rem_fd);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 124062
: 87454