diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-10-14 04:52:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-10-14 04:52:56 +0200 |
commit | 161e54f8719c4a11440d762276cbccbeb1736f8c (patch) | |
tree | 3d3fbc8203cb097038b3ca133f012fadab33e5d4 | |
parent | 3fbf9cbb02690e40cd65802e777519f3f3c8d88a (diff) |
journal: fix field retrieval by name
-rw-r--r-- | src/journal/sd-journal.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 6f47520217..1f4ad0ff64 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -493,22 +493,24 @@ int sd_journal_get_field(sd_journal *j, const char *field, const void **data, si l = le64toh(o->object.size) - offsetof(Object, data.payload); - if (field_length+1 > l) - continue; + if (l >= field_length+1 && + memcmp(o->data.payload, field, field_length) == 0 && + o->data.payload[field_length] == '=') { - if (memcmp(o->data.payload, field, field_length) || - o->data.payload[field_length] != '=') - continue; + t = (size_t) l; - t = (size_t) l; + if ((uint64_t) t != l) + return -E2BIG; - if ((uint64_t) t != l) - return -E2BIG; + *data = o->data.payload; + *size = t; - *data = o->data.payload; - *size = t; + return 1; + } - return 1; + r = journal_file_move_to_object(f, f->current_offset, OBJECT_ENTRY, &o); + if (r < 0) + return r; } return 0; |