[systemd-devel] [PATCH 2/2] journal: get rid of LINE_MAX in sd_journal_printv*()

Harald Hoyer harald.hoyer at gmail.com
Mon Apr 15 13:17:45 PDT 2013


Am 15.04.2013 21:29, schrieb Zbigniew Jędrzejewski-Szmek:
> On Mon, Apr 15, 2013 at 06:41:52PM +0200, harald at redhat.com wrote:
>> From: Harald Hoyer <harald at redhat.com>
>>
>> use stack_size_guess() to get rid of LINE_MAX
>> ---
>>  src/journal/journal-send.c      | 99 +++++++++++++++++++++++++++++++----------
>>  src/journal/test-journal-send.c | 92 +++++++++++++++++++++++++++++++++-----
>>  2 files changed, 156 insertions(+), 35 deletions(-)
>>
>> diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
>> index 4b9109a..2ff04b4 100644
>> --- a/src/journal/journal-send.c
>> +++ b/src/journal/journal-send.c
>> @@ -26,6 +26,7 @@
>>  #include <unistd.h>
>>  #include <fcntl.h>
>>  #include <printf.h>
>> +#include <sys/resource.h>
>>  
>>  #define SD_JOURNAL_SUPPRESS_LOCATION
>>  
>> @@ -35,15 +36,17 @@
>>  
>>  #define SNDBUF_SIZE (8*1024*1024)
>>  
>> -#define ALLOCA_CODE_FUNC(f, func)                 \
>> -        do {                                      \
>> -                size_t _fl;                       \
>> -                const char *_func = (func);       \
>> -                char **_f = &(f);                 \
>> -                _fl = strlen(_func) + 1;          \
>> -                *_f = alloca(_fl + 10);           \
>> -                memcpy(*_f, "CODE_FUNC=", 10);    \
>> -                memcpy(*_f + 10, _func, _fl);     \
>> +#define ALLOCA_CODE_FUNC(f, func)                    \
>> +        do {                                         \
>> +                size_t _fl;                          \
>> +                const char *_func = (func);          \
>> +                char **_f = &(f);                    \
>> +                _fl = strlen(_func) + 1;             \
>> +                if (stack_size_guess() < (_fl + 10)) \
> Can't _fl + 10 overflow (on 32 bit)?

You mean signed vs unsigned?



More information about the systemd-devel mailing list