{"record":{"id":"dab92e9ecadc391e","repo":"peass-ng/PEASS-ng","slug":"drivepath","errorCode":null,"errorMessage":"drivePath","messagePattern":"drivePath","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/DiskSpaceInfo.cs","lineNumber":53,"sourceCode":"   [Serializable]\n   [SecurityCritical]\n   public sealed class DiskSpaceInfo\n   {\n      [NonSerialized] private readonly bool _initGetClusterInfo = true;\n      [NonSerialized] private readonly bool _initGetSpaceInfo = true;\n      [NonSerialized] private readonly CultureInfo _cultureInfo = CultureInfo.CurrentCulture;\n      [NonSerialized] private readonly bool _continueOnAccessError;\n\n\n      /// <summary>Initializes a DiskSpaceInfo instance.</summary>\n      /// <param name=\"drivePath\">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      /// <Remark>This is a Lazyloading object; call <see cref=\"Refresh()\"/> to populate all properties first before accessing.</Remark>\n      [SuppressMessage(\"Microsoft.Design\", \"CA1062:Validate arguments of public methods\", MessageId = \"0\", Justification = \"Utils.IsNullOrWhiteSpace validates arguments.\")]\n      [SecurityCritical]\n      public DiskSpaceInfo(string drivePath)\n      {\n         if (Utils.IsNullOrWhiteSpace(drivePath))\n            throw new ArgumentNullException(\"drivePath\");\n\n\n         drivePath = drivePath.Length == 1 ? drivePath + Path.VolumeSeparatorChar : Path.GetPathRoot(drivePath, false);\n\n         if (Utils.IsNullOrWhiteSpace(drivePath))\n            throw new ArgumentException(Resources.InvalidDriveLetterArgument, \"drivePath\");\n\n\n         // MSDN:\n         // If this parameter is a UNC name, it must include a trailing backslash (for example, \"\\\\MyServer\\MyShare\\\").\n         // Furthermore, a drive specification must have a trailing backslash (for example, \"C:\\\").\n         // The calling application must have FILE_LIST_DIRECTORY access rights for this directory.\n         DriveName = Path.AddTrailingDirectorySeparator(drivePath, false);\n      }\n\n      \n      /// <summary>Initializes a DiskSpaceInfo instance.</summary>\n      /// <param name=\"drivePath\">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>","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/DiskSpaceInfo.cs#L35-L71","documentation":"AlphaFS's DiskSpaceInfo constructor throws ArgumentNullException with param name 'drivePath' when the passed drive path is null, empty, or whitespace. AlphaFS validates inputs eagerly so drive queries fail clearly rather than deep inside Win32 calls.","triggerScenarios":"Calling new DiskSpaceInfo(null), new DiskSpaceInfo(\"\"), or new DiskSpaceInfo(\"   \"); typically from a variable that failed to populate before construction.","commonSituations":"Enumerating drives where a lookup returns null; parsing command-line args that omitted a drive; string.Split producing an empty entry; a registry/config value that is blank.","solutions":["Check string.IsNullOrWhiteSpace(drivePath) before constructing DiskSpaceInfo","Fix the upstream source that produced the null/empty string (missing config value, failed lookup)","Handle empty enumeration results before constructing drive info objects"],"exampleFix":"// before\nvar dsi = new DiskSpaceInfo(userInput);\n// after\nif (string.IsNullOrWhiteSpace(userInput))\n    throw new ArgumentException(\"A drive path is required.\");\nvar dsi = new DiskSpaceInfo(userInput);","handlingStrategy":"type-guard","validationCode":"if (string.IsNullOrWhiteSpace(drivePath))\n    throw new ArgumentException(\"drivePath must be a non-empty drive path like C:\\\\\\\\\");\nvar dsi = new DiskSpaceInfo(drivePath);","typeGuard":"static bool IsValidDrivePath(string p) =>\n    !string.IsNullOrWhiteSpace(p) &&\n    !string.IsNullOrEmpty(Path.GetPathRoot(Path.IsPathRooted(p) ? p : p + \"\\\\\"));","tryCatchPattern":"try { var dsi = new DiskSpaceInfo(drivePath); }\ncatch (ArgumentNullException ex) { log.Error(\"drivePath was null/empty\", ex); }","preventionTips":["Validate strings with IsNullOrWhiteSpace before calling AlphaFS constructors","Never pass unvalidated UI/config input directly","Default to a known-good value like \"C:\\\\\" when input is empty"],"tags":["csharp","argument-null","alphafs","input-validation"],"backgroundTag":"null-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}