peass-ng/PEASS-ng · error · ArgumentNullException
rootPathName
Error message
rootPathName
What it means
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.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.VolumeLabel.cs:45
{
public static partial class Volume
{
/// <summary>[AlphaFS] Deletes the label of the file system volume that is the root of the current directory.</summary>
[SecurityCritical]
public static void DeleteCurrentVolumeLabel()
{
SetVolumeLabel(null, null);
}
/// <summary>[AlphaFS] Deletes the label of a file system volume.</summary>
/// <exception cref="ArgumentNullException"/>
/// <param name="rootPathName">The root directory of a file system volume. This is the volume the function will remove the label.</param>
[SecurityCritical]
public static void DeleteVolumeLabel(string rootPathName)
{
if (Utils.IsNullOrWhiteSpace(rootPathName))
throw new ArgumentNullException("rootPathName");
SetVolumeLabel(rootPathName, null);
}
/// <summary>[AlphaFS] Retrieve the label of a file system volume.</summary>
/// <param name="volumePath">
/// A path to a volume. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\".
/// </param>
/// <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>
[SecurityCritical]
public static string GetVolumeLabel(string volumePath)
{
return new VolumeInfo(volumePath, true, true).Name;
}
View on GitHub (pinned to 53fb989abc)
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.
Example fix
// before
string root = config["VolumeRoot"]; // may be null
Volume.DeleteVolumeLabel(root);
// after
string root = config["VolumeRoot"];
if (string.IsNullOrWhiteSpace(root)) throw new InvalidOperationException("VolumeRoot must be configured, e.g. C:\\");
Volume.DeleteVolumeLabel(root); Defensive patterns
Strategy: validation
Validate before calling
if (!string.IsNullOrWhiteSpace(rootPathName) &&
rootPathName.Length == 3 && rootPathName[1] == ':' && rootPathName[2] == '\\')
{
Volume.DeleteVolumeLabel(rootPathName);
} Type guard
static bool IsDriveRoot(string s) =>
!string.IsNullOrWhiteSpace(s) && s.Length == 3 &&
char.IsLetter(s[0]) && s[1] == ':' && s[2] == '\\'; Try / catch
try { Volume.DeleteVolumeLabel(rootPathName); }
catch (ArgumentNullException ex) when (ex.ParamName == "rootPathName")
{
// rootPathName was null/empty; log and require configuration
} Prevention
- 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
When it happens
Trigger: Calling Volume.DeleteVolumeLabel(null), DeleteVolumeLabel(""), or DeleteVolumeLabel(" "); also passing a variable populated from failed configuration parsing or an empty Environment.GetEnvironmentVariable result.
Common situations: 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.
Related errors
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/4174415642268f11.
Report an issue: GitHub.