mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(norm): remove fuzz code
This commit is contained in:
parent
b7e48cca05
commit
313bef63fd
2 changed files with 0 additions and 87 deletions
39
src/fuzz.c
39
src/fuzz.c
|
|
@ -1,39 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* fuzz.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2025/04/30 16:01:18 by kcolin #+# #+# */
|
|
||||||
/* Updated: 2025/04/30 17:13:17 by kcolin ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "fcntl.h"
|
|
||||||
#include "minishell.h"
|
|
||||||
#include "parser/cmd/cmd_destroy.h"
|
|
||||||
#include "parser/cmd_parsing.h"
|
|
||||||
#include "unistd.h"
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
||||||
t_minishell app;
|
|
||||||
bzero(&app, sizeof(t_minishell));
|
|
||||||
int null = open("/dev/null", O_RDONLY, 0);
|
|
||||||
|
|
||||||
char *line = (char *)calloc(size + 1, sizeof(char));
|
|
||||||
memcpy(line, data, size);
|
|
||||||
|
|
||||||
dup2(null, STDIN_FILENO);
|
|
||||||
close(null);
|
|
||||||
t_cmd *cmd = minishell_parse(&app, line);
|
|
||||||
|
|
||||||
cmd_destroy(cmd);
|
|
||||||
free(line);
|
|
||||||
|
|
||||||
return (0); // Values other than 0 and -1 are reserved for future use.
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* fuzz_hand_tester.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2025/04/30 17:30:53 by kcolin #+# #+# */
|
|
||||||
/* Updated: 2025/04/30 17:36:33 by kcolin ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "fcntl.h"
|
|
||||||
#include "minishell.h"
|
|
||||||
#include "parser/cmd/cmd_destroy.h"
|
|
||||||
#include "parser/cmd_parsing.h"
|
|
||||||
#include "unistd.h"
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
t_minishell app;
|
|
||||||
bzero(&app, sizeof(t_minishell));
|
|
||||||
int null = open("/dev/null", O_RDONLY, 0);
|
|
||||||
|
|
||||||
if (argc != 2)
|
|
||||||
return (1);
|
|
||||||
FILE *in = fopen(argv[1], "rb");
|
|
||||||
fseek(in, 0, SEEK_END);
|
|
||||||
long fsize = ftell(in);
|
|
||||||
fseek(in, 0, SEEK_SET); /* same as rewind(f); */
|
|
||||||
char *line = malloc(fsize + 1);
|
|
||||||
fread(line, fsize, 1, in);
|
|
||||||
fclose(in);
|
|
||||||
line[fsize] = 0;
|
|
||||||
|
|
||||||
|
|
||||||
dup2(null, STDIN_FILENO);
|
|
||||||
close(null);
|
|
||||||
t_cmd *cmd = minishell_parse(&app, line);
|
|
||||||
|
|
||||||
cmd_destroy(cmd);
|
|
||||||
free(line);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue