1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 21:36:37 +02:00
Files
weechat/tests/fuzz/core/calc-fuzzer.cc
2025-05-07 21:15:51 +02:00

48 lines
1.2 KiB
C++

/*
* SPDX-FileCopyrightText: 2025 Sébastien Helleu <flashcode@flashtux.org>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
*/
/* Fuzz testing on WeeChat core calc functions */
extern "C"
{
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include "src/core/core-calc.h"
}
extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
{
char *str;
str = (char *)malloc (size + 1);
memcpy (str, data, size);
str[size] = '\0';
free (calc_expression (str));
free (str);
return 0;
}