|
Zbigniew Jędrzejewski-Szmek |
126222 |
From a25fd0d4bd3cf652e55c24e7dc873fe530fa111a Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
Date: Mon, 16 Dec 2013 23:35:30 +0100
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
Subject: [PATCH] journal-file: protect against alloca(0)
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
src/journal/journal-file.c | 3 ++-
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
index 090cf97..8ea258b 100644
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
--- a/src/journal/journal-file.c
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+++ b/src/journal/journal-file.c
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
@@ -2737,7 +2737,8 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
ts.realtime = le64toh(o->entry.realtime);
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
n = journal_file_entry_n_items(o);
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
- items = alloca(sizeof(EntryItem) * n);
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+ /* alloca() can't take 0, hence let's allocate at least one */
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+ items = alloca(sizeof(EntryItem) * MAX(1u, n));
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
for (i = 0; i < n; i++) {
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
uint64_t l, h;
|