From c6460b19bd834875b00f199390e6121d5bdfba7e Mon Sep 17 00:00:00 2001 From: Bryan McNulty Date: Sun, 9 Mar 2025 12:26:05 -0500 Subject: massively improved SCMR module + new DCE client --- internal/util/util.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'internal/util/util.go') diff --git a/internal/util/util.go b/internal/util/util.go index 36d7ea2..f8f12ba 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -3,6 +3,7 @@ package util import ( "math/rand" // not crypto secure "regexp" + "strings" ) const randHostnameCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-" @@ -33,3 +34,17 @@ func RandomStringFromCharset(charset string, length int) string { } return string(b) } + +func RandomStringIfBlank(s string) string { + if s == "" { + return RandomString() + } + return s +} + +func CheckNullString(s string) string { + if !strings.HasSuffix(s, "\x00") { + return s + "\x00" + } + return s +} -- cgit v1.2.3