Skip to content

Commit

Permalink
Merge pull request #128 from jelu/release/1.7.3
Browse files Browse the repository at this point in the history
Release/1.7.3
  • Loading branch information
jelu authored Sep 4, 2024
2 parents 4e04e42 + 24b0fe7 commit 23340d1
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ libtool
src/config.h
src/stamp-h1
build
configure~

# Project specific files
src/packetq
Expand Down
11 changes: 11 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2024-09-04 Jerry Lundström

Release 1.7.3

This patch release fixes memory alignment issues and the handling of
TCP segments. Many thanks to Ray Bellis (ISC) for reporting this and
helping greatly with fixing it!

d8a06a3 C++11
8c99466 Memory align, TCP assemble

2024-08-29 Jerry Lundström

Release 1.7.2
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
# along with PacketQ. If not, see <http://www.gnu.org/licenses/>.

AC_PREREQ(2.61)
AC_INIT([packetq], [1.7.2], [[email protected]], [packetq], [https://github.com/DNS-OARC/packetq/issues])
AC_INIT([packetq], [1.7.3], [[email protected]], [packetq], [https://github.com/DNS-OARC/packetq/issues])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AC_CONFIG_SRCDIR([src/packetq.cpp])
AC_CONFIG_HEADER([src/config.h])

# Checks for programs.
AC_PROG_CXX
AS_VAR_APPEND(CXXFLAGS, [" -std=c++11"])

# Check --enable-warn-all
AC_ARG_ENABLE([warn-all], [AS_HELP_STRING([--enable-warn-all], [Enable all compiler warnings])], [
Expand Down
13 changes: 13 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
packetq (1.7.3-1~unstable+1) unstable; urgency=low

* Release 1.7.3

This patch release fixes memory alignment issues and the handling of
TCP segments. Many thanks to Ray Bellis (ISC) for reporting this and
helping greatly with fixing it!

d8a06a3 C++11
8c99466 Memory align, TCP assemble

-- Jerry Lundström <[email protected]> Wed, 04 Sep 2024 14:46:27 +0200

packetq (1.7.2-1~unstable+1) unstable; urgency=low

* Release 1.7.2
Expand Down
10 changes: 9 additions & 1 deletion rpm/packetq.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: packetq
Version: 1.7.2
Version: 1.7.3
Release: 1%{?dist}
Summary: A tool that provides a basic SQL-frontend to PCAP-files
Group: Productivity/Networking/DNS/Utilities
Expand Down Expand Up @@ -56,6 +56,14 @@ rm -rf $RPM_BUILD_ROOT


%changelog
* Wed Sep 04 2024 Jerry Lundström <[email protected]> 1.7.3-1
- Release 1.7.3
* This patch release fixes memory alignment issues and the handling of
TCP segments. Many thanks to Ray Bellis (ISC) for reporting this and
helping greatly with fixing it!
* Commits:
d8a06a3 C++11
8c99466 Memory align, TCP assemble
* Thu Aug 29 2024 Jerry Lundström <[email protected]> 1.7.2-1
- Release 1.7.2
* This patch release fixes various issues reported by CI/code analysis
Expand Down
4 changes: 1 addition & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ SUBDIRS = test
AM_CXXFLAGS = -I$(srcdir) \
-I$(srcdir)/Murmur \
-I$(top_srcdir) \
$(libmaxminddb_CFLAGS) \
-std=c++0x \
-Wall -Wno-parentheses -Wno-switch -Wno-sign-compare -Wno-char-subscripts
$(libmaxminddb_CFLAGS)

bin_PROGRAMS = packetq

Expand Down
36 changes: 19 additions & 17 deletions src/sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class Allocator {

void add_buffer()
{
m_curr_buffer = new Buffer(*this);
m_curr_buffer = new _Buffer(*this);
m_buffers.push_back(m_curr_buffer);
}
T* allocate()
Expand All @@ -243,28 +243,30 @@ class Allocator {
}
void deallocate(T* item)
{
Buffer** buffptr = (Buffer**)item;
_Buffer** buffptr = (_Buffer**)item;
buffptr[-1]->deallocate(item);
}

private:
class Buffer {
class _Buffer {
private:
Buffer& operator=(const Buffer& other);
Buffer(Buffer&& other) noexcept;
Buffer const& operator=(Buffer&& other);
_Buffer& operator=(const _Buffer& other);
_Buffer(_Buffer&& other) noexcept;
_Buffer const& operator=(_Buffer&& other);

public:
friend class Allocator;
Buffer(Allocator& allocator)
_Buffer(Allocator& allocator)
: m_allocator(allocator)
{
m_has_space = true;
m_used = 0;
m_stride = (sizeof(Buffer*) + m_allocator.m_size);
m_memory = (char*)calloc(m_stride, m_allocator.m_buffersize);
m_stride = (sizeof(_Buffer*) + m_allocator.m_size);
// align size of m_stride to that of a pointer
m_stride = ((m_stride / sizeof(void*)) + 1) * sizeof(void*);
m_memory = (char*)calloc(m_stride, m_allocator.m_buffersize);
}
~Buffer()
~_Buffer()
{
free(m_memory);
}
Expand All @@ -277,10 +279,10 @@ class Allocator {
m_free_list.pop();
}
if (!obj && m_used < m_allocator.m_buffersize) {
char* ptr = &m_memory[m_stride * m_used++];
Buffer** b = (Buffer**)ptr;
*b = this;
obj = (T*)(&b[1]);
char* ptr = &m_memory[m_stride * m_used++];
_Buffer** b = (_Buffer**)ptr;
*b = this;
obj = (T*)(&b[1]);
}
m_has_space = true;
if (!obj)
Expand All @@ -302,8 +304,8 @@ class Allocator {
char* m_memory;
};

Buffer* m_curr_buffer;
std::list<Buffer*> m_buffers;
_Buffer* m_curr_buffer;
std::list<_Buffer*> m_buffers;

int m_buffersize;
int m_size;
Expand Down Expand Up @@ -452,7 +454,7 @@ class Table {
std::vector<int> m_text_column_offsets;
};

#define ROW_DUMMY_SIZE 4
#define ROW_DUMMY_SIZE sizeof(void*)

class Row {
public:
Expand Down
28 changes: 10 additions & 18 deletions src/tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ namespace packetq {
class Stream_id {
public:
/// constructor
Stream_id()
: m_src_port(0)
, m_dst_port(0)
{
memset(&m_src_ip, 0, sizeof(m_src_ip));
memset(&m_dst_ip, 0, sizeof(m_dst_ip));
}
/// constructor taking source and destination adresses
Stream_id(in6addr_t& src_ip,
in6addr_t& dst_ip,
unsigned short src_port,
Expand All @@ -55,15 +47,7 @@ class Stream_id {
/// < comparison operator for the std::map
bool operator<(const Stream_id& rhs) const
{
if (memcmp(&m_src_ip.__in6_u.__u6_addr8, &rhs.m_src_ip.__in6_u.__u6_addr8, sizeof(m_src_ip.__in6_u.__u6_addr8)) < 0)
return true;
if (memcmp(&m_dst_ip.__in6_u.__u6_addr8, &rhs.m_dst_ip.__in6_u.__u6_addr8, sizeof(m_dst_ip.__in6_u.__u6_addr8)) < 0)
return true;
if (m_src_port < rhs.m_src_port)
return true;
if (m_dst_port < rhs.m_dst_port)
return true;
return false;
return memcmp(this, &rhs, sizeof(*this)) < 0;
}

private:
Expand Down Expand Up @@ -128,6 +112,10 @@ class Stream {
m_nseq = false;
m_seq = 0;
}
~Stream()
{
m_segments.clear();
}
/// add a datasegment to the stream
/** If the segment has the expected sequence number
* the segment will be added to the list
Expand Down Expand Up @@ -255,7 +243,11 @@ assemble_tcp(

data = 0;
if (str.has_content()) {
int size = str.get_size();
int size = str.get_size();
if (size < 2) {
// need at least dnslen
return 0;
}
unsigned char* buffer = str.get_buffer();
int dns_size = (int(buffer[0]) << 8) | buffer[1];

Expand Down

0 comments on commit 23340d1

Please sign in to comment.