Skip to content

Commit

Permalink
packagesuppliers/filesystem.d: Fix out of bounds on invalid pkg names
Browse files Browse the repository at this point in the history
If a user ran `dub fetch foo-1.1.1` instead of `dub fetch [email protected]`
over a filesystem package supplier, assuming that the archive exists,
the code that slices the filename tries to create an invalid slice as
it assumes that the filename will contain at least the package name, a
one character version separator, and the archive suffix which wouldn't
be the case with a package name like `foo-1.1.1` and an archive name
of `foo-1.1.1.zip`.

The fix is to require one more character in the glob to account for
the version separator.

Signed-off-by: Andrei Horodniceanu <[email protected]>
  • Loading branch information
the-horo authored and Geod24 committed Sep 23, 2024
1 parent 87b5bee commit d78df16
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/dub/packagesuppliers/filesystem.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FileSystemPackageSupplier : PackageSupplier {
import std.conv : to;
import dub.semver : isValidVersion;
Version[] ret;
const zipFileGlob = name.main.toString() ~ "*.zip";
const zipFileGlob = name.main.toString() ~ "?*.zip";
foreach (DirEntry d; dirEntries(m_path.toNativeString(), zipFileGlob, SpanMode.shallow)) {
NativePath p = NativePath(d.name);
auto vers = p.head.name[name.main.toString().length+1..$-4];
Expand Down

0 comments on commit d78df16

Please sign in to comment.