From ef1650f6a2072bc686b265e1d0a5e5ec3529b80a Mon Sep 17 00:00:00 2001 From: Seth Hall Date: Thu, 20 Jan 2011 15:07:24 -0500 Subject: [PATCH 1/6] Cleaned up g++ warnings. --- src/DCE_RPC.cc | 2 +- src/PrefixTable.cc | 4 ++-- src/RemoteSerializer.cc | 26 +++++++++++++------------- src/SMB.cc | 2 +- src/cq.c | 2 +- src/dce_rpc.pac | 4 ++-- src/patricia.c | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/DCE_RPC.cc b/src/DCE_RPC.cc index fe163f2632..62f7806c51 100644 --- a/src/DCE_RPC.cc +++ b/src/DCE_RPC.cc @@ -82,7 +82,7 @@ UUID::UUID(const char* str) } if ( i != 16 ) - internal_error(fmt("invalid UUID string: %s", str)); + internal_error("invalid UUID string: %s", str); } typedef map uuid_map_t; diff --git a/src/PrefixTable.cc b/src/PrefixTable.cc index e654b8440e..b3313c82e5 100644 --- a/src/PrefixTable.cc +++ b/src/PrefixTable.cc @@ -99,8 +99,8 @@ void* PrefixTable::Lookup(const Val* value, bool exact) const break; default: - internal_error(fmt("Wrong index type %d for PrefixTable", - value->Type()->Tag())); + internal_error("Wrong index type %d for PrefixTable", + value->Type()->Tag()); return 0; } } diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc index a9329cc9cb..6709ea0456 100644 --- a/src/RemoteSerializer.cc +++ b/src/RemoteSerializer.cc @@ -1505,13 +1505,13 @@ bool RemoteSerializer::DoMessage() { // We shut the connection to this peer down, // so we ignore all further messages. - DEBUG_COMM(fmt("parent: ignoring %s due to shutdown of peer #%d", + DEBUG_COMM(fmt("parent: ignoring %s due to shutdown of peer #%llu", msgToStr(current_msgtype), current_peer ? current_peer->id : 0)); return true; } - DEBUG_COMM(fmt("parent: %s from child; peer is #%d", + DEBUG_COMM(fmt("parent: %s from child; peer is #%llu", msgToStr(current_msgtype), current_peer ? current_peer->id : 0)); @@ -2610,7 +2610,7 @@ bool RemoteSerializer::SendCMsgToChild(char msg_type, Peer* peer) bool RemoteSerializer::SendToChild(char type, Peer* peer, char* str, int len) { - DEBUG_COMM(fmt("parent: (->child) %s (#%d, %s)", msgToStr(type), peer ? peer->id : PEER_NONE, str)); + DEBUG_COMM(fmt("parent: (->child) %s (#%d, %s)", msgToStr(type), (uint32_t) (peer ? peer->id : PEER_NONE), str)); if ( ! child_pid ) return false; @@ -2635,7 +2635,7 @@ bool RemoteSerializer::SendToChild(char type, Peer* peer, int nargs, ...) #ifdef DEBUG va_start(ap, nargs); DEBUG_COMM(fmt("parent: (->child) %s (#%d,%s)", - msgToStr(type), peer ? peer->id : PEER_NONE, fmt_uint32s(nargs, ap))); + msgToStr(type), (uint32_t) (peer ? peer->id : PEER_NONE), fmt_uint32s(nargs, ap))); va_end(ap); #endif @@ -2715,7 +2715,7 @@ void RemoteSerializer::InternalCommError(const char* msg) #ifdef DEBUG_COMMUNICATION DumpDebugData(); #else - internal_error(msg); + internal_error(msg, ""); #endif } @@ -3065,7 +3065,7 @@ bool SocketComm::ProcessParentMessage() } default: - internal_error(fmt("unknown msg type %d", parent_msgtype)); + internal_error("unknown msg type %d", parent_msgtype); return true; } @@ -3235,7 +3235,7 @@ bool SocketComm::ForwardChunkToPeer() { #ifdef DEBUG if ( parent_peer ) - DEBUG_COMM(fmt("child: not connected to #%d", parent_id)); + DEBUG_COMM(fmt("child: not connected to #%d", (uint) parent_id)); #endif } @@ -3319,7 +3319,7 @@ bool SocketComm::ProcessRemoteMessage(SocketComm::Peer* peer) CMsg* msg = (CMsg*) c->data; DEBUG_COMM(fmt("child: %s from peer #%d", - msgToStr(msg->Type()), peer->id)); + msgToStr(msg->Type()), (uint) peer->id)); switch ( msg->Type() ) { case MSG_PHASE_DONE: @@ -3795,7 +3795,7 @@ bool SocketComm::SendToParent(char type, Peer* peer, const char* str, int len) #ifdef DEBUG // str may already by constructed with fmt() const char* tmp = copy_string(str); - DEBUG_COMM(fmt("child: (->parent) %s (#%d, %s)", msgToStr(type), peer ? peer->id : RemoteSerializer::PEER_NONE, tmp)); + DEBUG_COMM(fmt("child: (->parent) %s (#%d, %s)", msgToStr(type), (uint) (peer ? peer->id : RemoteSerializer::PEER_NONE), tmp)); delete [] tmp; #endif if ( sendToIO(io, type, peer ? peer->id : RemoteSerializer::PEER_NONE, @@ -3814,7 +3814,7 @@ bool SocketComm::SendToParent(char type, Peer* peer, int nargs, ...) #ifdef DEBUG va_start(ap,nargs); - DEBUG_COMM(fmt("child: (->parent) %s (#%d,%s)", msgToStr(type), peer ? peer->id : RemoteSerializer::PEER_NONE, fmt_uint32s(nargs, ap))); + DEBUG_COMM(fmt("child: (->parent) %s (#%d,%s)", msgToStr(type), (uint) (peer ? peer->id : RemoteSerializer::PEER_NONE), fmt_uint32s(nargs, ap))); va_end(ap); #endif @@ -3850,7 +3850,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, const char* str, int len) #ifdef DEBUG // str may already by constructed with fmt() const char* tmp = copy_string(str); - DEBUG_COMM(fmt("child: (->peer) %s to #%d (%s)", msgToStr(type), peer->id, tmp)); + DEBUG_COMM(fmt("child: (->peer) %s to #%d (%s)", msgToStr(type), (uint) peer->id, tmp)); delete [] tmp; #endif @@ -3870,7 +3870,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, int nargs, ...) #ifdef DEBUG va_start(ap,nargs); DEBUG_COMM(fmt("child: (->peer) %s to #%d (%s)", - msgToStr(type), peer->id, fmt_uint32s(nargs, ap))); + msgToStr(type), (uint) peer->id, fmt_uint32s(nargs, ap))); va_end(ap); #endif @@ -3890,7 +3890,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, int nargs, ...) bool SocketComm::SendToPeer(Peer* peer, ChunkedIO::Chunk* c) { - DEBUG_COMM(fmt("child: (->peer) chunk of size %d to #%d", c->len, peer->id)); + DEBUG_COMM(fmt("child: (->peer) chunk of size %d to #%d", c->len, (uint) peer->id)); if ( ! sendToIO(peer->io, c) ) { Error(fmt("child: write error %s", io->Error()), peer); diff --git a/src/SMB.cc b/src/SMB.cc index 7ee6986d3d..a950302090 100644 --- a/src/SMB.cc +++ b/src/SMB.cc @@ -166,7 +166,7 @@ void SMB_Session::Deliver(int is_orig, int len, const u_char* data) const u_char* tmp = data_start + next; if ( data_start + next < data + body.length() ) { - Weird(fmt("ANDX buffer overlapping: next = %d, buffer_end = %d", next, data + body.length() - data_start)); + Weird(fmt("ANDX buffer overlapping: next = %d, buffer_end = %ld", next, data + body.length() - data_start)); break; } diff --git a/src/cq.c b/src/cq.c index 63e4275369..5263fb17b1 100644 --- a/src/cq.c +++ b/src/cq.c @@ -570,7 +570,7 @@ cq_debugbucket(register struct cq_handle *hp, bp2 = hp->buckets + PRI2BUCKET(hp, bp->pri); if (bp2 != buckets) { fprintf(stderr, - "%f in wrong bucket! (off by %d)\n", + "%f in wrong bucket! (off by %ld)\n", bp->pri, bp2 - buckets); cq_dump(hp); abort(); diff --git a/src/dce_rpc.pac b/src/dce_rpc.pac index 0aa689b532..58c2250c26 100644 --- a/src/dce_rpc.pac +++ b/src/dce_rpc.pac @@ -8,5 +8,5 @@ analyzer DCE_RPC withcontext { flow: DCE_RPC_Flow; }; -%include "dce_rpc-protocol.pac" -%include "dce_rpc-analyzer.pac" +%include dce_rpc-protocol.pac +%include dce_rpc-analyzer.pac diff --git a/src/patricia.c b/src/patricia.c index c9d271803c..8e40cb5ef6 100644 --- a/src/patricia.c +++ b/src/patricia.c @@ -1027,7 +1027,7 @@ lookup_then_remove (patricia_tree_t *tree, char *string) { patricia_node_t *node; - if (node = try_search_exact (tree, string)) + if ( (node = try_search_exact(tree, string)) ) patricia_remove (tree, node); } From b7b29c6f92bd5ffa5ba4053e7fa9041ec8840d6c Mon Sep 17 00:00:00 2001 From: Seth Hall Date: Thu, 20 Jan 2011 15:08:54 -0500 Subject: [PATCH 2/6] Added line to expect shift/reduce errors in parse.in This is the resolution that Gregor brought up in December, 2010 on the bro-dev list. --- src/parse.y | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/parse.y b/src/parse.y index b0bb39f0ea..1eed09cbf1 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3,6 +3,8 @@ // See the file "COPYING" in the main distribution directory for copyright. %} +%expect 71 + %token TOK_ADD TOK_ADD_TO TOK_ADDR TOK_ALARM TOK_ANY %token TOK_ATENDIF TOK_ATELSE TOK_ATIF TOK_ATIFDEF TOK_ATIFNDEF %token TOK_BOOL TOK_BREAK TOK_CASE TOK_CONST From fbf7d5ccc0c6566e6a195b400bbe99548dca49cf Mon Sep 17 00:00:00 2001 From: Seth Hall Date: Thu, 20 Jan 2011 15:10:31 -0500 Subject: [PATCH 3/6] Cleaned up the output from running binpac. Added an extra dependency to the dce_rpc pac files and running binpac with the -q (quiet) flag which requires changes to binpac which will be committed soon. --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 81ed0d81af..927f5e660b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -160,7 +160,7 @@ macro(BINPAC_TARGET pacFile) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${basename}_pac.h ${CMAKE_CURRENT_BINARY_DIR}/${basename}_pac.cc COMMAND ${BinPAC_EXE} - ARGS -d ${CMAKE_CURRENT_BINARY_DIR} + ARGS -q -d ${CMAKE_CURRENT_BINARY_DIR} -I ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${pacFile} DEPENDS ${BinPAC_EXE} ${pacFile} @@ -177,9 +177,9 @@ binpac_target(binpac_bro-lib.pac) binpac_target(bittorrent.pac bittorrent-protocol.pac bittorrent-analyzer.pac) binpac_target(dce_rpc.pac - dce_rpc-protocol.pac dce_rpc-analyzer.pac) + dce_rpc-protocol.pac dce_rpc-analyzer.pac epmapper.pac) binpac_target(dce_rpc_simple.pac - dce_rpc-protocol.pac) + dce_rpc-protocol.pac epmapper.pac) binpac_target(dhcp.pac dhcp-protocol.pac dhcp-analyzer.pac) binpac_target(dns.pac From 64182833717f803e9f45c0f9d050a9732caf92e8 Mon Sep 17 00:00:00 2001 From: Seth Hall Date: Mon, 24 Jan 2011 13:43:49 -0500 Subject: [PATCH 4/6] Two more small compile time error fixes. --- src/Sessions.cc | 2 +- src/main.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Sessions.cc b/src/Sessions.cc index fd443d4dcc..ffa5cd22f5 100644 --- a/src/Sessions.cc +++ b/src/Sessions.cc @@ -1354,7 +1354,7 @@ void NetSessions::Internal(const char* msg, const struct pcap_pkthdr* hdr, const u_char* pkt) { DumpPacket(hdr, pkt); - internal_error(msg); + internal_error("%s", msg); } void NetSessions::Weird(const char* name, diff --git a/src/main.cc b/src/main.cc index 82866302fd..a8f283dcbc 100644 --- a/src/main.cc +++ b/src/main.cc @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef HAVE_GETOPT_H #include #endif @@ -421,7 +422,7 @@ int main(int argc, char** argv) prog = argv[0]; - prefixes.append(""); // "" = "no prefix" + prefixes.append(strdup("")); // "" = "no prefix" char* p = getenv("BRO_PREFIXES"); if ( p ) From 275c6e64cce6a0a9e187c347864c909e04b4ef03 Mon Sep 17 00:00:00 2001 From: Seth Hall Date: Tue, 8 Feb 2011 12:47:10 -0500 Subject: [PATCH 5/6] PRI macros are currently not working for some reason. --- src/RemoteSerializer.cc | 29 +++++++++++++++-------------- src/SMB.cc | 4 +++- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc index 6709ea0456..7d731c5204 100644 --- a/src/RemoteSerializer.cc +++ b/src/RemoteSerializer.cc @@ -159,6 +159,7 @@ #include #include #include +#include #include "config.h" #ifdef TIME_WITH_SYS_TIME @@ -1505,13 +1506,13 @@ bool RemoteSerializer::DoMessage() { // We shut the connection to this peer down, // so we ignore all further messages. - DEBUG_COMM(fmt("parent: ignoring %s due to shutdown of peer #%llu", + DEBUG_COMM(fmt("parent: ignoring %s due to shutdown of peer #%" PRId64, msgToStr(current_msgtype), current_peer ? current_peer->id : 0)); return true; } - DEBUG_COMM(fmt("parent: %s from child; peer is #%llu", + DEBUG_COMM(fmt("parent: %s from child; peer is #%" PRId64, msgToStr(current_msgtype), current_peer ? current_peer->id : 0)); @@ -2610,7 +2611,7 @@ bool RemoteSerializer::SendCMsgToChild(char msg_type, Peer* peer) bool RemoteSerializer::SendToChild(char type, Peer* peer, char* str, int len) { - DEBUG_COMM(fmt("parent: (->child) %s (#%d, %s)", msgToStr(type), (uint32_t) (peer ? peer->id : PEER_NONE), str)); + DEBUG_COMM(fmt("parent: (->child) %s (#%" PRId64 ", %s)", msgToStr(type), peer ? peer->id : PEER_NONE, str)); if ( ! child_pid ) return false; @@ -2634,8 +2635,8 @@ bool RemoteSerializer::SendToChild(char type, Peer* peer, int nargs, ...) #ifdef DEBUG va_start(ap, nargs); - DEBUG_COMM(fmt("parent: (->child) %s (#%d,%s)", - msgToStr(type), (uint32_t) (peer ? peer->id : PEER_NONE), fmt_uint32s(nargs, ap))); + DEBUG_COMM(fmt("parent: (->child) %s (#%" PRId64 ",%s)", + msgToStr(type), peer ? peer->id : PEER_NONE, fmt_uint32s(nargs, ap))); va_end(ap); #endif @@ -3235,7 +3236,7 @@ bool SocketComm::ForwardChunkToPeer() { #ifdef DEBUG if ( parent_peer ) - DEBUG_COMM(fmt("child: not connected to #%d", (uint) parent_id)); + DEBUG_COMM(fmt("child: not connected to #%" PRId64, parent_id)); #endif } @@ -3318,8 +3319,8 @@ bool SocketComm::ProcessRemoteMessage(SocketComm::Peer* peer) CMsg* msg = (CMsg*) c->data; - DEBUG_COMM(fmt("child: %s from peer #%d", - msgToStr(msg->Type()), (uint) peer->id)); + DEBUG_COMM(fmt("child: %s from peer #%" PRId64, + msgToStr(msg->Type()), peer->id)); switch ( msg->Type() ) { case MSG_PHASE_DONE: @@ -3795,7 +3796,7 @@ bool SocketComm::SendToParent(char type, Peer* peer, const char* str, int len) #ifdef DEBUG // str may already by constructed with fmt() const char* tmp = copy_string(str); - DEBUG_COMM(fmt("child: (->parent) %s (#%d, %s)", msgToStr(type), (uint) (peer ? peer->id : RemoteSerializer::PEER_NONE), tmp)); + DEBUG_COMM(fmt("child: (->parent) %s (#%" PRId64 ", %s)", msgToStr(type), peer ? peer->id : RemoteSerializer::PEER_NONE, tmp)); delete [] tmp; #endif if ( sendToIO(io, type, peer ? peer->id : RemoteSerializer::PEER_NONE, @@ -3814,7 +3815,7 @@ bool SocketComm::SendToParent(char type, Peer* peer, int nargs, ...) #ifdef DEBUG va_start(ap,nargs); - DEBUG_COMM(fmt("child: (->parent) %s (#%d,%s)", msgToStr(type), (uint) (peer ? peer->id : RemoteSerializer::PEER_NONE), fmt_uint32s(nargs, ap))); + DEBUG_COMM(fmt("child: (->parent) %s (#%" PRId64 ",%s)", msgToStr(type), peer ? peer->id : RemoteSerializer::PEER_NONE, fmt_uint32s(nargs, ap))); va_end(ap); #endif @@ -3850,7 +3851,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, const char* str, int len) #ifdef DEBUG // str may already by constructed with fmt() const char* tmp = copy_string(str); - DEBUG_COMM(fmt("child: (->peer) %s to #%d (%s)", msgToStr(type), (uint) peer->id, tmp)); + DEBUG_COMM(fmt("child: (->peer) %s to #%" PRId64 " (%s)", msgToStr(type), peer->id, tmp)); delete [] tmp; #endif @@ -3869,8 +3870,8 @@ bool SocketComm::SendToPeer(Peer* peer, char type, int nargs, ...) #ifdef DEBUG va_start(ap,nargs); - DEBUG_COMM(fmt("child: (->peer) %s to #%d (%s)", - msgToStr(type), (uint) peer->id, fmt_uint32s(nargs, ap))); + DEBUG_COMM(fmt("child: (->peer) %s to #%" PRId64 " (%s)", + msgToStr(type), peer->id, fmt_uint32s(nargs, ap))); va_end(ap); #endif @@ -3890,7 +3891,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, int nargs, ...) bool SocketComm::SendToPeer(Peer* peer, ChunkedIO::Chunk* c) { - DEBUG_COMM(fmt("child: (->peer) chunk of size %d to #%d", c->len, (uint) peer->id)); + DEBUG_COMM(fmt("child: (->peer) chunk of size %d to #%" PRId64, c->len, peer->id)); if ( ! sendToIO(peer->io, c) ) { Error(fmt("child: write error %s", io->Error()), peer); diff --git a/src/SMB.cc b/src/SMB.cc index a950302090..5520ef4848 100644 --- a/src/SMB.cc +++ b/src/SMB.cc @@ -6,6 +6,7 @@ #include "SMB.h" #include "smb_pac.h" #include "Val.h" +#include "inttypes.h" namespace { const bool DEBUG_smb_ipc = true; @@ -166,7 +167,8 @@ void SMB_Session::Deliver(int is_orig, int len, const u_char* data) const u_char* tmp = data_start + next; if ( data_start + next < data + body.length() ) { - Weird(fmt("ANDX buffer overlapping: next = %d, buffer_end = %ld", next, data + body.length() - data_start)); + //Weird(fmt("ANDX buffer overlapping: next = %d, buffer_end = %" PRId32, next, data + body.length() - data_start)); + printf("ANDX buffer overlapping: next = %" PRId64 ", buffer_end = %" PRId32 " ", next, data + body.length() - data_start); break; } From b54445b725609b8439a643325c1457d63382d07b Mon Sep 17 00:00:00 2001 From: Seth Hall Date: Tue, 8 Feb 2011 20:28:56 -0500 Subject: [PATCH 6/6] Fixed problem with PRI macros. Thanks Gregor! --- src/RemoteSerializer.cc | 1 - src/SMB.cc | 4 +--- src/util.h | 6 ++++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc index 7d731c5204..f185b0c4ff 100644 --- a/src/RemoteSerializer.cc +++ b/src/RemoteSerializer.cc @@ -159,7 +159,6 @@ #include #include #include -#include #include "config.h" #ifdef TIME_WITH_SYS_TIME diff --git a/src/SMB.cc b/src/SMB.cc index 5520ef4848..78caf55eab 100644 --- a/src/SMB.cc +++ b/src/SMB.cc @@ -6,7 +6,6 @@ #include "SMB.h" #include "smb_pac.h" #include "Val.h" -#include "inttypes.h" namespace { const bool DEBUG_smb_ipc = true; @@ -167,8 +166,7 @@ void SMB_Session::Deliver(int is_orig, int len, const u_char* data) const u_char* tmp = data_start + next; if ( data_start + next < data + body.length() ) { - //Weird(fmt("ANDX buffer overlapping: next = %d, buffer_end = %" PRId32, next, data + body.length() - data_start)); - printf("ANDX buffer overlapping: next = %" PRId64 ", buffer_end = %" PRId32 " ", next, data + body.length() - data_start); + Weird(fmt("ANDX buffer overlapping: next = %d, buffer_end = %" PRIdPTR, next, data + body.length() - data_start)); break; } diff --git a/src/util.h b/src/util.h index f4f007a27d..4e648cee5d 100644 --- a/src/util.h +++ b/src/util.h @@ -11,6 +11,12 @@ #include #include "config.h" +#define _ISOC99_SOURCE +#define __STDC_LIMIT_MACROS +#define __STDC_CONSTANT_MACROS +#define __STDC_FORMAT_MACROS +#include "inttypes.h" + #if __STDC__ #define myattribute __attribute__ #else