Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yxml: initial integration #12620

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions projects/yxml/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################

FROM gcr.io/oss-fuzz-base/base-builder
RUN apt-get update && apt-get install -y build-essential autoconf automake libtool

RUN git clone https://github.com/JulStrat/yxml yxml
COPY *_fuzzer.c *.sh $SRC/
WORKDIR $SRC/yxml
28 changes: 28 additions & 0 deletions projects/yxml/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash -eu
#
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################

# Build yxml project
$CC $CFLAGS -I$SRC/yxml -c yxml.c -o yxml.a

# Build fuzzing harness
$CC $CFLAGS -I$SRC/yxml -c $SRC/yxml_fuzzer.c -o yxml_fuzzer.o
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE yxml_fuzzer.o \
-o $OUT/yxml_fuzzer yxml.a

# Create seed corpus
zip -rj $OUT/yxml_fuzzer_seed_corpus.zip $SRC/yxml/test/*.xml
6 changes: 6 additions & 0 deletions projects/yxml/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
homepage: "https://github.com/JulStrat/yxml"
main_repo: "https://github.com/JulStrat/yxml.git"
language: c
vendor_ccs:
- "[email protected]"
- "[email protected]"
37 changes: 37 additions & 0 deletions projects/yxml/yxml_fuzzer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* Copyright 2024 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "yxml.h"

#define BUFFER_SIZE 4096

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// Initialise YXML object
void *buf = malloc(BUFFER_SIZE);
yxml_t xml;
yxml_init(&xml, buf, BUFFER_SIZE);

// Parse fuzzing data with YXML
for (int i = 0; i < size; i++) {
yxml_parse(&xml, data[i]);
}

// Clean object
yxml_eof(&xml);
free(buf);
return 0;
}
Loading