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

heimdal: initial integration #10678

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 23 additions & 0 deletions projects/heimdal/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2023 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 \
make flex bison libtool automake autoconf libncurses5-dev texinfo

RUN git clone --depth 1 https://github.com/heimdal/heimdal
WORKDIR $SRC/heimdal
COPY build.sh *.c *.options $SRC/
35 changes: 35 additions & 0 deletions projects/heimdal/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash -eu
#
# Copyright 2023 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.
#
################################################################################

export ASAN_OPTIONS="detect_leaks=0"
autoreconf -fi
./configure --enable-shared=no --enable-static=yes --disable-otp
make V=1 -j$(nproc)

$CC $CFLAGS -Iinclude/ -c $SRC/fuzz_json.c -o fuzz_json.o
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz_json.o -o $OUT/fuzz_json \
-pthread ./lib/gssapi/.libs/libgssapi.a /src/heimdal/lib/ntlm/.libs/libheimntlm.a \
-L/lib /src/heimdal/lib/krb5/.libs/libkrb5.a ./lib/krb5/.libs/libkrb5.a \
/src/heimdal/lib/hx509/.libs/libhx509.a /src/heimdal/lib/wind/.libs/libwind.a \
/src/heimdal/lib/sqlite/.libs/libheimsqlite.a /src/heimdal/lib/hcrypto/.libs/libhcrypto.a \
./lib/hcrypto/.libs/libhcrypto.a /src/heimdal/lib/asn1/.libs/libasn1.a \
/src/heimdal/lib/base/.libs/libheimbase.a -lcrypto ./lib/asn1/.libs/libasn1.a \
/src/heimdal/lib/com_err/.libs/libcom_err.a /src/heimdal/lib/roken/.libs/libroken.a \
./lib/vers/.libs/libvers.a ./lib/roken/.libs/libroken.a -lresolv -lpthread -pthread

cp $SRC/*.options $OUT/
45 changes: 45 additions & 0 deletions projects/heimdal/fuzz_json.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Copyright 2023 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 <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include "heimbase.h"

int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
char *null_terminated = (char *)malloc(size + 1);
memcpy(null_terminated, (char *)data, size);
null_terminated[size] = '\0';

// Call various json handlers
heim_error_t error = NULL;
heim_object_t o = heim_json_create(null_terminated, 20, 0, &error);
if (error == NULL) {
heim_error_t error2 = NULL;
heim_object_t o2 = heim_json_copy_serialize(o, 0, &error2);
if (error2 == NULL) {
heim_error_t error3 = NULL;
heim_object_t o3 =
heim_json_create(heim_string_get_utf8(o2), 20, 0, &error3);
if (error3 != NULL) {
heim_json_eq(o, o3);
}
}
heim_release(o2);
}
heim_release(o);

free(null_terminated);
return 0;
}
2 changes: 2 additions & 0 deletions projects/heimdal/fuzz_json.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libfuzzer]
detect_leaks=0
6 changes: 6 additions & 0 deletions projects/heimdal/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
homepage: "https://github.com/heimdal/heimdal"
main_repo: "https://github.com/heimdal/heimdal"
language: c
primary_contact: "[email protected]"
auto_ccs :
- "[email protected]"
Loading