Uploaded image for project: 'Quarkus'
  1. Quarkus
  2. QUARKUS-6389

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

XMLWordPrintable

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

          1. 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:

      ```java
      rel.substring(META_INF_RESOURCES.length())
      ```

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

          1. How it’s fixed

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

      ```java
      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`.

          1. Issue

      Closes #47666

          1. 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! 🙏

              Unassigned Unassigned
              blafond Barry LaFond
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: