From: Thomas Hindoe Paaboel Andersen Date: Mon, 16 Dec 2013 22:35:30 +0000 (+0100) Subject: journal-file: protect against alloca(0) X-Git-Tag: v209~886 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=4faa70046ca0c1775c8e231179716a78cf3291b1 journal-file: protect against alloca(0) --- diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 4009b29b4..48fdb6163 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -2730,7 +2730,8 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6 ts.realtime = le64toh(o->entry.realtime); n = journal_file_entry_n_items(o); - items = alloca(sizeof(EntryItem) * n); + /* alloca() can't take 0, hence let's allocate at least one */ + items = alloca(sizeof(EntryItem) * MAX(1u, n)); for (i = 0; i < n; i++) { uint64_t l, h;