summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2021-11-17 17:44:21 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2021-11-18 22:43:17 +0100
commit847c7ee8c3c1a6cecd02501562b1afd8dd3c51de (patch)
treeb1667a8e0fdf3239ee71eb44aad6d4eefdd2acb8 /src
parentjournal: Skip over corrupt entry items in enumerate_data() (diff)
downloadsystemd-847c7ee8c3c1a6cecd02501562b1afd8dd3c51de.tar.xz
systemd-847c7ee8c3c1a6cecd02501562b1afd8dd3c51de.zip
journal: Use separate variable for Data object in sd_journal_get_data()
A little cleanup to make the next change easier. We're not moving to a new Entry object in the for loop so there's no danger of changing the Entry object window.
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-journal/sd-journal.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index 8089f2bcc9..e440d3c560 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -2297,6 +2297,7 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
n = journal_file_entry_n_items(o);
for (i = 0; i < n; i++) {
+ Object *d;
uint64_t p, l;
le64_t le_hash;
size_t t;
@@ -2304,20 +2305,20 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
p = le64toh(o->entry.items[i].object_offset);
le_hash = o->entry.items[i].hash;
- r = journal_file_move_to_object(f, OBJECT_DATA, p, &o);
+ r = journal_file_move_to_object(f, OBJECT_DATA, p, &d);
if (r < 0)
return r;
- if (le_hash != o->data.hash)
+ if (le_hash != d->data.hash)
return -EBADMSG;
- l = le64toh(o->object.size) - offsetof(Object, data.payload);
+ l = le64toh(d->object.size) - offsetof(Object, data.payload);
- compression = o->object.flags & OBJECT_COMPRESSION_MASK;
+ compression = d->object.flags & OBJECT_COMPRESSION_MASK;
if (compression) {
#if HAVE_COMPRESSION
r = decompress_startswith(compression,
- o->data.payload, l,
+ d->data.payload, l,
&f->compress_buffer,
field, field_length, '=');
if (r < 0)
@@ -2328,7 +2329,7 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
size_t rsize;
r = decompress_blob(compression,
- o->data.payload, l,
+ d->data.payload, l,
&f->compress_buffer, &rsize,
j->data_threshold);
if (r < 0)
@@ -2343,23 +2344,19 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
return -EPROTONOSUPPORT;
#endif
} else if (l >= field_length+1 &&
- memcmp(o->data.payload, field, field_length) == 0 &&
- o->data.payload[field_length] == '=') {
+ memcmp(d->data.payload, field, field_length) == 0 &&
+ d->data.payload[field_length] == '=') {
t = (size_t) l;
if ((uint64_t) t != l)
return -E2BIG;
- *data = o->data.payload;
+ *data = d->data.payload;
*size = t;
return 0;
}
-
- r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
- if (r < 0)
- return r;
}
return -ENOENT;