{"record":{"id":"4174415642268f11","repo":"peass-ng/PEASS-ng","slug":"rootpathname","errorCode":null,"errorMessage":"rootPathName","messagePattern":"rootPathName","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.VolumeLabel.cs","lineNumber":45,"sourceCode":"{\n   public static partial class Volume\n   {\n      /// <summary>[AlphaFS] Deletes the label of the file system volume that is the root of the current directory.</summary>\n      [SecurityCritical]\n      public static void DeleteCurrentVolumeLabel()\n      {\n         SetVolumeLabel(null, null);\n      }\n\n\n      /// <summary>[AlphaFS] Deletes the label of a file system volume.</summary>\n      /// <exception cref=\"ArgumentNullException\"/>\n      /// <param name=\"rootPathName\">The root directory of a file system volume. This is the volume the function will remove the label.</param>\n      [SecurityCritical]\n      public static void DeleteVolumeLabel(string rootPathName)\n      {\n         if (Utils.IsNullOrWhiteSpace(rootPathName))\n            throw new ArgumentNullException(\"rootPathName\");\n\n\n         SetVolumeLabel(rootPathName, null);\n      }\n\n\n      /// <summary>[AlphaFS] Retrieve the label of a file system volume.</summary>\n      /// <param name=\"volumePath\">\n      ///   A path to a volume. For example: \"C:\\\", \"\\\\server\\share\", or \"\\\\?\\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\\\".\n      /// </param>\n      /// <returns>The the label of the file system volume. This function can return <c>string.Empty</c> since a volume label is generally not mandatory.</returns>\n      [SecurityCritical]\n      public static string GetVolumeLabel(string volumePath)\n      {\n         return new VolumeInfo(volumePath, true, true).Name;\n      }\n\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.VolumeLabel.cs#L27-L63","documentation":"Volume.DeleteVolumeLabel removes a volume's label by calling SetVolumeLabel with a null label. Before doing so it validates rootPathName with Utils.IsNullOrWhiteSpace and throws ArgumentNullException naming rootPathName when it is null, empty, or whitespace. The library treats a missing root path as a programming error rather than deferring to the native API.","triggerScenarios":"Calling Volume.DeleteVolumeLabel(null), DeleteVolumeLabel(\"\"), or DeleteVolumeLabel(\"   \"); also passing a variable populated from failed configuration parsing or an empty Environment.GetEnvironmentVariable result.","commonSituations":"Building the drive root from user config where the drive letter was not set; string.Split on a path that produced an empty entry; refactoring that renamed a variable but left the argument unbound.","solutions":["Pass a valid volume root such as \"C:\\\" (drive letter with backslash).","If the value comes from config or user input, validate it is non-empty and looks like a root path before calling.","Wrap the call in a null/whitespace check and surface a domain-specific message instead of ArgumentNullException."],"exampleFix":"// before\nstring root = config[\"VolumeRoot\"]; // may be null\nVolume.DeleteVolumeLabel(root);\n// after\nstring root = config[\"VolumeRoot\"];\nif (string.IsNullOrWhiteSpace(root)) throw new InvalidOperationException(\"VolumeRoot must be configured, e.g. C:\\\\\");\nVolume.DeleteVolumeLabel(root);","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrWhiteSpace(rootPathName) &&\n    rootPathName.Length == 3 && rootPathName[1] == ':' && rootPathName[2] == '\\\\')\n{\n    Volume.DeleteVolumeLabel(rootPathName);\n}","typeGuard":"static bool IsDriveRoot(string s) =>\n    !string.IsNullOrWhiteSpace(s) && s.Length == 3 &&\n    char.IsLetter(s[0]) && s[1] == ':' && s[2] == '\\\\';","tryCatchPattern":"try { Volume.DeleteVolumeLabel(rootPathName); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"rootPathName\")\n{\n    // rootPathName was null/empty; log and require configuration\n}","preventionTips":["Pass the drive root with trailing backslash, e.g. \"C:\\\"","Validate configuration keys that feed volume paths at startup","Treat empty label removal as DeleteVolumeLabel, not SetVolumeLabel(\"\")","Use DriveInfo.RootDirectory.FullName to build the root"],"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"}