Skip to content
Snippets Groups Projects
Commit 75afcb76 authored by Pernille Kopperud's avatar Pernille Kopperud
Browse files

:)

parent 345a7bba
No related branches found
No related tags found
No related merge requests found
Pipeline #85076 failed
image: archlinux:latest
fuzzertest:
script:
- pacman -Syu --noconfirm make clang cmake
- mkdir build
- cd build
- CC=clang cmake ..
- make
- ./tests/utility_fuzzer_test -max_total_time=60
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
#include <stdlib.h> #include <stdlib.h>
int main() { int main() {
char test[] = "hei&der<borte>!"; const char *test = "hei&der<borte>!";
size_t size = strlen(test); size_t size = strlen(test);
printf("%s\n", combineStrings(test, size)); const char *res = combineStrings(test, size);
printf("%s\n", res);
free(res);
return 0; return 0;
} }
\ No newline at end of file
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include <stdint.h> #include <stdint.h>
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
combineStrings((const char *)data, size); free(combineStrings((const char *)data, size));
return 0; return 0;
} }
\ No newline at end of file
...@@ -2,33 +2,38 @@ ...@@ -2,33 +2,38 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
const char* combineStrings(char *msg, size_t size){ const char* combineStrings(const char *msg, size_t size){
int i; int i;
char* temp; char* temp;
size_t counter = 1;
temp = malloc(size*5+1); temp = malloc(size*5+1);
temp[0] = '\0';
for (i = 0; i < size; ++i) for (i = 0; i < size; ++i)
{ {
if(msg[i] == '&') if(msg[i] == '&')
{ {
strcat(temp, "&amp;"); strcat(temp, "&amp;");
counter += 5;
} }
else if(msg[i] == '>') else if(msg[i] == '>')
{ {
strcat(temp,"&gt;"); strcat(temp,"&gt;");
counter += 4;
} }
else if(msg[i] == '<') else if(msg[i] == '<')
{ {
strcat(temp,"&lt;"); strcat(temp,"&lt;");
counter += 4;
} }
else else
{ {
strncat(temp,&msg[i],1); strncat(temp,&msg[i],1);
counter += 1;
} }
} }
return temp;
temp = realloc(temp, counter);
return temp;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment