Fix a few C89 issues
This commit is contained in:
parent
1076ec178c
commit
083c8c6801
|
@ -24,10 +24,10 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <assert.h> // assert
|
#include <assert.h> /* assert */
|
||||||
#include <stdint.h> // uint8_t
|
#include <stdint.h> /* uint8_t */
|
||||||
#include <stdlib.h> // malloc, free
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> // memcpy
|
#include <string.h> /* memcpy */
|
||||||
|
|
||||||
#if defined(WITH_LIBICU)
|
#if defined(WITH_LIBICU)
|
||||||
#include <unicode/uclean.h>
|
#include <unicode/uclean.h>
|
||||||
|
@ -39,16 +39,16 @@
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
static int first_run = 1;
|
static int first_run = 1;
|
||||||
|
psl_ctx_t *psl;
|
||||||
char *domain = (char *) malloc(size + 1), *res;
|
char *domain = (char *) malloc(size + 1), *res;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
assert(domain != NULL);
|
assert(domain != NULL);
|
||||||
|
|
||||||
// 0 terminate
|
/* 0 terminate */
|
||||||
memcpy(domain, data, size);
|
memcpy(domain, data, size);
|
||||||
domain[size] = 0;
|
domain[size] = 0;
|
||||||
|
|
||||||
psl_ctx_t *psl;
|
|
||||||
psl = (psl_ctx_t *) psl_builtin();
|
psl = (psl_ctx_t *) psl_builtin();
|
||||||
|
|
||||||
psl_is_public_suffix(psl, domain);
|
psl_is_public_suffix(psl, domain);
|
||||||
|
@ -84,7 +84,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
free(domain);
|
free(domain);
|
||||||
|
|
||||||
#if defined(WITH_LIBICU)
|
#if defined(WITH_LIBICU)
|
||||||
u_cleanup(); // free all library internal memory to avoid memory leaks being reported
|
u_cleanup(); /* free all library internal memory to avoid memory leaks being reported */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -24,16 +24,18 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <assert.h> // assert
|
#include <assert.h> /* assert */
|
||||||
#include <stdint.h> // uint8_t
|
#include <stdint.h> /* uint8_t */
|
||||||
#include <stdlib.h> // malloc, free
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> // memcpy
|
#include <string.h> /* memcpy */
|
||||||
|
|
||||||
#include "libpsl.h"
|
#include "libpsl.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
|
FILE *fp;
|
||||||
|
psl_ctx_t *psl;
|
||||||
char *in = (char *) malloc(size + 16);
|
char *in = (char *) malloc(size + 16);
|
||||||
|
|
||||||
assert(in != NULL);
|
assert(in != NULL);
|
||||||
|
@ -42,10 +44,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
memcpy(in, ".DAFSA@PSL_0 \n", 16);
|
memcpy(in, ".DAFSA@PSL_0 \n", 16);
|
||||||
memcpy(in + 16, data, size);
|
memcpy(in + 16, data, size);
|
||||||
|
|
||||||
FILE *fp = fmemopen(in, size + 16, "r");
|
fp = fmemopen(in, size + 16, "r");
|
||||||
assert(fp != NULL);
|
assert(fp != NULL);
|
||||||
|
|
||||||
psl_ctx_t *psl;
|
|
||||||
psl = psl_load_fp(fp);
|
psl = psl_load_fp(fp);
|
||||||
|
|
||||||
psl_is_public_suffix(NULL, NULL);
|
psl_is_public_suffix(NULL, NULL);
|
||||||
|
|
|
@ -24,20 +24,21 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <assert.h> // assert
|
#include <assert.h> /* assert */
|
||||||
#include <stdint.h> // uint8_t
|
#include <stdint.h> /* uint8_t */
|
||||||
#include <stdlib.h> // malloc, free
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> // memcpy
|
#include <string.h> /* memcpy */
|
||||||
|
|
||||||
#include "libpsl.h"
|
#include "libpsl.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
|
FILE *fp;
|
||||||
psl_ctx_t *psl;
|
psl_ctx_t *psl;
|
||||||
|
|
||||||
FILE *fp = fmemopen((void *)data, size, "r");
|
fp = fmemopen((void *)data, size, "r");
|
||||||
if (!fp && size) // libc6 < 2.22 return NULL when size == 0
|
if (!fp && size) /* libc6 < 2.22 return NULL when size == 0 */
|
||||||
assert(1);
|
assert(1);
|
||||||
|
|
||||||
psl = psl_load_fp(fp);
|
psl = psl_load_fp(fp);
|
||||||
|
|
|
@ -81,6 +81,9 @@ static void test_all_from(const char *dirname)
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
const char *target;
|
||||||
|
char corporadir[sizeof(SRCDIR) + 1 + strlen(argv[0]) + 8];
|
||||||
|
|
||||||
/* if VALGRIND testing is enabled, we have to call ourselves with valgrind checking */
|
/* if VALGRIND testing is enabled, we have to call ourselves with valgrind checking */
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
const char *valgrind = getenv("TESTS_VALGRIND");
|
const char *valgrind = getenv("TESTS_VALGRIND");
|
||||||
|
@ -94,10 +97,9 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *target = strrchr(argv[0], '/');
|
target = strrchr(argv[0], '/');
|
||||||
target = target ? target + 1 : argv[0];
|
target = target ? target + 1 : argv[0];
|
||||||
|
|
||||||
char corporadir[sizeof(SRCDIR) + 1 + strlen(target) + 8];
|
|
||||||
snprintf(corporadir, sizeof(corporadir), SRCDIR "/%s.in", target);
|
snprintf(corporadir, sizeof(corporadir), SRCDIR "/%s.in", target);
|
||||||
|
|
||||||
test_all_from(corporadir);
|
test_all_from(corporadir);
|
||||||
|
@ -130,7 +132,7 @@ int main(int argc, char **argv)
|
||||||
int ret;
|
int ret;
|
||||||
unsigned char buf[64 * 1024];
|
unsigned char buf[64 * 1024];
|
||||||
|
|
||||||
while (__AFL_LOOP(10000)) { // only works with afl-clang-fast
|
while (__AFL_LOOP(10000)) { /* only works with afl-clang-fast */
|
||||||
ret = fread(buf, 1, sizeof(buf), stdin);
|
ret = fread(buf, 1, sizeof(buf), stdin);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue