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

Add instruction for a C++ fuzz target includes a C file from a C++ project #420

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DonggeLiu
Copy link
Collaborator

@DonggeLiu DonggeLiu commented Jul 3, 2024

Example:

In file included from /src/libvpx/examples/vpx_dec_fuzzer.cc:28:
/src/libvpx/vp9/decoder/vp9_decodeframe.c:69:11: error: cannot initialize a variable of type 'TX_MODE' with an rvalue of type 'int'
   69 |   TX_MODE tx_mode = vpx_read_literal(r, 2);

In the long term, we probably should not be required to include source code files.

@DonggeLiu
Copy link
Collaborator Author

/gcbrun exp -n dg

@DonggeLiu
Copy link
Collaborator Author

/gcbrun exp -f -n dg

@DonggeLiu
Copy link
Collaborator Author

DonggeLiu commented Jul 3, 2024

@oliverchang @jonathanmetzman Do you happen to know if there is a solution to this error?
This error is caused by including a C file in the C++ fuzz target.
C allows type casting, but C++ does not, hence the error happened on the #include statement.
The original fuzz target is in C++ and so is the project-under-test (openssl).
But that specific file vp9_decodeframe.c is in C:

In file included from /src/libvpx/examples/vpx_dec_fuzzer.cc:28:
/src/libvpx/vp9/decoder/vp9_decodeframe.c:69:11: error: cannot initialize a variable of type 'TX_MODE' with an rvalue of type 'int'
   69 |   TX_MODE tx_mode = vpx_read_literal(r, 2);

I tried adding extern "C" around the #include statement, but it does fix the error:

extern "C" {
    #include "/src/libvpx/vp9/decoder/vp9_decodeframe.c"
}

@DonggeLiu DonggeLiu marked this pull request as draft July 12, 2024 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant