Skip to content
Snippets Groups Projects
Forked from APT Developers / apt
Source project has a limited visibility.
  • Julian Andres Klode's avatar
    dc980fb9
    patterns: Safely peek ahead one byte · dc980fb9
    Julian Andres Klode authored
    
    The pattern tree parser was written using string_views in a no-copy
    fashion. However, at various places we assume that we can index one
    byte after the end of the string_view and get a NUL-byte there.
    
    This works fine in practice because we only ever pass it zero-terminated
    string_views, but it fails if you compile with -Wp,-D_GLIBCXX_ASSERTIONS
    because it will do bounds checks.
    
    So instead, do our own bounds checks here and always return '\0'
    if requesting one byte too many.
    
    Reported-by: default avatarChristian Heusel <christian@heusel.eu>
    dc980fb9
    History
    patterns: Safely peek ahead one byte
    Julian Andres Klode authored
    
    The pattern tree parser was written using string_views in a no-copy
    fashion. However, at various places we assume that we can index one
    byte after the end of the string_view and get a NUL-byte there.
    
    This works fine in practice because we only ever pass it zero-terminated
    string_views, but it fails if you compile with -Wp,-D_GLIBCXX_ASSERTIONS
    because it will do bounds checks.
    
    So instead, do our own bounds checks here and always return '\0'
    if requesting one byte too many.
    
    Reported-by: default avatarChristian Heusel <christian@heusel.eu>