Skip to content
Snippets Groups Projects
Select Git revision
  • 0e2d57fd50f61e668be3180bc8f25991ea88aa8c
  • passt default
  • master
  • pu
  • todo
  • next
  • maint
  • v2.8.0-rc1
  • v2.8.0-rc0
  • v2.7.2
  • v2.7.1
  • v2.7.0
  • v2.6.5
  • v2.7.0-rc3
  • v2.7.0-rc2
  • v2.7.0-rc1
  • v2.7.0-rc0
  • v2.6.4
  • v2.6.3
  • v2.6.2
  • v2.6.1
  • v2.3.10
  • v2.5.4
  • v2.4.10
  • v2.6.0
  • v2.6.0-rc3
  • v2.5.3
27 results

diff-delta.c

Blame
    • Nicolas Pitre's avatar
      506049c7
      fix >4GiB source delta assertion failure · 506049c7
      Nicolas Pitre authored
      
      When people try insane things such as delta-compressing 4GiB files, they
      get this assertion:
      
      diff-delta.c:285: create_delta_index: Assertion `packed_entry - (struct index_entry *)mem == entries' failed.
      
      This happens because:
      
      1) the 'entries' variable is an unsigned int
      
      2) it is assigned with entries = (bufsize - 1) / RABIN_WINDOW
         (that itself is not a problem unless bufsize > 4G * RABIN_WINDOW)
      
      3) the buffer is indexed from top to bottom starting at
         "data = buffer + entries * RABIN_WINDOW" and the multiplication
         here does indeed overflows, making the resulting top of the buffer
         much lower than expected.
      
      This makes the number of actually produced index entries smaller than
      what was computed initially, hence the assertion.
      
      Furthermore, the current delta encoding format cannot represent offsets
      into a reference buffer with more than 32 bits anyway.  So let's just
      limit the number of entries to what the delta format can encode.
      
      Reported-by: default avatarIlari Liusvaara <ilari.liusvaara@elisanet.fi>
      Signed-off-by: default avatarNicolas Pitre <nico@fluxnic.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      506049c7
      History
      fix >4GiB source delta assertion failure
      Nicolas Pitre authored
      
      When people try insane things such as delta-compressing 4GiB files, they
      get this assertion:
      
      diff-delta.c:285: create_delta_index: Assertion `packed_entry - (struct index_entry *)mem == entries' failed.
      
      This happens because:
      
      1) the 'entries' variable is an unsigned int
      
      2) it is assigned with entries = (bufsize - 1) / RABIN_WINDOW
         (that itself is not a problem unless bufsize > 4G * RABIN_WINDOW)
      
      3) the buffer is indexed from top to bottom starting at
         "data = buffer + entries * RABIN_WINDOW" and the multiplication
         here does indeed overflows, making the resulting top of the buffer
         much lower than expected.
      
      This makes the number of actually produced index entries smaller than
      what was computed initially, hence the assertion.
      
      Furthermore, the current delta encoding format cannot represent offsets
      into a reference buffer with more than 32 bits anyway.  So let's just
      limit the number of entries to what the delta format can encode.
      
      Reported-by: default avatarIlari Liusvaara <ilari.liusvaara@elisanet.fi>
      Signed-off-by: default avatarNicolas Pitre <nico@fluxnic.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    diff-delta.c 15.45 KiB