| Summary: | port fix: x11-toolkits/plib - Fix netSocket code | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Ports & Packages | Reporter: | Ganael LAPLANCHE <ganael.laplanche> | ||||
| Component: | Individual Port(s) | Assignee: | Dmitry Marakasov <amdmi3> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | Latest | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
Responsible Changed From-To: freebsd-ports-bugs->amdmi3 I'll take it. * Ganael Laplanche (ganael.laplanche@martymac.com) wrote: > This patch should fix any network-related application using the plib library (e.g. simgear). It closes ports/138786. Did you check if it works? AFAIK, sin_len must be set properly, while in your version it will be zero. This should be more correct, also with additional compile-time check: --- plib.patch begins here --- Index: Makefile =================================================================== RCS file: /home/amdmi3/projects/freebsd/FreeBSD.cvs/ports/x11-toolkits/plib/Makefile,v retrieving revision 1.39 diff -u -r1.39 Makefile --- Makefile 8 Sep 2009 02:25:36 -0000 1.39 +++ Makefile 9 Mar 2010 14:49:48 -0000 @@ -7,7 +7,7 @@ PORTNAME= plib PORTVERSION= 1.8.5 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= x11-toolkits MASTER_SITES= http://plib.sourceforge.net/dist/ Index: files/patch-src-net-netSocket.cxx =================================================================== RCS file: files/patch-src-net-netSocket.cxx diff -N files/patch-src-net-netSocket.cxx --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-src-net-netSocket.cxx 9 Mar 2010 15:53:58 -0000 @@ -0,0 +1,21 @@ +--- src/net/netSocket.cxx.orig 2008-03-11 05:06:20.000000000 +0300 ++++ src/net/netSocket.cxx 2010-03-09 18:53:58.000000000 +0300 +@@ -38,6 +38,7 @@ + #include <unistd.h> + #include <netdb.h> + #include <fcntl.h> ++#include <stddef.h> + + #else + +@@ -64,8 +65,10 @@ + + void netAddress::set ( const char* host, int port ) + { ++ int dummy[(sizeof(netAddress) == sizeof(sockaddr_in))*2-1]; // Compile time assert + memset(this, 0, sizeof(netAddress)); + ++ sin_len = sizeof(netAddress); + sin_family = AF_INET ; + sin_port = htons (port); + Index: files/patch-src-net-netSocket.h =================================================================== RCS file: files/patch-src-net-netSocket.h diff -N files/patch-src-net-netSocket.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-src-net-netSocket.h 9 Mar 2010 15:16:55 -0000 @@ -0,0 +1,27 @@ +--- src/net/netSocket.h.orig 2008-03-11 05:06:20.000000000 +0300 ++++ src/net/netSocket.h 2010-03-09 18:16:55.000000000 +0300 +@@ -41,6 +41,8 @@ + #define NET_SOCKET_H + + #include "ul.h" ++#include <sys/types.h> ++#include <sys/socket.h> + #include <errno.h> + + /* +@@ -49,10 +51,11 @@ + class netAddress + { + /* DANGER!!! This MUST match 'struct sockaddr_in' exactly! */ +- short sin_family ; +- unsigned short sin_port ; +- unsigned int sin_addr ; +- char sin_zero [ 8 ] ; ++ int8_t sin_len; ++ sa_family_t sin_family; ++ in_port_t sin_port; ++ in_addr_t sin_addr; ++ char sin_zero[8]; + + public: + netAddress () {} --- plib.patch ends here --- -- Dmitry Marakasov . 55B5 0596 FF1E 8D84 5F56 9510 D35A 80DD F9D2 F77D amdmi3@amdmi3.ru ..: jabber: amdmi3@jabber.ru http://www.amdmi3.ru On Tue, 9 Mar 2010 19:09:48 +0300, Dmitry Marakasov wrote Hi Dmitry, > Did you check if it works? AFAIK, sin_len must be set properly, > while in your version it will be zero. This should be more correct, > also with additional compile-time check: Yes, it did work for me. But you're right, your patch is much cleaner. I've tested it and it works :) Great ! Thank you very much, Ganaël LAPLANCHE ganael.laplanche@martymac.org http://www.martymac.org On Tue, 9 Mar 2010 19:09:48 +0300, Dmitry Marakasov wrote Hi Dmitry, > Did you check if it works? AFAIK, sin_len must be set properly, > while in your version it will be zero. This should be more correct, > also with additional compile-time check: Yes, it did work for me. But you're right, your patch is much cleaner. I've tested it and it works :) Great ! Thank you very much, Ganaël LAPLANCHE ganael.laplanche@martymac.org http://www.martymac.org State Changed From-To: open->closed Committed, with minor changes. Thanks! amdmi3 2010-03-15 14:35:32 UTC
FreeBSD ports repository
Modified files:
x11-toolkits/plib Makefile
Added files:
x11-toolkits/plib/files patch-src-net-netSocket.cxx
patch-src-net-netSocket.h
Log:
- Add a patch to fix network-related functionality
PR: 144575 ([1]), 138786 ([2])
Submitted by: Ganael Laplanche <ganael.laplanche@martymac.com> [1],
Martin Laabs <spamtrap@martinlaabs.de> [2]
Patch by: Ganael Laplanche <ganael.laplanche@martymac.com>
Revision Changes Path
1.40 +1 -1 ports/x11-toolkits/plib/Makefile
1.1 +21 -0 ports/x11-toolkits/plib/files/patch-src-net-netSocket.cxx (new)
1.1 +27 -0 ports/x11-toolkits/plib/files/patch-src-net-netSocket.h (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
amdmi3 2010-03-16 17:55:22 UTC
FreeBSD ports repository
Modified files:
devel/simgear Makefile
games/flightgear Makefile
games/flightgear-atlas Makefile
Log:
- Bump revisions on ports that use networking functions from plib after it was updated (flightgear and friends seem to be the only such ports)
PR: 144575
Submitted by: Ganael Laplanche <ganael.laplanche@martymac.com>
Approved by: portmgr (pav)
Revision Changes Path
1.38 +1 -0 ports/devel/simgear/Makefile
1.20 +1 -1 ports/games/flightgear-atlas/Makefile
1.67 +1 -0 ports/games/flightgear/Makefile
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
|
This patch fixes socket handling for netSocket class in plib. As written in src/net/netSocket.h : /* DANGER!!! This MUST match 'struct sockaddr_in' exactly! */ the netAddress class should begin with the contents of 'struct sockaddr_in' *exactly*, because casts are performed using pointers. E.g. in src/net/netSocket.cxx : int netSocket::connect ( const char* host, int port ) { [...] netAddress addr ( host, port ) ; [...] return ::connect(handle,(const sockaddr*)&addr,sizeof(netAddress)); } This patch should fix any network-related application using the plib library (e.g. simgear). It closes ports/138786. As this lib is built as static, we should also bump PORTREVISIONs for dependent apps to make them update properly. Fix: Patch attached with submission follows: