bin/139112: [ttcp] sockaddr_in.sin_family initialization,
new option -S src_addr added.
Oleg
Oleg.Dolgov at gmail.com
Thu Sep 24 13:20:02 UTC 2009
>Number: 139112
>Category: bin
>Synopsis: [ttcp] sockaddr_in.sin_family initialization, new option -S src_addr added.
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Sep 24 13:20:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Oleg
>Release: FreeBSD 7.0
>Organization:
Sunbay
>Environment:
>Description:
Field sinme.sin_family doesn't initialized passed to bind, which failed.
New parameter -S src_addr added.
-s src_addr
Set the source IP address for the ttcp connection to src_addr.
>How-To-Repeat:
phobos at amd64# ./ttcp -r -s
ttcp-r: buflen=8192, nbuf=2048, align=16384/0, port=5001 tcp
ttcp-r: socket
ttcp-r: bind: Invalid argument
errno=22
phobos at amd64# ./ttcp -t -s 127.0.0.1
ttcp-t: buflen=8192, nbuf=2048, align=16384/0, port=5001 tcp -> 127.0.0.1
ttcp-t: socket
ttcp-t: bind: Invalid argument
errno=22
>Fix:
Patch attached with submission follows:
--- ttcp.c 2009-09-24 15:54:25.000000000 +0300
+++ ttcp.c.patched 2009-09-24 15:55:38.000000000 +0300
@@ -99,6 +99,7 @@
int touchdata = 0; /* access data after reading */
struct hostent *addr;
+in_addr_t src_addr;
extern int errno;
extern int optind;
extern char *optarg;
@@ -156,7 +157,7 @@
if (argc < 2) goto usage;
- while ((c = getopt(argc, argv, "drstuvBDTb:f:l:n:p:A:O:")) != -1) {
+ while ((c = getopt(argc, argv, "drstuvBDTb:f:l:n:p:A:O:S:")) != -1) {
switch (c) {
case 'B':
@@ -217,6 +218,9 @@
case 'T':
touchdata = 1;
break;
+ case 'S':
+ src_addr = inet_addr(optarg);
+ break;
default:
goto usage;
@@ -249,12 +253,14 @@
#endif /* cray */
}
sinhim.sin_port = htons(port);
+ sinme.sin_addr.s_addr = src_addr;
sinme.sin_port = 0; /* free choice */
} else {
/* rcvr */
sinme.sin_port = htons(port);
}
+ sinme.sin_family = AF_INET;
if (udp && buflen < 5) {
buflen = 5; /* send more than the sentinel size */
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list