Skip to content
  • Philip Withnall's avatar
    gvariant: Fix checking arithmetic for tuple element ends · eb7c9adc
    Philip Withnall authored
    
    
    When checking whether a serialised GVariant tuple is in normal form,
    it’s possible for `offset_ptr -= offset_size` to underflow and wrap
    around, resulting in gvs_read_unaligned_le() reading memory outside the
    serialised GVariant bounds.
    
    See §(Tuples) in gvariant-serialiser.c for the documentation on how
    tuples are serialised. Briefly, all variable-length elements in the
    tuple have an offset to their end stored in an array of offsets at the
    end of the tuple. The width of each offset is in offset_size. offset_ptr
    is added to the start of the serialised tuple to get the offset which is
    currently being examined. The offset array is in reverse order compared
    to the tuple elements, hence the subtraction.
    
    The bug can be triggered if a tuple contains a load of variable-length
    elements, each of whose length is actually zero (i.e. empty arrays).
    
    Includes a unit test.
    
    oss-fuzz#9801
    
    Signed-off-by: default avatarPhilip Withnall <withnall@endlessm.com>
    eb7c9adc