- fix breakegae on 32 bit archs
authorJan Rękorajski <baggins@pld-linux.org>
Sat, 9 May 2020 09:46:27 +0000 (11:46 +0200)
committerJan Rękorajski <baggins@pld-linux.org>
Sat, 9 May 2020 09:46:27 +0000 (11:46 +0200)
logsource.c: substracting signed from unsigned will result in an unsigned
    value that cannot be smaller than 0

test_window_size_counter.c: this test should have NEVER worked,
    window_size_counter always strips highest bit from the value.
    It passed by accident on 64 bit, because the cast was narrowing
    type from long (64 bit) to int (32 bit) (both long and int are 32
    bit on 32 bit archs).

On a side note, the whole syslog-ng code is super brittle. It's mixing
signed and unsigned in arithmetics, mixing differently sized integers
all over the place. It's just an accident waiting to happen.

32bit.patch [new file with mode: 0644]
syslog-ng.spec

diff --git a/32bit.patch b/32bit.patch
new file mode 100644 (file)
index 0000000..359ba3e
--- /dev/null
@@ -0,0 +1,26 @@
+diff -ur syslog-ng-syslog-ng-3.27.1/lib/logsource.c syslog-ng-syslog-ng-3.27.1.32bit/lib/logsource.c
+--- syslog-ng-syslog-ng-3.27.1/lib/logsource.c 2020-04-30 16:18:56.000000000 +0200
++++ syslog-ng-syslog-ng-3.27.1.32bit/lib/logsource.c   2020-05-09 11:36:21.539723717 +0200
+@@ -57,7 +58,7 @@
+       return window_size_increment;
+     }
+-  guint32 remaining_window_size_increment = MAX(window_size_increment - old, 0);
++  guint32 remaining_window_size_increment = MAX((gssize)window_size_increment - old, 0);
+   guint32 reclaimed = window_size_increment - remaining_window_size_increment;
+   atomic_gssize_add(&self->pending_reclaimed, reclaimed);
+diff -ur syslog-ng-syslog-ng-3.27.1/lib/tests/test_window_size_counter.c syslog-ng-syslog-ng-3.27.1.32bit/lib/tests/test_window_size_counter.c
+--- syslog-ng-syslog-ng-3.27.1/lib/tests/test_window_size_counter.c    2020-04-30 16:18:56.000000000 +0200
++++ syslog-ng-syslog-ng-3.27.1.32bit/lib/tests/test_window_size_counter.c      2020-05-09 11:43:12.103043082 +0200
+@@ -59,8 +59,8 @@
+   WindowSizeCounter c;
+   gboolean suspended = FALSE;
+   window_size_counter_set(&c, -1);
+-  gint v = (gint)window_size_counter_get(&c, &suspended);
+-  cr_assert_eq(v, -1);
++  gssize v = (gssize)window_size_counter_get(&c, &suspended);
++  cr_assert_eq(v, G_MAXLONG);
+ }
+ Test(test_window_size_counter, suspend_resume_multiple_times)
index f5d7687e3526b2d5c303bada8fe86488b60d3bfa..7f0677ff64f01ebee9cc579ade8d4b4a08a4773c 100644 (file)
@@ -62,6 +62,7 @@ Patch3:               %{name}-systemd.patch
 Patch4:                man-paths.patch
 Patch5:                %{name}-link.patch
 Patch6:                no_shared_ivykis.patch
+Patch7:                32bit.patch
 URL:           https://syslog-ng.org/
 BuildRequires: autoconf >= 2.59
 BuildRequires: automake
@@ -363,6 +364,7 @@ rmdir lib/ivykis
 %patch4 -p1
 %patch5 -p1
 %patch6 -p1
+%patch7 -p1
 cp -p %{SOURCE4} doc
 cp -p %{SOURCE5} contrib/syslog-ng.conf.simple
 
This page took 0.125704 seconds and 4 git commands to generate.