Skip to content

Commit 23340d1

Browse files
authored
Merge pull request #128 from jelu/release/1.7.3
Release/1.7.3
2 parents 4e04e42 + 24b0fe7 commit 23340d1

File tree

8 files changed

+66
-40
lines changed

8 files changed

+66
-40
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ libtool
6363
src/config.h
6464
src/stamp-h1
6565
build
66+
configure~
6667

6768
# Project specific files
6869
src/packetq

CHANGES

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2024-09-04 Jerry Lundström
2+
3+
Release 1.7.3
4+
5+
This patch release fixes memory alignment issues and the handling of
6+
TCP segments. Many thanks to Ray Bellis (ISC) for reporting this and
7+
helping greatly with fixing it!
8+
9+
d8a06a3 C++11
10+
8c99466 Memory align, TCP assemble
11+
112
2024-08-29 Jerry Lundström
213

314
Release 1.7.2

configure.ac

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
# along with PacketQ. If not, see <http://www.gnu.org/licenses/>.
1919

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

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

2930
# Check --enable-warn-all
3031
AC_ARG_ENABLE([warn-all], [AS_HELP_STRING([--enable-warn-all], [Enable all compiler warnings])], [

debian/changelog

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
packetq (1.7.3-1~unstable+1) unstable; urgency=low
2+
3+
* Release 1.7.3
4+
5+
This patch release fixes memory alignment issues and the handling of
6+
TCP segments. Many thanks to Ray Bellis (ISC) for reporting this and
7+
helping greatly with fixing it!
8+
9+
d8a06a3 C++11
10+
8c99466 Memory align, TCP assemble
11+
12+
-- Jerry Lundström <[email protected]> Wed, 04 Sep 2024 14:46:27 +0200
13+
114
packetq (1.7.2-1~unstable+1) unstable; urgency=low
215

316
* Release 1.7.2

rpm/packetq.spec

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: packetq
2-
Version: 1.7.2
2+
Version: 1.7.3
33
Release: 1%{?dist}
44
Summary: A tool that provides a basic SQL-frontend to PCAP-files
55
Group: Productivity/Networking/DNS/Utilities
@@ -56,6 +56,14 @@ rm -rf $RPM_BUILD_ROOT
5656

5757

5858
%changelog
59+
* Wed Sep 04 2024 Jerry Lundström <[email protected]> 1.7.3-1
60+
- Release 1.7.3
61+
* This patch release fixes memory alignment issues and the handling of
62+
TCP segments. Many thanks to Ray Bellis (ISC) for reporting this and
63+
helping greatly with fixing it!
64+
* Commits:
65+
d8a06a3 C++11
66+
8c99466 Memory align, TCP assemble
5967
* Thu Aug 29 2024 Jerry Lundström <[email protected]> 1.7.2-1
6068
- Release 1.7.2
6169
* This patch release fixes various issues reported by CI/code analysis

src/Makefile.am

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ SUBDIRS = test
2525
AM_CXXFLAGS = -I$(srcdir) \
2626
-I$(srcdir)/Murmur \
2727
-I$(top_srcdir) \
28-
$(libmaxminddb_CFLAGS) \
29-
-std=c++0x \
30-
-Wall -Wno-parentheses -Wno-switch -Wno-sign-compare -Wno-char-subscripts
28+
$(libmaxminddb_CFLAGS)
3129

3230
bin_PROGRAMS = packetq
3331

src/sql.h

+19-17
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class Allocator {
216216

217217
void add_buffer()
218218
{
219-
m_curr_buffer = new Buffer(*this);
219+
m_curr_buffer = new _Buffer(*this);
220220
m_buffers.push_back(m_curr_buffer);
221221
}
222222
T* allocate()
@@ -243,28 +243,30 @@ class Allocator {
243243
}
244244
void deallocate(T* item)
245245
{
246-
Buffer** buffptr = (Buffer**)item;
246+
_Buffer** buffptr = (_Buffer**)item;
247247
buffptr[-1]->deallocate(item);
248248
}
249249

250250
private:
251-
class Buffer {
251+
class _Buffer {
252252
private:
253-
Buffer& operator=(const Buffer& other);
254-
Buffer(Buffer&& other) noexcept;
255-
Buffer const& operator=(Buffer&& other);
253+
_Buffer& operator=(const _Buffer& other);
254+
_Buffer(_Buffer&& other) noexcept;
255+
_Buffer const& operator=(_Buffer&& other);
256256

257257
public:
258258
friend class Allocator;
259-
Buffer(Allocator& allocator)
259+
_Buffer(Allocator& allocator)
260260
: m_allocator(allocator)
261261
{
262262
m_has_space = true;
263263
m_used = 0;
264-
m_stride = (sizeof(Buffer*) + m_allocator.m_size);
265-
m_memory = (char*)calloc(m_stride, m_allocator.m_buffersize);
264+
m_stride = (sizeof(_Buffer*) + m_allocator.m_size);
265+
// align size of m_stride to that of a pointer
266+
m_stride = ((m_stride / sizeof(void*)) + 1) * sizeof(void*);
267+
m_memory = (char*)calloc(m_stride, m_allocator.m_buffersize);
266268
}
267-
~Buffer()
269+
~_Buffer()
268270
{
269271
free(m_memory);
270272
}
@@ -277,10 +279,10 @@ class Allocator {
277279
m_free_list.pop();
278280
}
279281
if (!obj && m_used < m_allocator.m_buffersize) {
280-
char* ptr = &m_memory[m_stride * m_used++];
281-
Buffer** b = (Buffer**)ptr;
282-
*b = this;
283-
obj = (T*)(&b[1]);
282+
char* ptr = &m_memory[m_stride * m_used++];
283+
_Buffer** b = (_Buffer**)ptr;
284+
*b = this;
285+
obj = (T*)(&b[1]);
284286
}
285287
m_has_space = true;
286288
if (!obj)
@@ -302,8 +304,8 @@ class Allocator {
302304
char* m_memory;
303305
};
304306

305-
Buffer* m_curr_buffer;
306-
std::list<Buffer*> m_buffers;
307+
_Buffer* m_curr_buffer;
308+
std::list<_Buffer*> m_buffers;
307309

308310
int m_buffersize;
309311
int m_size;
@@ -452,7 +454,7 @@ class Table {
452454
std::vector<int> m_text_column_offsets;
453455
};
454456

455-
#define ROW_DUMMY_SIZE 4
457+
#define ROW_DUMMY_SIZE sizeof(void*)
456458

457459
class Row {
458460
public:

src/tcp.cpp

+10-18
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ namespace packetq {
3333
class Stream_id {
3434
public:
3535
/// constructor
36-
Stream_id()
37-
: m_src_port(0)
38-
, m_dst_port(0)
39-
{
40-
memset(&m_src_ip, 0, sizeof(m_src_ip));
41-
memset(&m_dst_ip, 0, sizeof(m_dst_ip));
42-
}
43-
/// constructor taking source and destination adresses
4436
Stream_id(in6addr_t& src_ip,
4537
in6addr_t& dst_ip,
4638
unsigned short src_port,
@@ -55,15 +47,7 @@ class Stream_id {
5547
/// < comparison operator for the std::map
5648
bool operator<(const Stream_id& rhs) const
5749
{
58-
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)
59-
return true;
60-
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)
61-
return true;
62-
if (m_src_port < rhs.m_src_port)
63-
return true;
64-
if (m_dst_port < rhs.m_dst_port)
65-
return true;
66-
return false;
50+
return memcmp(this, &rhs, sizeof(*this)) < 0;
6751
}
6852

6953
private:
@@ -128,6 +112,10 @@ class Stream {
128112
m_nseq = false;
129113
m_seq = 0;
130114
}
115+
~Stream()
116+
{
117+
m_segments.clear();
118+
}
131119
/// add a datasegment to the stream
132120
/** If the segment has the expected sequence number
133121
* the segment will be added to the list
@@ -255,7 +243,11 @@ assemble_tcp(
255243

256244
data = 0;
257245
if (str.has_content()) {
258-
int size = str.get_size();
246+
int size = str.get_size();
247+
if (size < 2) {
248+
// need at least dnslen
249+
return 0;
250+
}
259251
unsigned char* buffer = str.get_buffer();
260252
int dns_size = (int(buffer[0]) << 8) | buffer[1];
261253

0 commit comments

Comments
 (0)