{"record":{"id":"df9c025765dc285f","repo":"asLody/VirtualApp","slug":"invalid-name","errorCode":null,"errorMessage":"Invalid name: ","messagePattern":"Invalid name: ","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"VirtualApp/lib/src/main/java/com/lody/virtual/server/pm/installer/PackageInstallerSession.java","lineNumber":338,"sourceCode":"            throw new IOException(e);\n        }\n    }\n\n    @Override\n    public ParcelFileDescriptor openRead(String name) throws RemoteException {\n        try {\n            return openReadInternal(name);\n        } catch (IOException e) {\n            throw new IllegalStateException(e);\n        }\n    }\n\n    private ParcelFileDescriptor openReadInternal(String name) throws IOException {\n        assertPreparedAndNotSealed(\"openRead\");\n\n        try {\n            if (!FileUtils.isValidExtFilename(name)) {\n                throw new IllegalArgumentException(\"Invalid name: \" + name);\n            }\n            final File target = new File(resolveStageDir(), name);\n\n            final FileDescriptor targetFd = Os.open(target.getAbsolutePath(), O_RDONLY, 0);\n            return ParcelFileDescriptor.dup(targetFd);\n\n        } catch (ErrnoException e) {\n            throw new IOException(e);\n        }\n    }\n\n    @Override\n    public void removeSplit(String splitName) throws RemoteException {\n        if (TextUtils.isEmpty(params.appPackageName)) {\n            throw new IllegalStateException(\"Must specify package name to remove a split\");\n        }\n        try {\n            createRemoveSplitMarker(splitName);","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/asLody/VirtualApp/blob/666fefcb5d3f39cc944001c3457c38ffd6544c87/VirtualApp/lib/src/main/java/com/lody/virtual/server/pm/installer/PackageInstallerSession.java#L320-L356","documentation":"openReadInternal validates the requested file name with FileUtils.isValidExtFilename before opening it inside the stage directory; an invalid name throws IllegalArgumentException('Invalid name: ' + name). This prevents malformed or path-like names from being used to address files in the session stage dir.","triggerScenarios":"Calling session.openRead(name) where name contains path separators ('../'), is null/empty, or otherwise fails isValidExtFilename.","commonSituations":"Reconstructing APK part names dynamically (e.g. concatenating split names) and accidentally including slashes or illegal characters; reading a file the session never wrote; passing user-supplied names straight through.","solutions":["Sanitize the name with FileUtils.isValidExtFilename (or FilenameUtils) before calling openRead.","Only pass file names previously returned by session.getNames().","Strip path components: use new File(userInput).getName() and reject anything containing '/' or '\\\\'."],"exampleFix":"// before\nInputStream in = new ParcelFileDescriptor.AutoCloseInputStream(session.openRead(userInput));\n\n// after\nString name = new File(userInput).getName();\nif (!FileUtils.isValidExtFilename(name)) {\n    throw new IllegalArgumentException(\"Bad file name: \" + name);\n}\nInputStream in = new ParcelFileDescriptor.AutoCloseInputStream(session.openRead(name));","handlingStrategy":"validation","validationCode":"if (name == null || !FileUtils.isValidExtFilename(new File(name).getName())) {\n    throw new IllegalArgumentException(\"Invalid session file name: \" + name);\n}","typeGuard":"boolean isValidSessionFileName(String s) {\n    return s != null && !s.isEmpty() && s.equals(new File(s).getName()) && FileUtils.isValidExtFilename(s);\n}","tryCatchPattern":"try (InputStream in = new ParcelFileDescriptor.AutoCloseInputStream(session.openRead(name))) {\n    // read\n} catch (IllegalArgumentException e) {\n    // log invalid name and fall back to getNames() lookup\n}","preventionTips":["Only openRead names returned by session.getNames().","Strip path components from any user-provided name.","Reject names containing '/', '\\\\', or null characters early."],"tags":["illegal-argument","filename-validation","package-installer","android"],"backgroundTag":"invalid-argument-format","analyzedSha":"666fefcb5d3f39cc944001c3457c38ffd6544c87","analyzedAt":"2026-09-09T11:09:01.694Z","contentChangedAt":"2026-09-09T11:09:01.694Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}