[systemd-commits] 2 commits - src/journal src/shared
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Sep 24 14:42:38 PDT 2012
src/journal/journal-send.c | 9 ++++++++-
src/shared/macro.h | 6 ++++--
2 files changed, 12 insertions(+), 3 deletions(-)
New commits:
commit cecd32f648cdf315ee19c0cf7c8c7cb9fb5d6ee6
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Sep 24 23:42:29 2012 +0200
macro: increase VA_FORMAT_ADVANCE type array and hit assert when it is reached
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 0dd210a..dbdf5b3 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -193,10 +193,12 @@ static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
#define _cleanup_closedir_ __attribute__((cleanup(closedirp)))
#define _cleanup_umask_ __attribute__((cleanup(umaskp)))
-#define VA_FORMAT_ADVANCE(format, ap) do { \
- int _argtypes[64]; \
+#define VA_FORMAT_ADVANCE(format, ap) \
+do { \
+ int _argtypes[128]; \
size_t _i, _k; \
_k = parse_printf_format((format), ELEMENTSOF(_argtypes), _argtypes); \
+ assert(_k < ELEMENTSOF(_argtypes)); \
for (_i = 0; _i < _k; _i++) { \
if (_argtypes[_i] & PA_FLAG_PTR) { \
(void) va_arg(ap, void*); \
commit 72f1d5a2880d103dc1c1746f5c02e192e054705e
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Sep 24 23:42:03 2012 +0200
journal: also use new VA_FORMAT_ADVANCE() macro in sd_journal_send()
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index b192f1f..d503f3f 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -25,6 +25,7 @@
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
+#include <printf.h>
#define SD_JOURNAL_SUPPRESS_LOCATION
@@ -121,6 +122,7 @@ static int fill_iovec_sprintf(const char *format, va_list ap, int extra, struct
while (format) {
struct iovec *c;
char *buffer;
+ va_list aq;
if (i >= n) {
n = MAX(i*2, 4);
@@ -133,10 +135,15 @@ static int fill_iovec_sprintf(const char *format, va_list ap, int extra, struct
iov = c;
}
- if (vasprintf(&buffer, format, ap) < 0) {
+ va_copy(aq, ap);
+ if (vasprintf(&buffer, format, aq) < 0) {
+ va_end(aq);
r = -ENOMEM;
goto fail;
}
+ va_end(aq);
+
+ VA_FORMAT_ADVANCE(format, ap);
IOVEC_SET_STRING(iov[i++], buffer);
More information about the systemd-commits
mailing list