Skip to content
Snippets Groups Projects
Commit e0af7644 authored by Wilhelm Bjoland's avatar Wilhelm Bjoland
Browse files

La til halla og fuzztarget filer

parent 44f4ca57
No related branches found
No related tags found
No related merge requests found
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "halla.c"
// fuzz_target.cc
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// Create a c string from fuzzer data (with an additional byte set to '\0')
char *str = (char *)malloc(sizeof(char) * size + 1); // Create a c-string of length size + 1
memcpy(str, data, size); // Copy fuzzer data to string
str[size] = '\0'; // Set last byte of allocated string to '\0'
char *test = checkChar(str);
free(test);
free(str);
return 0;
}
//clang -g -O1 -fsanitize=fuzzer,address c.c -o c
//clang -g -fsanitize=fuzzer first-cap.c -o fuzz-first-cap
halla.c 0 → 100644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
char *checkChar(char str[50]) {
int i;
char *newstr;
newstr = (char *)calloc(200,1);
for (i = 0; i < strlen(str); i++) {
if (str[i] == '&') {
const char *ch = "&amp";
strncat(newstr, ch, 4);
} else if (str[i] == '<') {
const char *ch = "&lt";
strncat(newstr, ch, 3);
} else if (str[i] == '>') {
const char *ch = "&gt";
strncat(newstr, ch, 3);
} else {
const char ch = str[i];
strncat(newstr, &ch, 1);
}
}
return newstr;
}
/*
int main() {
char str[200];
printf("Enter the string you want to convert: \n");
fgets(str, 200, stdin);
char *string = checkChar(str);
printf("After replacement:\n%s", string);
return 0;
}*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment