Skip to content

qasan: support libc implementations with opaque FILE - #2909

Merged
vanhauser-thc merged 2 commits into
AFLplusplus:devfrom
qiyuhuating:fix-qasan-opaque-file
Oct 25, 2026
Merged

vanhauser-thc merged 2 commits into
AFLplusplus:devfrom
qiyuhuating:fix-qasan-opaque-file

Conversation

@qiyuhuating

Copy link
Copy Markdown
Contributor

Summary

  • probe at build time whether the target libc exposes FILE as a complete type
  • only use sizeof(FILE) in the fgets QASAN hook when that probe succeeds
  • preserve the existing Android exception

Rationale

FILE is an opaque type in musl's public headers, so the current unconditional sizeof(FILE) prevents libqasan from compiling there. Keying the workaround on __GLIBC__ or treating every non-glibc libc as opaque is too broad.

A compile probe asks the target compiler directly whether FILE is complete. Libcs that expose the object layout keep the existing QASAN range check; conforming opaque implementations simply let libc own the internal FILE dereference, while QASAN still validates the user buffer passed to fgets.

Fixes #2832

@vanhauser-thc

Copy link
Copy Markdown
Member

yes I think this is the easiest fix. thanks

@vanhauser-thc
vanhauser-thc merged commit 43a4d2f into AFLplusplus:dev Oct 25, 2026
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.

2 participants