chiark / gitweb /
journalctl: Allow to disable line cap with --lines=all
[elogind.git] / src / journal / sd-journal.c
index 01c91e4c02780f1148fd5d9cc784a411a667998f..693707cb347a817da8f2a416e29ba5dfe6d30aa2 100644 (file)
@@ -2004,7 +2004,7 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
                                                   &f->compress_buffer, &f->compress_buffer_size,
                                                   field, field_length, '=')) {
 
-                                uint64_t rsize;
+                                size_t rsize;
 
                                 r = decompress_blob(compression,
                                                     o->data.payload, l,
@@ -2059,7 +2059,7 @@ static int return_data(sd_journal *j, JournalFile *f, Object *o, const void **da
         compression = o->object.flags & OBJECT_COMPRESSION_MASK;
         if (compression) {
 #if defined(HAVE_XZ) || defined(HAVE_LZ4)
-                uint64_t rsize;
+                size_t rsize;
                 int r;
 
                 r = decompress_blob(compression,
@@ -2557,7 +2557,7 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
 
                 /* Let's do the type check by hand, since we used 0 context above. */
                 if (o->object.type != OBJECT_DATA) {
-                        log_error("%s:offset " OFSfmt ": object has type %d, expected %d",
+                        log_debug("%s:offset " OFSfmt ": object has type %d, expected %d",
                                   j->unique_file->path, j->unique_offset,
                                   o->object.type, OBJECT_DATA);
                         return -EBADMSG;
@@ -2571,6 +2571,21 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
                 if (r < 0)
                         return r;
 
+                /* Check if we have at least the field name and "=". */
+                if (ol <= k) {
+                        log_debug("%s:offset " OFSfmt ": object has size %zu, expected at least %zu",
+                                  j->unique_file->path, j->unique_offset,
+                                  ol, k + 1);
+                        return -EBADMSG;
+                }
+
+                if (memcmp(odata, j->unique_field, k) || ((const char*) odata)[k] != '=') {
+                        log_debug("%s:offset " OFSfmt ": object does not start with \"%s=\"",
+                                  j->unique_file->path, j->unique_offset,
+                                  j->unique_field);
+                        return -EBADMSG;
+                }
+
                 /* OK, now let's see if we already returned this data
                  * object by checking if it exists in the earlier
                  * traversed files. */