Esempio n. 1
0
static SquashStatus
squash_brieflz_decompress_buffer (SquashCodec* codec,
                                  size_t* decompressed_size,
                                  uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)],
                                  size_t compressed_size,
                                  const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)],
                                  SquashOptions* options) {
    const uint8_t *src = compressed;
    unsigned long size;

#if ULONG_MAX < SIZE_MAX
    if (HEDLEY_UNLIKELY(ULONG_MAX < compressed_size) ||
            HEDLEY_UNLIKELY(ULONG_MAX < *decompressed_size))
        return squash_error (SQUASH_RANGE);
#endif

    size = blz_depack_safe (src, (unsigned long) compressed_size,
                            decompressed, (unsigned long) *decompressed_size);

    if (HEDLEY_UNLIKELY(size != *decompressed_size))
        return squash_error (SQUASH_FAILED);

#if SIZE_MAX < ULONG_MAX
    if (HEDLEY_UNLIKELY(SIZE_MAX < size))
        return squash_error (SQUASH_RANGE);
#endif

    *decompressed_size = (size_t) size;

    return SQUASH_OK;
}
Esempio n. 2
0
static SquashStatus
squash_brieflz_decompress_buffer (SquashCodec* codec,
                                  size_t* decompressed_size,
                                  uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)],
                                  size_t compressed_size,
                                  const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)],
                                  SquashOptions* options) {
  const uint8_t *src = compressed;
  uint64_t original_size;
  size_t size;

  size = read_varuint64 (src, compressed_size, &original_size);

  if (SQUASH_UNLIKELY(size == 0)) {
    return squash_error (SQUASH_FAILED);
  }

  src += size;
  compressed_size -= size;

  if (SQUASH_UNLIKELY(original_size > *decompressed_size)) {
    return squash_error (SQUASH_BUFFER_FULL);
  }

#if ULONG_MAX < SIZE_MAX
  if (SQUASH_UNLIKELY(ULONG_MAX < compressed_size) ||
      SQUASH_UNLIKELY(ULONG_MAX < original_size))
    return squash_error (SQUASH_RANGE);
#endif

  size = blz_depack_safe (src, (unsigned long) compressed_size,
                          decompressed, (unsigned long) original_size);

  if (SQUASH_UNLIKELY(size != original_size)) {
    return squash_error (SQUASH_FAILED);
  }

#if SIZE_MAX < ULONG_MAX
  if (SQUASH_UNLIKELY(SIZE_MAX < size))
    return squash_error (SQUASH_RANGE);
#endif

  *decompressed_size = size;

  return SQUASH_OK;
}
Esempio n. 3
0
int64_t lzbench_brieflz_decompress(char *inbuf, size_t insize, char *outbuf, size_t outsize, size_t, size_t, char*)
{
    return blz_depack_safe(inbuf, insize, outbuf, outsize);
}