Skip to content

Commit ab6a54c

Browse files
committed
Sanitize username used for constructing log filenames.
On Windows, os/user.Current may return a username containing a backslash.
1 parent c2ab0c9 commit ab6a54c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

glog_file.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ func init() {
6464
if err == nil {
6565
userName = current.Username
6666
}
67+
68+
// Sanitize userName since it may contain filepath separators on Windows.
69+
userName = strings.Replace(userName, `\`, "_", -1)
6770
}
6871

6972
// shortHostname returns its argument, truncating at the first period.

0 commit comments

Comments
 (0)