common/type.go: Truncate ASCII strings at the first NUL

This can prevent the string from being classified as "binary" and its
value being suppressed in output.
pull/56/head
Dustin Oprea 2021-01-31 17:09:03 -05:00
parent 52fa399645
commit 443fda923a
1 changed files with 7 additions and 0 deletions

View File

@ -186,6 +186,13 @@ func FormatFromType(value interface{}, justFirst bool) (phrase string, err error
case []byte:
return DumpBytesToString(t), nil
case string:
for i, c := range t {
if c == 0 {
t = t[:i]
break
}
}
if isPrintableText(t) == false {
phrase = fmt.Sprintf("string with binary data (%d bytes)", len(t))
return phrase, nil