cagebreak/fuzz/fuzz-parse.c
project-repo d19c32d7a4 Release 2.3.0
Functionality:
  * Add configuration to anchor position of messages (#60, 71 in Bugs.md).
  * Add output priorisation (#38, 68 in Bugs.md).
  * Print whether output is active in dump.

Bug Fixes:
  * Fix gamma control (72 in Bugs.md).
  * Add missing commands to example config.
  * Add message_config to dump output.

Example Scripts:
  * Add screenshot script.
  * Make example scripts standalone.

Documentation:
  * Escape html tags in config man page. (#68, 69 in Bugs.md)
  * Improve README.md (#62, 70 in Bugs.md).
  * Improve SECURITY.md.
  * Add CONTRIBUTING.md (#62, 70 in Bugs.md).
  * FAQ: Add Firefox screenshare instructions for wayland.
  * FAQ: Add wlroots downgrading instructions for workaround in case of temporary wlroots incompatibility.
  * Update copyright notices to 2024.

Development Tooling:
  * Add new gpg keys (signed by the old ones).
  * Add PR template.
  * Add dev-FAQ.
  * Remove now-unnecessary fanalyzer pragmas.
2024-01-26 10:53:03 +00:00

80 lines
2 KiB
C

// Copyright 2020 - 2024, project-repo and the cagebreak contributors
// SPDX-License-Identifier: MIT
#define _POSIX_C_SOURCE 200812L
#include <stdlib.h>
#include <string.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_keyboard_group.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/util/log.h>
#include "../keybinding.h"
#include "../message.h"
#include "../output.h"
#include "../parse.h"
#include "../seat.h"
#include "../server.h"
#include "../view.h"
#include "../workspace.h"
#include "config.h"
#if CG_HAS_XWAYLAND
#include "../xwayland.h"
#endif
#include "fuzz-lib.h"
int
set_configuration(struct cg_server *server, char *content) {
char *line;
while((line = strtok_r(NULL, "\n", &content)) != NULL) {
line[strcspn(line, "\n")] = '\0';
if(*line != '\0' && *line != '#') {
char *errstr = NULL;
server->running = true;
if(parse_rc_line(server, line, &errstr) != 0) {
if(errstr != NULL) {
free(errstr);
}
return -1;
}
}
}
return 0;
}
int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if(size == 0) {
return 0;
}
char *str = malloc(sizeof(char) * size);
strncpy(str, (char *)data, size);
str[size - 1] = 0;
set_configuration(&server, str);
free(str);
keybinding_list_free(server.keybindings);
server.keybindings = keybinding_list_init();
run_action(KEYBINDING_WORKSPACES, &server,
(union keybinding_params){.i = 1});
run_action(KEYBINDING_LAYOUT_FULLSCREEN, &server,
(union keybinding_params){.c = NULL});
struct cg_output *output;
wl_list_for_each(output, &server.outputs, link) { message_clear(output); }
for(unsigned int i = 3; server.modes[i] != NULL; ++i) {
free(server.modes[i]);
}
server.modes[3] = NULL;
server.modes = realloc(server.modes, 4 * sizeof(char *));
struct cg_output_config *output_config, *output_config_tmp;
wl_list_for_each_safe(output_config, output_config_tmp,
&server.output_config, link) {
wl_list_remove(&output_config->link);
free(output_config->output_name);
free(output_config);
}
return 0;
}