1. 01 Oct, 2016 8 commits
    • delta-apply: fix sign extension · cf0396a5
      We compute offsets by executing `off |= (*delta++ << 24)` for
      multiple constants, where `off` is of type `size_t` and `delta`
      is of type `unsigned char`. The usual arithmetic conversions (see
      ISO C89 §3.2.1.5 "Usual arithmetic conversions") kick in here,
      causing us to promote both operands to `int` and then extending
      the result to an `unsigned long` when OR'ing it with `off`.
      The integer promotion to `int` may result in wrong size
      calculations for big values.
      
      Fix the issue by making the constants `unsigned long`, causing both
      operands to be promoted to `unsigned long`.
      Patrick Steinhardt committed
    • odb_loose: fix undefined behavior when computing size · 1fb8a951
      An object's size is computed by reading the object header's size
      field until the most significant bit is not set anymore. To get
      the total size, we increase the shift on each iteration and add
      the shifted value to the total size.
      
      We read the current value into a variable of type `unsigned
      char`, from which we then take all bits except the most
      significant bit and shift the result. We will end up with a
      maximum shift of 60, but this exceeds the width of the value's
      type, resulting in undefined behavior.
      
      Fix the issue by instead reading the values into a variable of
      type `unsigned long`, which matches the required width. This is
      equivalent to git.git, which uses an `unsigned long` as well.
      Patrick Steinhardt committed
    • checkout: set ignorecase=0 when config lookup fails · f627e196
      When `git_repository__cvar` fails we may end up with a
      `ignorecase` value of `-1`. As we subsequently check if
      `ignorecase` is non-zero, we may end up reporting that data
      should be removed when in fact it should not.
      
      Err on the safer side and set `ignorecase = 0` when
      `git_repository__cvar` fails.
      Patrick Steinhardt committed
    • odb: avoid inflating the full delta to read the header · 66633e83
      When we read the header, we want to know the size and type of the
      object. We're currently inflating the full delta in order to read the
      first few bytes. This can mean hundreds of kB needlessly inflated for
      large objects.
      
      Instead use a packfile stream to read just enough so we can read the two
      varints in the header and avoid inflating most of the delta.
      Carlos Martín Nieto committed
    • cmake: include threading libraries in pkg-config · 1aacaa31
      Include any required threading libraries in our `libgit2.pc`.
      Edward Thomson committed
    • Fix return value of openssl_read (infinite loop) · b726c539
      openssl_read should return -1 in case of error.
      
      SSL_read returns values <= 0 in case of error.
      
      A return value of 0 can lead to an infinite loop, so the return value
      of ssl_set_error will be returned if SSL_read is not successful (analog
      to openssl_write).
      Christian Schlack committed
    • tag: ignore extra header fields · 16541b86
      While no extra header fields are defined for tags, git accepts them by
      ignoring them and continuing the search for the message. There are a few
      tags like this in the wild which git parses just fine, so we should do
      the same.
      Carlos Martín Nieto committed
  2. 11 Apr, 2016 32 commits