mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Call initialize instead of check_wuffs_version
This commit is contained in:
1 parent
b41f121d20
commit
53760ce0fd
7 files changed
+34
-18
No files matched your search
@@ -58,8 +58,8 @@ for a C++ compiler $CXX, such as clang++ or g++.
|
|||||||
uint8_t src_buffer[SRC_BUFFER_SIZE];
|
uint8_t src_buffer[SRC_BUFFER_SIZE];
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
wuffs_crc32__ieee_hasher h = ((wuffs_crc32__ieee_hasher){});
|
wuffs_crc32__ieee_hasher h;
|
||||||
const char* status = h.check_wuffs_version(sizeof h, WUFFS_VERSION);
|
const char* status = h.initialize(sizeof h, WUFFS_VERSION, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
fprintf(stderr, "%s\n", status);
|
fprintf(stderr, "%s\n", status);
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -288,9 +288,9 @@ const char* allocate(wuffs_gif__decoder* dec, wuffs_base__image_config* ic) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* play() {
|
const char* play() {
|
||||||
wuffs_gif__decoder dec = ((wuffs_gif__decoder){});
|
wuffs_gif__decoder dec;
|
||||||
wuffs_base__status status =
|
wuffs_base__status status =
|
||||||
wuffs_gif__decoder__check_wuffs_version(&dec, sizeof dec, WUFFS_VERSION);
|
wuffs_gif__decoder__initialize(&dec, sizeof dec, WUFFS_VERSION, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,8 +86,9 @@ static const char* decode() {
|
|||||||
if (!dec) {
|
if (!dec) {
|
||||||
return "out of memory";
|
return "out of memory";
|
||||||
}
|
}
|
||||||
const char* status = wuffs_deflate__decoder__check_wuffs_version(
|
const char* status = wuffs_deflate__decoder__initialize(
|
||||||
dec, sizeof__wuffs_deflate__decoder(), WUFFS_VERSION);
|
dec, sizeof__wuffs_deflate__decoder(), WUFFS_VERSION,
|
||||||
|
WUFFS_INITIALIZE__ALREADY_ZEROED);
|
||||||
if (status) {
|
if (status) {
|
||||||
free(dec);
|
free(dec);
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
+2
-2
@@ -79,9 +79,9 @@ uint8_t work_buffer[WORK_BUFFER_SIZE];
|
|||||||
static void ignore_return_value(int ignored) {}
|
static void ignore_return_value(int ignored) {}
|
||||||
|
|
||||||
static const char* decode() {
|
static const char* decode() {
|
||||||
wuffs_gzip__decoder dec = ((wuffs_gzip__decoder){});
|
wuffs_gzip__decoder dec;
|
||||||
const char* status =
|
const char* status =
|
||||||
wuffs_gzip__decoder__check_wuffs_version(&dec, sizeof dec, WUFFS_VERSION);
|
wuffs_gzip__decoder__initialize(&dec, sizeof dec, WUFFS_VERSION, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,9 +56,11 @@ const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
|||||||
// Use a {} code block so that "goto exit" doesn't trigger "jump bypasses
|
// Use a {} code block so that "goto exit" doesn't trigger "jump bypasses
|
||||||
// variable initialization" warnings.
|
// variable initialization" warnings.
|
||||||
{
|
{
|
||||||
wuffs_gif__decoder dec = ((wuffs_gif__decoder){});
|
wuffs_gif__decoder dec;
|
||||||
const char* status = wuffs_gif__decoder__check_wuffs_version(
|
const char* status = wuffs_gif__decoder__initialize(
|
||||||
&dec, sizeof dec, WUFFS_VERSION);
|
&dec, sizeof dec, WUFFS_VERSION,
|
||||||
|
(hash & 1) ? WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED
|
||||||
|
: 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
ret = status;
|
ret = status;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|||||||
@@ -61,9 +61,10 @@ uint8_t work_buffer[1];
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
||||||
wuffs_zlib__decoder dec = ((wuffs_zlib__decoder){});
|
wuffs_zlib__decoder dec;
|
||||||
const char* status =
|
const char* status = wuffs_zlib__decoder__initialize(
|
||||||
wuffs_zlib__decoder__check_wuffs_version(&dec, sizeof dec, WUFFS_VERSION);
|
&dec, sizeof dec, WUFFS_VERSION,
|
||||||
|
(hash & 1) ? WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED : 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@ const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
|||||||
// Ignore the checksum for 99.99%-ish of all input. When fuzzers generate
|
// Ignore the checksum for 99.99%-ish of all input. When fuzzers generate
|
||||||
// random input, the checkum is very unlikely to match. Still, it's useful to
|
// random input, the checkum is very unlikely to match. Still, it's useful to
|
||||||
// verify that checksumming does not lead to e.g. buffer overflows.
|
// verify that checksumming does not lead to e.g. buffer overflows.
|
||||||
wuffs_zlib__decoder__set_ignore_checksum(&dec, hash & 0xFFFF);
|
wuffs_zlib__decoder__set_ignore_checksum(&dec, hash & 0xFFFE);
|
||||||
|
|
||||||
uint8_t dst_buffer[DST_BUFFER_SIZE];
|
uint8_t dst_buffer[DST_BUFFER_SIZE];
|
||||||
wuffs_base__io_buffer dst = ((wuffs_base__io_buffer){
|
wuffs_base__io_buffer dst = ((wuffs_base__io_buffer){
|
||||||
|
|||||||
@@ -112,6 +112,14 @@ uint8_t idat_buffer[SRC_BUFFER_SIZE] = {0};
|
|||||||
size_t idat_splits[MAX_IDAT_CHUNKS + 1] = {0};
|
size_t idat_splits[MAX_IDAT_CHUNKS + 1] = {0};
|
||||||
uint32_t num_idat_chunks = 0;
|
uint32_t num_idat_chunks = 0;
|
||||||
|
|
||||||
|
#define WORK_BUFFER_SIZE WUFFS_ZLIB__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||||
|
#if WORK_BUFFER_SIZE > 0
|
||||||
|
uint8_t work_buffer[WORK_BUFFER_SIZE];
|
||||||
|
#else
|
||||||
|
// Not all C/C++ compilers support 0-length arrays.
|
||||||
|
uint8_t work_buffer[1];
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t width = 0;
|
uint32_t width = 0;
|
||||||
uint32_t height = 0;
|
uint32_t height = 0;
|
||||||
uint64_t bytes_per_pixel = 0;
|
uint64_t bytes_per_pixel = 0;
|
||||||
@@ -218,9 +226,9 @@ const char* process_png_chunks(uint8_t* p, size_t n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* decode_once(bool frag_dst, bool frag_idat) {
|
const char* decode_once(bool frag_dst, bool frag_idat) {
|
||||||
wuffs_zlib__decoder dec = ((wuffs_zlib__decoder){});
|
wuffs_zlib__decoder dec;
|
||||||
const char* status =
|
const char* status =
|
||||||
wuffs_zlib__decoder__check_wuffs_version(&dec, sizeof dec, WUFFS_VERSION);
|
wuffs_zlib__decoder__initialize(&dec, sizeof dec, WUFFS_VERSION, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -259,7 +267,11 @@ const char* decode_once(bool frag_dst, bool frag_idat) {
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
status =
|
status =
|
||||||
wuffs_zlib__decoder__decode_io_writer(&dec, dst_writer, idat_reader);
|
wuffs_zlib__decoder__decode_io_writer(&dec, dst_writer, idat_reader,
|
||||||
|
((wuffs_base__slice_u8){
|
||||||
|
.ptr = work_buffer,
|
||||||
|
.len = WORK_BUFFER_SIZE,
|
||||||
|
}));
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in new issue
Block a user