Format C code (#1621)

* Add iter() to owned slice

* Format C
This commit is contained in:
Andrea Fioraldi 2023-10-11 14:19:14 +02:00 committed by GitHub
parent 6986317a03
commit 35e387773c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 10 deletions

View File

@ -16,22 +16,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t i) {
if (*icmp != 0x69694141) return 0; if (*icmp != 0x69694141) return 0;
if (memcmp(buf + 8, "1234EF", 6) == 0) abort(); if (memcmp(buf + 8, "1234EF", 6) == 0) abort();
return 0; return 0;
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
unsigned char buf[1024]; unsigned char buf[1024];
ssize_t i; ssize_t i;
while (__AFL_LOOP(1000)) { while (__AFL_LOOP(1000)) {
i = read(0, (char *)buf, sizeof(buf) - 1); i = read(0, (char *)buf, sizeof(buf) - 1);
if (i > 0) buf[i] = 0; if (i > 0) buf[i] = 0;
LLVMFuzzerTestOneInput(buf, i); LLVMFuzzerTestOneInput(buf, i);
} }
return 0; return 0;
} }

View File

@ -1,11 +1,14 @@
int __attribute__ ((noinline)) BREAKPOINT() { int __attribute__((noinline)) BREAKPOINT() {
for (;;) {} for (;;) {}
} }
int LLVMFuzzerTestOneInput(unsigned int *Data, unsigned int Size) { int LLVMFuzzerTestOneInput(unsigned int *Data, unsigned int Size) {
if (Data[3] == 0) {while(1){}} // cause a timeout if (Data[3] == 0) {
while (1) {}
} // cause a timeout
for (int i = 0; i < Size; i++) { for (int i = 0; i < Size; i++) {
// if (Data[i] > 0xFFd0 && Data[i] < 0xFFFF) {return 1;} // cause qemu to crash // if (Data[i] > 0xFFd0 && Data[i] < 0xFFFF) {return 1;} // cause qemu to
// crash
for (int j = i + 1; j < Size; j++) { for (int j = i + 1; j < Size; j++) {
if (Data[j] == 0) { continue; } if (Data[j] == 0) { continue; }
if (Data[j] > Data[i]) { if (Data[j] > Data[i]) {