diff --git a/include/tins/dot11/dot11_mgmt.h b/include/tins/dot11/dot11_mgmt.h index e1ae39a..09ad501 100644 --- a/include/tins/dot11/dot11_mgmt.h +++ b/include/tins/dot11/dot11_mgmt.h @@ -463,7 +463,8 @@ public: uint16_t dwell_time; uint8_t hop_set, hop_pattern, hop_index; - fh_params_set() {} + fh_params_set() + : dwell_time(0), hop_set(0), hop_pattern(0), hop_index(0) {} fh_params_set(uint16_t dwell_time, uint8_t hop_set, @@ -482,7 +483,8 @@ public: uint8_t cfp_count, cfp_period; uint16_t cfp_max_duration, cfp_dur_remaining; - cf_params_set() {} + cf_params_set() + : cfp_count(0), cfp_period(0), cfp_max_duration(0), cfp_dur_remaining(0) {} cf_params_set(uint8_t cfp_count, uint8_t cfp_period, @@ -505,7 +507,7 @@ public: uint8_t recovery_interval; channel_map_type channel_map; - ibss_dfs_params() {} + ibss_dfs_params() : recovery_interval(0) {} ibss_dfs_params(const address_type& addr, uint8_t recovery_interval, @@ -547,7 +549,8 @@ public: uint8_t flag, number_of_sets, modulus, offset; byte_array random_table; - fh_pattern_type() {} + fh_pattern_type() + : flag(0), number_of_sets(0), modulus(0), offset(0) {} fh_pattern_type(uint8_t flag, uint8_t sets, @@ -566,7 +569,8 @@ public: struct channel_switch_type { uint8_t switch_mode, new_channel, switch_count; - channel_switch_type() {} + channel_switch_type() + : switch_mode(0), new_channel(0), switch_count(0) {} channel_switch_type(uint8_t mode, uint8_t channel, @@ -583,7 +587,8 @@ public: uint8_t quiet_count, quiet_period; uint16_t quiet_duration, quiet_offset; - quiet_type() {} + quiet_type() + : quiet_count(0), quiet_period(0), quiet_duration(0), quiet_offset(0) {} quiet_type(uint8_t count, uint8_t period, @@ -603,7 +608,8 @@ public: uint16_t available_capacity; uint8_t channel_utilization; - bss_load_type() {} + bss_load_type() + : station_count(0), available_capacity(0), channel_utilization(0) {} bss_load_type(uint16_t count, uint8_t utilization, uint16_t capacity) : station_count(count), available_capacity(capacity), @@ -619,7 +625,8 @@ public: uint8_t dtim_count, dtim_period, bitmap_control; byte_array partial_virtual_bitmap; - tim_type() {} + tim_type() + : dtim_count(0), dtim_period(0), bitmap_control(0) {} tim_type(uint8_t count, uint8_t period, diff --git a/include/tins/icmp.h b/include/tins/icmp.h index 890bd85..c357a37 100644 --- a/include/tins/icmp.h +++ b/include/tins/icmp.h @@ -507,7 +507,9 @@ private: bool are_extensions_allowed() const; icmp_header header_; - uint32_t orig_timestamp_or_address_mask_, recv_timestamp_, trans_timestamp_; + uint32_t orig_timestamp_or_address_mask_; + uint32_t recv_timestamp_; + uint32_t trans_timestamp_; ICMPExtensionsStructure extensions_; }; diff --git a/include/tins/icmpv6.h b/include/tins/icmpv6.h index ec70eef..7a34523 100644 --- a/include/tins/icmpv6.h +++ b/include/tins/icmpv6.h @@ -251,8 +251,8 @@ public: uint8_t prefix_len; small_uint<1> A, L; uint32_t valid_lifetime, - preferred_lifetime, - reserved2; + preferred_lifetime, + reserved2; ipaddress_type prefix; prefix_info_type(uint8_t prefix_len = 0, @@ -262,7 +262,7 @@ public: uint32_t preferred_lifetime = 0, const ipaddress_type& prefix = ipaddress_type()) : prefix_len(prefix_len), A(A), L(L), valid_lifetime(valid_lifetime), - preferred_lifetime(preferred_lifetime), prefix(prefix) { } + preferred_lifetime(preferred_lifetime), reserved2(0), prefix(prefix) { } static prefix_info_type from_option(const option& opt); }; diff --git a/include/tins/pdu_option.h b/include/tins/pdu_option.h index ab63796..63be671 100644 --- a/include/tins/pdu_option.h +++ b/include/tins/pdu_option.h @@ -333,8 +333,10 @@ public: PDUOption(option_type opt = option_type(), size_t length = 0, const data_type* data = 0) - : option_(opt), size_(static_cast(length)) { - set_payload_contents(data, data + (data ? length : 0)); + : option_(opt), size_(static_cast(length)), real_size_(0) { + if (data != 0) { + set_payload_contents(data, data + length); + } } /** diff --git a/include/tins/radiotap.h b/include/tins/radiotap.h index a613512..61bf599 100644 --- a/include/tins/radiotap.h +++ b/include/tins/radiotap.h @@ -506,10 +506,21 @@ private: radiotap_hdr radio_; // present fields... uint64_t tsft_; - uint16_t channel_type_, channel_freq_, rx_flags_, signal_quality_, tx_flags_; + uint16_t channel_type_; + uint16_t channel_freq_; + uint16_t rx_flags_; + uint16_t signal_quality_; + uint16_t tx_flags_; mcs_type mcs_; - uint8_t antenna_, flags_, rate_, channel_, max_power_, db_signal_, data_retries_; - int8_t dbm_signal_, dbm_noise_; + uint8_t antenna_; + uint8_t flags_; + uint8_t rate_; + uint8_t channel_; + uint8_t max_power_; + uint8_t db_signal_; + uint8_t data_retries_; + int8_t dbm_signal_; + int8_t dbm_noise_; }; } diff --git a/include/tins/tcp_ip/flow.h b/include/tins/tcp_ip/flow.h index 977247e..9c48cd1 100644 --- a/include/tins/tcp_ip/flow.h +++ b/include/tins/tcp_ip/flow.h @@ -297,7 +297,7 @@ public: private: // Compress all flags into just one struct using bitfields struct flags { - flags() : ignore_data_packets(0), sack_permitted(0), ack_tracking(0) { + flags() : is_v6(0), ignore_data_packets(0), sack_permitted(0), ack_tracking(0) { } diff --git a/include/tins/tcp_stream.h b/include/tins/tcp_stream.h index ddeb0c3..d2bdbbd 100644 --- a/include/tins/tcp_stream.h +++ b/include/tins/tcp_stream.h @@ -60,10 +60,10 @@ public: IPv4Address client_addr, server_addr; uint16_t client_port, server_port; - StreamInfo() {} + StreamInfo() : client_port(0), server_port(0) {} StreamInfo(IPv4Address client, IPv4Address server, - uint16_t cport, uint16_t sport); + uint16_t cport, uint16_t sport); bool operator<(const StreamInfo& rhs) const; }; diff --git a/src/crypto.cpp b/src/crypto.cpp index c5b44b4..117dc7d 100644 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -270,7 +270,7 @@ SessionKeys::SessionKeys(const ptk_type& ptk, bool is_ccmp) } SessionKeys::SessionKeys(const RSNHandshake& hs, const pmk_type& pmk) -: ptk_(PTK_SIZE) { +: ptk_(PTK_SIZE), is_ccmp_(false) { if (pmk.size() != PMK_SIZE) { throw invalid_handshake(); } diff --git a/src/dns.cpp b/src/dns.cpp index dd8bb73..0b76139 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -605,7 +605,7 @@ bool DNS::matches_response(const uint8_t* ptr, uint32_t total_sz) const { // SOA record DNS::soa_record::soa_record() -: serial_(0), refresh_(0), retry_(0), expire_(0) { +: serial_(0), refresh_(0), retry_(0), expire_(0), minimum_ttl_(0) { } diff --git a/src/dot11/dot11_control.cpp b/src/dot11/dot11_control.cpp index 39e51e4..83ab999 100644 --- a/src/dot11/dot11_control.cpp +++ b/src/dot11/dot11_control.cpp @@ -196,7 +196,7 @@ uint32_t Dot11BlockAckRequest::header_size() const { Dot11BlockAck::Dot11BlockAck(const address_type& dst_addr, const address_type& target_addr) -: Dot11ControlTA(dst_addr, target_addr), bitmap_() { +: Dot11ControlTA(dst_addr, target_addr), bar_control_(0), start_sequence_(0), bitmap_() { subtype(BLOCK_ACK); } diff --git a/src/icmp.cpp b/src/icmp.cpp index 1c2a670..cc59a84 100644 --- a/src/icmp.cpp +++ b/src/icmp.cpp @@ -59,7 +59,8 @@ ICMP::ICMP(Flags flag) type(flag); } -ICMP::ICMP(const uint8_t* buffer, uint32_t total_sz) { +ICMP::ICMP(const uint8_t* buffer, uint32_t total_sz) +: orig_timestamp_or_address_mask_(), recv_timestamp_(), trans_timestamp_() { InputMemoryStream stream(buffer, total_sz); stream.read(header_); if (type() == TIMESTAMP_REQUEST || type() == TIMESTAMP_REPLY) { diff --git a/src/icmpv6.cpp b/src/icmpv6.cpp index 0ba43c7..585bcd6 100644 --- a/src/icmpv6.cpp +++ b/src/icmpv6.cpp @@ -47,13 +47,13 @@ using Tins::Memory::OutputMemoryStream; namespace Tins { ICMPv6::ICMPv6(Types tp) -: options_size_(), reach_time_(0), retrans_timer_(0) { +: options_size_(), reach_time_(0), retrans_timer_(0), mlqm_() { memset(&header_, 0, sizeof(header_)); type(tp); } ICMPv6::ICMPv6(const uint8_t* buffer, uint32_t total_sz) -: options_size_(), reach_time_(0), retrans_timer_(0) { +: options_size_(), reach_time_(0), retrans_timer_(0), mlqm_() { InputMemoryStream stream(buffer, total_sz); stream.read(header_); if (has_target_addr()) { @@ -850,7 +850,7 @@ ICMPv6::prefix_info_type ICMPv6::prefix_info_type::from_option(const option& opt output.A = (stream.read() >> 6) & 0x1; output.valid_lifetime = stream.read_be(); output.preferred_lifetime = stream.read_be(); - stream.skip(sizeof(uint32_t)); + output.reserved2 = stream.read_be(); output.prefix = stream.read(); return output; } diff --git a/src/ip_reassembler.cpp b/src/ip_reassembler.cpp index df784c2..6bb735f 100644 --- a/src/ip_reassembler.cpp +++ b/src/ip_reassembler.cpp @@ -39,7 +39,7 @@ namespace Tins { namespace Internals { IPv4Stream::IPv4Stream() -: received_end_(false), received_size_(), total_size_() { +: received_end_(false), transport_proto_(0xff), received_size_(), total_size_() { } diff --git a/src/packet_sender.cpp b/src/packet_sender.cpp index ecab256..ebc1744 100644 --- a/src/packet_sender.cpp +++ b/src/packet_sender.cpp @@ -263,7 +263,9 @@ void PacketSender::open_l3_socket(SocketType type) { #else typedef const char* option_ptr; #endif - setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL,(option_ptr)&on,sizeof(on)); + if (setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, (option_ptr)&on, sizeof(on)) != 0) { + throw socket_open_error(make_error_string()); + } sockets_[type] = static_cast(sockfd); } diff --git a/src/rsn_information.cpp b/src/rsn_information.cpp index df641dc..cc58616 100644 --- a/src/rsn_information.cpp +++ b/src/rsn_information.cpp @@ -43,7 +43,7 @@ using Tins::Memory::OutputMemoryStream; namespace Tins { RSNInformation::RSNInformation() -: version_(1), capabilities_(0) { +: version_(1), capabilities_(0), group_suite_(static_cast(0)) { } diff --git a/src/sniffer.cpp b/src/sniffer.cpp index e22bb6a..9ea2741 100644 --- a/src/sniffer.cpp +++ b/src/sniffer.cpp @@ -87,7 +87,7 @@ struct sniff_data { PDU* pdu; bool packet_processed; - sniff_data() : pdu(0), packet_processed(true) { } +sniff_data() : tv(), pdu(0), packet_processed(true) { } }; template @@ -408,7 +408,7 @@ const unsigned SnifferConfiguration::DEFAULT_TIMEOUT = 1000; SnifferConfiguration::SnifferConfiguration() : flags_(0), snap_len_(DEFAULT_SNAP_LEN), buffer_size_(0), timeout_(DEFAULT_TIMEOUT), - promisc_(false), rfmon_(false), immediate_mode_(false) { + promisc_(false), rfmon_(false), immediate_mode_(false), direction_(PCAP_D_INOUT) { }