chiark / gitweb /
journal: fix off-by-one error in native message iovec counting
authorMichal Schmidt <mschmidt@redhat.com>
Tue, 16 Apr 2013 21:07:14 +0000 (23:07 +0200)
committerMichal Schmidt <mschmidt@redhat.com>
Tue, 16 Apr 2013 21:07:14 +0000 (23:07 +0200)
Thanks to Cristian Ciupitu for a reproducer.
https://bugzilla.redhat.com/show_bug.cgi?id=924359

src/journal/journald-native.c

index 9d1f39f0c5e855ab999018d95781db4f07381686..f878dfc911a719a0501f961264a2e9b228f5d905 100644 (file)
@@ -123,11 +123,12 @@ void server_process_native_message(
 
                 /* A property follows */
 
-                if (n+N_IOVEC_META_FIELDS >= m) {
+                /* n received properties, +1 for _TRANSPORT */
+                if (n + 1 + N_IOVEC_META_FIELDS >= m) {
                         struct iovec *c;
                         unsigned u;
 
-                        u = MAX((n+N_IOVEC_META_FIELDS+1) * 2U, 4U);
+                        u = MAX((n + 1 + N_IOVEC_META_FIELDS) * 2U, 4U);
                         c = realloc(iovec, u * sizeof(struct iovec));
                         if (!c) {
                                 log_oom();