{"record":{"id":"2b4dfd6b02360200","repo":"projectdiscovery/nuclei","slug":"share-name-cannot-be-empty","errorCode":null,"errorMessage":"share name cannot be empty","messagePattern":"share name cannot be empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/js/libs/smbsession/path.go","lineNumber":54,"sourceCode":"\tif strings.ContainsRune(p, 0) {\n\t\treturn \"\", fmt.Errorf(\"share path contains NUL\")\n\t}\n\tclean := path.Clean(p)\n\tclean = strings.TrimPrefix(clean, \"/\")\n\tif clean == \"..\" || strings.HasPrefix(clean, \"../\") {\n\t\treturn \"\", fmt.Errorf(\"share path escapes share root: %q\", p)\n\t}\n\tif clean == \".\" {\n\t\treturn \".\", nil\n\t}\n\treturn clean, nil\n}\n\n// RequireShareName validates a share name (no path separators).\nfunc RequireShareName(share string) error {\n\tshare = strings.TrimSpace(share)\n\tif share == \"\" {\n\t\treturn fmt.Errorf(\"share name cannot be empty\")\n\t}\n\tif strings.ContainsAny(share, `/\\`) {\n\t\treturn fmt.Errorf(\"share name must not contain path separators: %q\", share)\n\t}\n\tif strings.ContainsRune(share, 0) {\n\t\treturn fmt.Errorf(\"share name contains NUL\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":36,"sourceCodeEnd":64,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/libs/smbsession/path.go#L36-L64","documentation":"RequireShareName is the first check smbsession helpers run on the share argument. After trimming whitespace, an empty share name is rejected because there is no share to mount (UseShare would fail deeper in the stack with a less clear error). This is purely caller-side input validation.","triggerScenarios":"Calling s.ListDir('', 'dir'), s.ReadFile('  ', 'file', 0), or passing a template variable for the share that resolved to an empty string.","commonSituations":"Optional template inputs interpolated into the share slot; destructuring that misses the share field; iterating over a share list where one entry is blank.","solutions":["Pass a concrete share name such as 'C$', 'IPC$', or 'NETLOGON'","Default the share when the input variable is empty before calling","Filter empty entries out of share lists before iterating"],"exampleFix":"// before\nlet share = '';\ns.ListDir(share, 'Windows'); // share name cannot be empty\n\n// after\nlet share = 'C$';\ns.ListDir(share, 'Windows');","handlingStrategy":"validation","validationCode":"share = strings.TrimSpace(share)\nif share == \"\" { return errors.New(\"share required\") }","typeGuard":"func validShareName(s string) bool { return strings.TrimSpace(s) != \"\" }","tryCatchPattern":"if err := smbsession.RequireShareName(share); err != nil {\n    share = \"C$\" // sensible default\n    if err = smbsession.RequireShareName(share); err != nil { return err }\n}","preventionTips":["Require a non-empty share argument in template inputs","Default administrative shares like C$ when the variable is optional","Filter blank entries from enumerated share lists before iterating"],"tags":["validation","input","smb","configuration"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}