Merge pull request #68 from raboof/fix-stack-buffer-overflow
Fix stack buffer overflow
This commit is contained in:
@@ -5,7 +5,7 @@ all: nethogs decpcap_test
|
|||||||
# nethogs_testsum
|
# nethogs_testsum
|
||||||
|
|
||||||
CFLAGS?=-Wall -Wextra
|
CFLAGS?=-Wall -Wextra
|
||||||
CXXFLAGS?=-Wall -Wextra
|
CXXFLAGS?=-Wall -Wextra -Wno-missing-field-initializers
|
||||||
|
|
||||||
OBJS=packet.o connection.o process.o decpcap.o cui.o inode2prog.o conninode.o devices.o
|
OBJS=packet.o connection.o process.o decpcap.o cui.o inode2prog.o conninode.o devices.o
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ ifeq ($(DEBUG),1)
|
|||||||
$(info Bulding debug version)
|
$(info Bulding debug version)
|
||||||
ODIR:=$(ODIR_BASE)/lib/debug
|
ODIR:=$(ODIR_BASE)/lib/debug
|
||||||
CFLAGS?=-Wall -Wextra -O0 -g -fPIC $(VISIBILITY)
|
CFLAGS?=-Wall -Wextra -O0 -g -fPIC $(VISIBILITY)
|
||||||
CXXFLAGS?=-Wall -Wextra --std=c++0x -O0 -g -fPIC $(VISIBILITY) $(CXXINCLUDES)
|
CXXFLAGS?=-Wall -Wextra -Wno-missing-field-initializers --std=c++0x -O0 -g -fPIC $(VISIBILITY) $(CXXINCLUDES)
|
||||||
else
|
else
|
||||||
# Release mode options
|
# Release mode options
|
||||||
ODIR:=$(ODIR_BASE)/lib/release
|
ODIR:=$(ODIR_BASE)/lib/release
|
||||||
CFLAGS?=-Wall -Wextra -O3 -fPIC $(VISIBILITY)
|
CFLAGS?=-Wall -Wextra -O3 -fPIC $(VISIBILITY)
|
||||||
CXXFLAGS?=-Wall -Wextra --std=c++0x -O3 -fPIC $(VISIBILITY) $(CXXINCLUDES)
|
CXXFLAGS?=-Wall -Wextra -Wno-missing-field-initializers --std=c++0x -O3 -fPIC $(VISIBILITY) $(CXXINCLUDES)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJ_NAMES= libnethogs.o packet.o connection.o process.o decpcap.o inode2prog.o conninode.o devices.o
|
OBJ_NAMES= libnethogs.o packet.o connection.o process.o decpcap.o inode2prog.o conninode.o devices.o
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ std::map<std::string, unsigned long> conninode;
|
|||||||
*/
|
*/
|
||||||
void addtoconninode(char *buffer) {
|
void addtoconninode(char *buffer) {
|
||||||
short int sa_family;
|
short int sa_family;
|
||||||
struct in6_addr result_addr_local;
|
struct in6_addr result_addr_local = {};
|
||||||
struct in6_addr result_addr_remote;
|
struct in6_addr result_addr_remote = {};
|
||||||
|
|
||||||
char rem_addr[128], local_addr[128];
|
char rem_addr[128], local_addr[128];
|
||||||
int local_port, rem_port;
|
int local_port, rem_port;
|
||||||
@@ -102,8 +102,8 @@ void addtoconninode(char *buffer) {
|
|||||||
if ((in6_local.s6_addr32[0] == 0x0) && (in6_local.s6_addr32[1] == 0x0) &&
|
if ((in6_local.s6_addr32[0] == 0x0) && (in6_local.s6_addr32[1] == 0x0) &&
|
||||||
(in6_local.s6_addr32[2] == 0xFFFF0000)) {
|
(in6_local.s6_addr32[2] == 0xFFFF0000)) {
|
||||||
/* IPv4-compatible address */
|
/* IPv4-compatible address */
|
||||||
result_addr_local = *((struct in6_addr *)&(in6_local.s6_addr32[3]));
|
result_addr_local.s6_addr32[0] = in6_local.s6_addr32[3];
|
||||||
result_addr_remote = *((struct in6_addr *)&(in6_remote.s6_addr32[3]));
|
result_addr_remote.s6_addr32[0] = in6_remote.s6_addr32[3];
|
||||||
sa_family = AF_INET;
|
sa_family = AF_INET;
|
||||||
} else {
|
} else {
|
||||||
/* real IPv6 address */
|
/* real IPv6 address */
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ struct tcp_hdr {
|
|||||||
#define TH_URG 0x20
|
#define TH_URG 0x20
|
||||||
#define TH_ECE 0x40
|
#define TH_ECE 0x40
|
||||||
#define TH_CWR 0x80
|
#define TH_CWR 0x80
|
||||||
#define TH_FLAGS (TH_FIN | TH_SYN | TH_RST | TH_ACK | TH_URG | TH_ECE | TH_CWR)
|
|
||||||
u_short th_win; /* window */
|
u_short th_win; /* window */
|
||||||
u_short th_sum; /* checksum */
|
u_short th_sum; /* checksum */
|
||||||
u_short th_urp; /* urgent pointer */
|
u_short th_urp; /* urgent pointer */
|
||||||
|
|||||||
Reference in New Issue
Block a user