Title: Fix null reference bind in header parsing by brunopostle · Pull Request #8716 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Fix null reference bind in header parsing by brunopostle · Pull Request #8716 · IfcOpenShell/IfcOpenShell
X Title: Fix null reference bind in header parsing by brunopostle · Pull Request #8716 · IfcOpenShell/IfcOpenShell
Description: Summary read_from_spf_file() in src/ifcparse/IfcSpfHeader.cpp unconditionally dereferences storage->references_to_resolve to bind it to a reference parameter: return pc.construct(boost::none, *storage->references_to_resolve, decl, ...); That member is never set while parsing header entities (FILE_DESCRIPTION, FILE_NAME, FILE_SCHEMA don't carry forward instance references), so this binds a reference to a null pointer — undefined behaviour per the standard, since compilers are permitted to assume references are never null. Fix: fall back to an empty, throwaway unresolved_references list when references_to_resolve is unset. Reproduction This triggers on any file with a header, not just malformed input, but only surfaces under UBSan. It was found via a new coverage-guided libFuzzer harness for IfcParse::IfcFile (not yet upstreamed). Build with UBSan and parse any valid IFC file: mkdir build-fuzz && cd build-fuzz cmake ../cmake \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_CXX_FLAGS="-fsanitize=undefined -fno-sanitize-recover=all -g -O1" \ -DCMAKE_C_FLAGS="-fsanitize=undefined -fno-sanitize-recover=all -g -O1" \ -DBUILD_IFCGEOM=OFF -DWITH_OPENCASCADE=OFF -DBUILD_ONLY_COMMON_SCHEMAS=ON cmake --build . --target IfcConvert -- -j$(nproc) UBSAN_OPTIONS=print_stacktrace=1 ./ifcconvert/IfcConvert any_file.ifc /dev/null Before the fix: src/ifcparse/IfcSpfHeader.cpp:38:46: runtime error: reference binding to null pointer of type 'unresolved_references' ... After the fix: clean exit, no UBSan report. No dedicated regression test is included — the code path is already exercised by every existing test that opens a file; the bug only manifests under a sanitizer build, so verification is via the UBSan repro above. AI-generated content This change (diagnosis and fix) was generated with the assistance of an AI coding tool, per AGENTS.md.
Open Graph Description: Summary read_from_spf_file() in src/ifcparse/IfcSpfHeader.cpp unconditionally dereferences storage->references_to_resolve to bind it to a reference parameter: return pc.construct(boost::none, *s...
X Description: Summary read_from_spf_file() in src/ifcparse/IfcSpfHeader.cpp unconditionally dereferences storage->references_to_resolve to bind it to a reference parameter: return pc.construct(boost::none...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/pull/8716
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:fa1b564c-8d9e-f847-eddb-6c47f196a62e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | ACD8:2876DA:C342E4:FF7930:6B04DE2A |
| html-safe-nonce | f460e5c292a90b68c67979a270479d3c34c1cea7275aab6ad2e2bafa0a5bad43 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0Q4OjI4NzZEQTpDMzQyRTQ6RkY3OTMwOjZCMDRERTJBIiwidmlzaXRvcl9pZCI6IjQ1NDA1OTI3NjIzMDcwMTAwOTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5044ed661dc357160a0948587c99b8099dbea99bee4c54a95cb9f976ca1cd15c |
| hovercard-subject-tag | pull_request:4080160162 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/IfcOpenShell/IfcOpenShell/pull/8716/files |
| twitter:image | https://avatars.githubusercontent.com/u/1747315?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1747315?s=400&v=4 |
| og:image:alt | Summary read_from_spf_file() in src/ifcparse/IfcSpfHeader.cpp unconditionally dereferences storage->references_to_resolve to bind it to a reference parameter: return pc.construct(boost::none, *s... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 194dacb8acfd3e4d3ffb2704e0b1f10327f0dad690a7142acc7b0e0a2d073965 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6c35540a0a2991ee20bd053ba2601cce33f72cb1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width