mirror of
https://github.com/libjpeg-turbo/libjpeg-turbo.git
synced 2026-01-18 21:41:20 +01:00
OSS-Fuzz: Test 2-bit through 15-bit data precision
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
struct test {
|
||||
enum TJPF pf;
|
||||
int psv, pt;
|
||||
int precision, psv, pt;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,13 +51,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
int width = 0, height = 0, fd = -1, i, ti;
|
||||
char filename[FILENAME_MAX] = { 0 };
|
||||
struct test tests[NUMTESTS] = {
|
||||
{ TJPF_RGB, 1, 0 },
|
||||
{ TJPF_BGR, 2, 2 },
|
||||
{ TJPF_RGBX, 3, 4 },
|
||||
{ TJPF_BGRA, 4, 7 },
|
||||
{ TJPF_XRGB, 5, 5 },
|
||||
{ TJPF_GRAY, 6, 3 },
|
||||
{ TJPF_CMYK, 7, 0 }
|
||||
{ TJPF_RGB, 12, 1, 0 },
|
||||
{ TJPF_BGR, 11, 2, 2 },
|
||||
{ TJPF_RGBX, 10, 3, 4 },
|
||||
{ TJPF_BGRA, 9, 4, 7 },
|
||||
{ TJPF_XRGB, 12, 5, 5 },
|
||||
{ TJPF_GRAY, 12, 6, 3 },
|
||||
{ TJPF_CMYK, 12, 7, 0 }
|
||||
};
|
||||
#if defined(__has_feature) && __has_feature(memory_sanitizer)
|
||||
char env[18] = "JSIMD_FORCENONE=1";
|
||||
@@ -81,6 +81,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
/* Test non-default compression options on specific iterations. */
|
||||
tj3Set(handle, TJPARAM_BOTTOMUP, ti == 0);
|
||||
tj3Set(handle, TJPARAM_NOREALLOC, ti != 2);
|
||||
tj3Set(handle, TJPARAM_PRECISION, tests[ti].precision);
|
||||
tj3Set(handle, TJPARAM_RESTARTROWS, ti == 0 || ti == 6 ? 1 : 0);
|
||||
|
||||
tj3Set(handle, TJPARAM_MAXPIXELS, 1048576);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
struct test {
|
||||
enum TJPF pf;
|
||||
int psv, pt;
|
||||
int precision, psv, pt;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,13 +51,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
int width = 0, height = 0, fd = -1, i, ti;
|
||||
char filename[FILENAME_MAX] = { 0 };
|
||||
struct test tests[NUMTESTS] = {
|
||||
{ TJPF_RGB, 1, 0 },
|
||||
{ TJPF_BGR, 2, 2 },
|
||||
{ TJPF_RGBX, 3, 4 },
|
||||
{ TJPF_BGRA, 4, 7 },
|
||||
{ TJPF_XRGB, 5, 5 },
|
||||
{ TJPF_GRAY, 6, 3 },
|
||||
{ TJPF_CMYK, 7, 0 }
|
||||
{ TJPF_RGB, 16, 1, 0 },
|
||||
{ TJPF_BGR, 15, 2, 2 },
|
||||
{ TJPF_RGBX, 14, 3, 4 },
|
||||
{ TJPF_BGRA, 13, 4, 7 },
|
||||
{ TJPF_XRGB, 16, 5, 5 },
|
||||
{ TJPF_GRAY, 16, 6, 3 },
|
||||
{ TJPF_CMYK, 16, 7, 0 }
|
||||
};
|
||||
#if defined(__has_feature) && __has_feature(memory_sanitizer)
|
||||
char env[18] = "JSIMD_FORCENONE=1";
|
||||
@@ -81,6 +81,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
/* Test non-default compression options on specific iterations. */
|
||||
tj3Set(handle, TJPARAM_BOTTOMUP, ti == 0);
|
||||
tj3Set(handle, TJPARAM_NOREALLOC, ti != 2);
|
||||
tj3Set(handle, TJPARAM_PRECISION, tests[ti].precision);
|
||||
tj3Set(handle, TJPARAM_RESTARTROWS, ti == 0 || ti == 6 ? 1 : 0);
|
||||
|
||||
tj3Set(handle, TJPARAM_MAXPIXELS, 1048576);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
struct test {
|
||||
enum TJPF pf;
|
||||
int psv, pt;
|
||||
int precision, psv, pt;
|
||||
};
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
int width = 0, height = 0, fd = -1, i, ti;
|
||||
char filename[FILENAME_MAX] = { 0 };
|
||||
struct test tests[NUMTESTS] = {
|
||||
{ TJPF_RGB, 1, 0 },
|
||||
{ TJPF_BGR, 2, 2 },
|
||||
{ TJPF_RGBX, 3, 4 },
|
||||
{ TJPF_BGRA, 4, 7 },
|
||||
{ TJPF_XRGB, 5, 5 },
|
||||
{ TJPF_GRAY, 6, 3 },
|
||||
{ TJPF_CMYK, 7, 0 }
|
||||
{ TJPF_RGB, 8, 1, 0 },
|
||||
{ TJPF_BGR, 7, 2, 5 },
|
||||
{ TJPF_RGBX, 6, 3, 4 },
|
||||
{ TJPF_BGRA, 5, 4, 1 },
|
||||
{ TJPF_XRGB, 4, 5, 3 },
|
||||
{ TJPF_GRAY, 3, 6, 2 },
|
||||
{ TJPF_CMYK, 2, 7, 0 }
|
||||
};
|
||||
#if defined(__has_feature) && __has_feature(memory_sanitizer)
|
||||
char env[18] = "JSIMD_FORCENONE=1";
|
||||
@@ -80,6 +80,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
/* Test non-default compression options on specific iterations. */
|
||||
tj3Set(handle, TJPARAM_BOTTOMUP, ti == 0);
|
||||
tj3Set(handle, TJPARAM_NOREALLOC, ti != 2);
|
||||
tj3Set(handle, TJPARAM_PRECISION, tests[ti].precision);
|
||||
tj3Set(handle, TJPARAM_RESTARTROWS, ti == 0 || ti == 6 ? 1 : 0);
|
||||
|
||||
tj3Set(handle, TJPARAM_MAXPIXELS, 1048576);
|
||||
|
||||
Reference in New Issue
Block a user