Skip to content

Conversation

LucienBrule
Copy link
Contributor

Fix OOB in StaticResourcesProcessor for META-INF/resources-only JARs

What it does

This patch prevents a StringIndexOutOfBoundsException when a jar contains only the META-INF/resources entry (without any files underneath). Quarkus’ StaticResourcesProcessor was unconditionally calling:

rel.substring(META_INF_RESOURCES.length())

even when rel.equals("META-INF/resources"), which triggers the out-of-bounds error.

How it’s fixed

We now guard on rel.startsWith(prefix) before stripping off the META-INF/resources/ prefix:

if (rel.startsWith(prefix)) {
    String subPath = rel.substring(prefix.length());
    knownPaths.add(new Entry(subPath, false));
}

This safely skips jars that don’t have any static files under META-INF/resources.

Issue

Closes #47666

Verification

I ran the graalpy-demo reproduction script in all modes (break, fix, and verify), and now the native build succeeds without error.


Thank you for reviewing! 🙏

Copy link
Member

@maxandersen maxandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impressive we haven't seen this elsewhere :)

lgtm.

Copy link

quarkus-bot bot commented May 4, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit a7849ec.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@phillip-kruger phillip-kruger merged commit 6b47266 into quarkusio:main May 5, 2025
57 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.23 - main milestone May 5, 2025
@gsmet gsmet modified the milestones: 3.23 - main, 3.20.1 May 6, 2025
@gsmet gsmet modified the milestones: 3.20.1, 3.23 - main May 6, 2025
@gsmet gsmet modified the milestones: 3.23 - main, 3.22.2 May 6, 2025
@jmartisk jmartisk modified the milestones: 3.22.2, 3.20.2 Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StringIndexOutOfBoundsException in StaticResourcesProcessor with META-INF/resources-only JARs
5 participants