[systemd-devel] [PATCH 1/2] journal: assume that next entry is after previous entry

Lennart Poettering lennart at poettering.net
Tue Mar 4 12:22:52 PST 2014


On Thu, 27.02.14 00:57, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

>  
>          /* And jump to it */
> -        return generic_array_get(f,
> -                                 le64toh(f->header->entry_array_offset),
> -                                 i,
> -                                 ret, offset);
> +        r = generic_array_get(f,
> +                              le64toh(f->header->entry_array_offset),
> +                              i,
> +                              ret, offset);
> +        if (r <= 0)
> +                return r;
> +
> +        if (p > 0 &&
> +            (direction == DIRECTION_DOWN ? *offset <= p : *offset >= p)) {
> +                log_debug("%s: entry array corrupted at entry %"PRIu64,
> +                          f->path, i);
> +                return -EBADMSG;
> +        }
> +
> +        return 1;
>  }
>  
>  int journal_file_skip_entry(

Looks good, but I really don't like that it clobbers *offset even when
it fails. Feel free to commit with some temporary variable added we read
this into first...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list