{"record":{"id":"24765ddaf2136520","repo":"peass-ng/PEASS-ng","slug":"volumename-24765d","errorCode":null,"errorMessage":"volumeName","messagePattern":"volumeName","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/VolumeInfo.cs","lineNumber":51,"sourceCode":"   [Serializable]\n   [SecurityCritical]\n   public sealed class VolumeInfo\n   {\n      [NonSerialized] private readonly bool _continueOnAccessError;\n      [NonSerialized] private readonly SafeFileHandle _volumeHandle;\n      [NonSerialized] private NativeMethods.VOLUME_INFO_FLAGS _volumeInfoAttributes;\n\n\n      /// <summary>Initializes a VolumeInfo instance.</summary>\n      /// <exception cref=\"ArgumentNullException\"/>\n      /// <exception cref=\"ArgumentException\"/>\n      /// <param name=\"volumeName\">A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \\\\server\\share.</param>\n      [SuppressMessage(\"Microsoft.Design\", \"CA1062:Validate arguments of public methods\", MessageId = \"0\", Justification = \"Utils.IsNullOrWhiteSpace validates arguments.\")]\n      [SecurityCritical]\n      public VolumeInfo(string volumeName)\n      {\n         if (Utils.IsNullOrWhiteSpace(volumeName))\n            throw new ArgumentNullException(\"volumeName\");\n\n\n         if (!volumeName.StartsWith(Path.LongPathPrefix, StringComparison.Ordinal))\n            volumeName = Path.IsUncPathCore(volumeName, false, false) ? Path.GetLongPathCore(volumeName, GetFullPathOptions.None) : Path.LongPathPrefix + volumeName;\n\n         else\n         {\n            volumeName = volumeName.Length == 1 ? volumeName + Path.VolumeSeparatorChar : Path.GetPathRoot(volumeName, false);\n\n            if (!volumeName.StartsWith(Path.GlobalRootPrefix, StringComparison.OrdinalIgnoreCase))\n               volumeName = Path.GetPathRoot(volumeName, false);\n         }\n\n\n         if (Utils.IsNullOrWhiteSpace(volumeName))\n            throw new ArgumentException(Resources.InvalidDriveLetterArgument, \"volumeName\");\n\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/VolumeInfo.cs#L33-L69","documentation":"The VolumeInfo constructor requires a non-empty volumeName (drive path, drive letter, or UNC share) because all subsequent path normalization depends on it. It throws ArgumentNullException naming volumeName when the value is null, empty, or whitespace. This is a fail-fast guard before GetLongPathCore / prefix normalization runs.","triggerScenarios":"new VolumeInfo(null), new VolumeInfo(\"\"), or whitespace; constructing from DriveInfo properties on a drive that no longer exists, or from a config/env value that resolved to empty.","commonSituations":"Enumerating drives where a removable device was unplugged between listing and VolumeInfo construction; configuration files with a missing DriveLetter key; passing DriveInfo.Name results from a failed drive query.","solutions":["Pass a valid drive root like \"C:\\\" or a UNC path like \"\\\\\\\\server\\\\share\".","Check the drive exists first (DriveInfo.IsReady or GetDrives()) before constructing VolumeInfo.","Validate with string.IsNullOrWhiteSpace and fall back to a default volume or skip the entry."],"exampleFix":"// before\nvar info = new VolumeInfo(drive.RootDirectory.Name); // drive may be gone\n// after\nvar di = new DriveInfo(\"C\");\nif (di.IsReady)\n{\n    var info = new VolumeInfo(di.RootDirectory.FullName);\n}\nelse\n{\n    // skip or log: volume unavailable\n}","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(volumeName))\n    throw new ArgumentException(\"volumeName required, e.g. C:\\\\ or \\\\\\\\server\\\\share\");\nvar info = new VolumeInfo(volumeName);","typeGuard":"static bool IsValidVolumeName(string s) =>\n    !string.IsNullOrWhiteSpace(s) &&\n    (s.StartsWith(\"\\\\\\\\\", StringComparison.Ordinal) ||\n     (s.Length >= 2 && char.IsLetter(s[0]) && s[1] == ':'));","tryCatchPattern":"try { var info = new VolumeInfo(volumeName); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"volumeName\")\n{\n    // missing drive path; skip entry or use default volume\n}","preventionTips":["Check DriveInfo.IsReady for removable/network drives before constructing","Never construct VolumeInfo from values that may be unbound config keys","Use DriveInfo.RootDirectory.FullName as the canonical input","Validate UNC paths include both server and share"],"tags":["csharp","alphafs","argument-null","filesystem"],"backgroundTag":"null-or-empty-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}