-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libchewing is a library for Chinese character input.
- Loading branch information
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2016 Google Inc. | ||
# | ||
# 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 ossfuzz/base-libfuzzer | ||
MAINTAINER kcwu@csie.org | ||
RUN apt-get install -y make autoconf automake libtool texinfo | ||
|
||
CMD /src/oss-fuzz/libchewing/build.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2016 Google Inc. | ||
// | ||
// 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. | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
def libfuzzerBuild = fileLoader.fromGit('infra/libfuzzer-pipeline.groovy', | ||
'https://github.com/google/oss-fuzz.git', | ||
'master', null, '') | ||
|
||
libfuzzerBuild { | ||
git = "https://github.com/chewing/libchewing.git" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash -eu | ||
# Copyright 2016 Google Inc. | ||
# | ||
# 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. | ||
# | ||
################################################################################ | ||
|
||
cd /src/libchewing | ||
|
||
# build the library. | ||
./autogen.sh | ||
./configure --disable-shared --enable-static --without-sqlite3 | ||
make clean all | ||
|
||
# build your fuzzer(s) | ||
make -C test CFLAGS="$CFLAGS -Dmain=stress_main -Drand=get_fuzz_input" stress.o | ||
|
||
./libtool --mode=link \ | ||
$CC $CFLAGS \ | ||
-o /out/chewing_fuzzer \ | ||
/src/oss-fuzz/libchewing/chewing_fuzzer.c \ | ||
test/stress.o test/libtesthelper.la src/libchewing.la $LDFLAGS /work/libfuzzer/*.o | ||
|
||
# install data files | ||
make -C data pkgdatadir=/out install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <libgen.h> | ||
|
||
static const uint8_t* fuzz_ptr; | ||
static const uint8_t* fuzz_input; | ||
static size_t fuzz_size; | ||
|
||
int stress_main(int argc, char** argv); | ||
|
||
int LLVMFuzzerInitialize(int* argc, char*** argv) { | ||
char* exe_path = (*argv)[0]; | ||
char* dir = dirname(exe_path); | ||
// Assume data files are at the same location as executable. | ||
setenv("CHEWING_PATH", dir, 0); | ||
setenv("CHEWING_USER_PATH", dir, 0); | ||
return 0; | ||
} | ||
|
||
int get_fuzz_input() { | ||
if (fuzz_ptr - fuzz_input >= fuzz_size) | ||
return EOF; | ||
return *fuzz_ptr++; | ||
} | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | ||
fuzz_input = fuzz_ptr = data; | ||
fuzz_size = size; | ||
|
||
const char *stress_argv[] = { | ||
"./chewing_fuzzer", | ||
"-extra", | ||
"-loop", "1", | ||
NULL, | ||
}; | ||
stress_main(4, (char**)stress_argv); | ||
return 0; | ||
} |