const void *data, uint64_t size,
Object **ret, uint64_t *ret_offset) {
- uint64_t hash, p;
- uint64_t osize;
- Object *o;
+ uint64_t hash, p, fp, osize;
+ Object *o, *fo;
int r, compression = 0;
const void *eq;
assert(f);
- assert(data || size == 0);
+
+ if (!data || size == 0)
+ return -EINVAL;
hash = journal_file_hash_data(f, data, size);
return 0;
}
+ eq = memchr(data, '=', size);
+ if (!eq)
+ return -EINVAL;
+
osize = offsetof(Object, data.payload) + size;
r = journal_file_append_object(f, OBJECT_DATA, osize, &o, &p);
if (r < 0)
if (r < 0)
return r;
- if (!data)
- eq = NULL;
- else
- eq = memchr(data, '=', size);
- if (eq && eq > data) {
- Object *fo = NULL;
- uint64_t fp;
-
- /* Create field object ... */
- r = journal_file_append_field(f, data, (uint8_t*) eq - (uint8_t*) data, &fo, &fp);
- if (r < 0)
- return r;
+ /* Create field object ... */
+ r = journal_file_append_field(f, data, (uint8_t*) eq - (uint8_t*) data, &fo, &fp);
+ if (r < 0)
+ return r;
- /* ... and link it in. */
- o->data.next_field_offset = fo->field.head_data_offset;
- fo->field.head_data_offset = le64toh(p);
- }
+ /* ... and link it in. */
+ o->data.next_field_offset = fo->field.head_data_offset;
+ fo->field.head_data_offset = le64toh(p);
if (ret)
*ret = o;
assert(f);
assert(f->header);
- assert(iovec || n_iovec == 0);
+ assert(iovec && n_iovec > 0);
if (ts) {
if (!VALID_REALTIME(ts->realtime))
} else
data = o->data.payload;
+ if (l == 0)
+ return -EBADMSG;
+
r = journal_file_append_data(to, data, l, &u, &h);
if (r < 0)
return r;
return r;
}
- r = journal_file_append_entry_internal(to, &ts, boot_id, xor_hash, items, n,
- NULL, NULL, NULL);
+ r = journal_file_append_entry_internal(to, &ts, boot_id, xor_hash, items, n, NULL, NULL, NULL);
if (mmap_cache_fd_got_sigbus(to->cache_fd))
return -EIO;