googleprojectzero / SkCodecFuzzer

Fuzzing harness for testing proprietary image codecs supported by Skia on Android
Apache License 2.0
330 stars 77 forks source link

Compile failed #3

Closed wlya closed 4 years ago

wlya commented 4 years ago

Ubuntu16.04 LTS

ubuntu@~/SkCodecFuzzer/source$
make
/home/ubuntu/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang++ -c -o loader.o loader.cc -D_LIBCPP_ABI_NAMESPACE=__1 -I/home/ubuntu/SkCodecFuzzer/skia/include/core -I/home/ubuntu/SkCodecFuzzer/skia/include/codec -I/home/ubuntu/SkCodecFuzzer/skia/include/config -I/home/ubuntu/SkCodecFuzzer/skia/include/config/android -I/home/ubuntu/SkCodecFuzzer/capstone-4.0.1/include -I/home/ubuntu/SkCodecFuzzer/libbacktrace/include
In file included from loader.cc:35:
/home/ubuntu/SkCodecFuzzer/skia/include/codec/SkAndroidCodec.h:11:10: fatal error: 'include/codec/SkCodec.h' file not found
#include "include/codec/SkCodec.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Makefile:17: recipe for target 'loader.o' failed
make: *** [loader.o] Error 1

all deps

./
├── deps
│   └── capstone-4.0.1
├── libbacktrace
│   ├── include
│   └── testdata
├── skia
│   ├── animations
│   ├── .............
│   └── tools
├── source
├── system
│   ├── bin
│   ├── lib
│   └── lib64
└── third_party
    └── libdislocator

modified Makefile

ANDROID_NDK=/home/ubuntu/Android/Sdk/ndk/21.1.6352462
SKIA_PATH=/home/ubuntu/SkCodecFuzzer/skia
CAPSTONE_PATH=/home/ubuntu/SkCodecFuzzer/capstone-4.0.1
ANDROID_PATH=/home/ubuntu/SkCodecFuzzer/system
LIBBACKTRACE_PATH=/home/ubuntu/SkCodecFuzzer/libbacktrace
....
gilmarwsr commented 4 years ago

I have faced the exactly problem... I've created a script to scan al *.h files in the directory (including subdirectories) "/skia/include" and change in all files every entry #include "reference" to #include "../../reference". In your example, this will change #include "include/codec/SkCodec.h" to #include "../../include/codec/SkCodec.h"

I also changed those references in SkCodecFuzzer/source/loader.cc to this:

include "../../skia/include/codec/SkAndroidCodec.h"

include "../../skia/include/core/SkBitmap.h"

include "../../skia/include/codec/SkCodec.h"

include "../../skia/include/core/SkString.h"

wlya commented 4 years ago

Thank you so much. Your advice is very helpful.

ChongChengAC commented 1 year ago

Here's my python script. It's not elegant, but works:

import os

dir_to_traverse = os.getcwd()
user_input = input(
    f"current working directory -- {dir_to_traverse}, continue? [y/n]")
if user_input != "y" and user_input != 'Y':
    exit()
for path, dirs, files in os.walk(dir_to_traverse):
    level = 1 + path.removeprefix(f"{dir_to_traverse}").count("/")
    match_text = "#include \"include"
    replace_text = "#include \"" + level * "../" + "include"
    for filename in files:
        if filename.endswith(".h"):
            with open(f"{path}/{filename}", "r") as f:
                text = f.read()
            text = text.replace(match_text, replace_text)
            with open(f"{path}/{filename}", "w") as f:
                f.write(text)