Skip to content

Commit daa1c38

Browse files
committed
[binutils] Add libsframe decode fuzzer
Add a new fuzz target for libsframe's sframe_decode() function. This covers SFrame section parsing which was previously unfuzzed. Includes seed corpus with valid V2/V3 headers and edge cases.
1 parent 40b4032 commit daa1c38

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

projects/binutils/build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ for i in fuzz_disassemble fuzz_bfd fuzz_bfd_ext; do
5454
$CXX $CXXFLAGS $i.o -o $OUT/$i $LIB_FUZZING_ENGINE -Wl,--start-group ${LIBS} -Wl,--end-group
5555
done
5656

57+
# Build sframe fuzzer
58+
$CC $CFLAGS -I ../include -I ../libsframe -c fuzz_sframe.c -o fuzz_sframe.o
59+
$CXX $CXXFLAGS fuzz_sframe.o -o $OUT/fuzz_sframe $LIB_FUZZING_ENGINE \
60+
../libsframe/.libs/libsframe.a ../libiberty/libiberty.a
61+
echo "[libfuzzer]" > $OUT/fuzz_sframe.options
62+
echo "detect_leaks=0" >> $OUT/fuzz_sframe.options
63+
5764
# Build targeted disassembly fuzzers
5865
if [ -n "${OSS_FUZZ_CI-}" ]
5966
then

projects/binutils/fuzz_sframe.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Copyright 2026 Google Inc.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
#include <stdint.h>
17+
#include <stdlib.h>
18+
#include "sframe-api.h"
19+
20+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
21+
int err = 0;
22+
sframe_decoder_ctx *dctx;
23+
24+
dctx = sframe_decode((const char *)data, size, &err);
25+
if (dctx != NULL)
26+
sframe_decoder_free(&dctx);
27+
28+
return 0;
29+
}
532 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)