summaryrefslogtreecommitdiffstats
path: root/plugins/omudpspoof
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-11-12 11:55:04 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2009-11-12 11:55:04 +0100
commit4ae292e664260f148e7da6c1641d1490c059371e (patch)
tree08fba98add59d4d1a6cefcb54b0590c3086018d3 /plugins/omudpspoof
parent20f1c9c502beadcc5c6e549c31795e538484ec4f (diff)
downloadrsyslog-4ae292e664260f148e7da6c1641d1490c059371e.tar.gz
rsyslog-4ae292e664260f148e7da6c1641d1490c059371e.tar.xz
rsyslog-4ae292e664260f148e7da6c1641d1490c059371e.zip
bugfix: omudpspoof miscalculated source and destination ports
while this was probably not noticed for source ports, it resulted in almost all destination ports being wrong, except for the default port of 514, which by virtue of its binary representation was calculated correct (and probably thus the bug not earlier detected).
Diffstat (limited to 'plugins/omudpspoof')
-rw-r--r--plugins/omudpspoof/omudpspoof.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/omudpspoof/omudpspoof.c b/plugins/omudpspoof/omudpspoof.c
index c70ef836..50bc6c9a 100644
--- a/plugins/omudpspoof/omudpspoof.c
+++ b/plugins/omudpspoof/omudpspoof.c
@@ -181,7 +181,8 @@ ENDdbgPrintInstInfo
/* Send a message via UDP
* rgehards, 2007-12-20
*/
-static rsRetVal UDPSend(instanceData *pData, uchar *pszSourcename, char *msg, size_t len)
+static inline rsRetVal
+UDPSend(instanceData *pData, uchar *pszSourcename, char *msg, size_t len)
{
struct addrinfo *r;
int lsent = 0;
@@ -208,9 +209,10 @@ static rsRetVal UDPSend(instanceData *pData, uchar *pszSourcename, char *msg, si
for (r = pData->f_addr; r; r = r->ai_next) {
tempaddr = (struct sockaddr_in *)r->ai_addr;
libnet_clear_packet(libnet_handle);
+ /* note: libnet does need ports in host order NOT in network byte order! -- rgerhards, 2009-11-12 */
udp = libnet_build_udp(
- pData->sourcePort, /* source port */
- tempaddr->sin_port, /* destination port */
+ ntohs(pData->sourcePort),/* source port */
+ ntohs(tempaddr->sin_port),/* destination port */
LIBNET_UDP_H + len, /* packet length */
0, /* checksum */
(u_char*)msg, /* payload */