Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"System.NotSupportedException: The given path's format is not supported" when archive contains files with illegal filenames #1364

Closed
draeath opened this issue Aug 10, 2015 · 3 comments
Labels
Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN ★☆☆

Comments

@draeath
Copy link

draeath commented Aug 10, 2015

Got this when attempting to update HullcamVDS from 0.40 to 0.50.

Long story short, there's a few 0-byte files in the archive named "Thumbs.db:encryptable" that blow CKAN up. Adding them to the exclusions (as other Thumbs.db trash files are handled for other mods) fixes.

I'm going to submit a pull request to fix this mod, if I can figure out how, but here's the crash details, and a delta of the registry.json that fixed it.

Handling of invalid filenames (eg, contains junk characters) should at least be caught in some fashion, instead of falling through to System.NotSupportedException.

C:\Users\draeath>l:\gamestuff\KSP-stuff\ckan.exe install HullcamVDS
About to install...

 * HullcamVDS 0.50

Continue? [Y/n] y

Downloading "https://kerbalstuff.com/mod/450/Hullcam VDS/download/0.50"
0 kbps - downloading - 0 MiB left - 100%
Installing mod "HullcamVDS 0.50"
Unhandled Exception: System.NotSupportedException: The given path's format is not supported.
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at CKAN.ModuleInstaller.CopyZipEntry(ZipFile zipfile, ZipEntry entry, String fullPath, Boolean makeDirs)
   at CKAN.ModuleInstaller.InstallModule(CkanModule module, String zip_filename)
   at CKAN.ModuleInstaller.Install(CkanModule module, String filename)
   at CKAN.ModuleInstaller.InstallList(ICollection`1 modules, RelationshipResolverOptions options, IDownloader downloader)
   at CKAN.CmdLine.Install.RunCommand(KSP ksp, Object raw_options)
   at CKAN.CmdLine.MainClass.Main(String[] args)
--- C:/Users/draeath/Desktop/registry-broke.json    Sun Aug 09 21:00:55 2015
+++ C:/Users/draeath/Desktop/registry-fixed.json    Sun Aug 09 21:00:46 2015
@@ -67167,12 +67167,17 @@
                        {
                            "file": "HullCameraVDS",
                            "find": null,
                            "find_regexp": null,
                            "install_to": "GameData",
-                           "filter": null,
-                           "filter_regexp": null
+                           "filter": [
+                               "Thumbs.db",
+                               "Thumbs.db:encryptable"
+                           ],
+                           "filter_regexp": [
+                               "ModuleManager.*dll$"
+                           ]
                        }
                    ],
                    "spec_version": "1",
                    "abstract": "Hullcam let's you add cameras to any part of your vehicle or construction.",
                    "description": null,
@@ -67180,11 +67185,15 @@
                    "author": [
                        "Albert_VDS"
                    ],
                    "comment": null,
                    "conflicts": null,
-                   "depends": null,
+                   "depends": [
+                       {
+                           "name": "ModuleManager"
+                       }
+                   ],
                    "download": "https://kerbalstuff.com/mod/450/Hullcam%20VDS/download/0.50",
                    "download_size": 5318377,
                    "identifier": "HullcamVDS",
                    "ksp_version": "1.0.4",
                    "ksp_version_max": null,
draeath referenced this issue in KSP-CKAN/NetKAN Aug 10, 2015
0.50 archive contains files with colons in their names, which causes CKAN to crash upon installation. Also, the mod added a dependency of Module Manager - added exclusion of the file and added the dependency spec.
@draeath
Copy link
Author

draeath commented Aug 10, 2015

I'm afraid I don't know what's wrong syntactically and could use some help fixing. EDIT: Was helped (see previous pull request, now closed, for detail). Resubmitted. I couldn't figure out how to "amend" the PR, so new one submitted.

@draeath
Copy link
Author

draeath commented Aug 10, 2015

That PR merge should stop this instance from blowing up... but I'd consider the issue still open as if such a file was included anywhere else it would recur.

@mheguy mheguy added Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN ★☆☆ labels Aug 10, 2015
@HebaruSan
Copy link
Member

We saw this again recently with #2467, though we have more ZIP validation now and System.ArgumentException was thrown instead. I thought about code changes, but I didn't like the idea of hard-coding knowledge about specific operating systems' file systems' limitations.

Catching that exception here might be a good idea:

catch (ZipException ze)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN ★☆☆
Projects
None yet
Development

No branches or pull requests

3 participants