diff --git a/internal/literals/literals.go b/internal/literals/literals.go index 8f3b722..a24c7c0 100644 --- a/internal/literals/literals.go +++ b/internal/literals/literals.go @@ -106,16 +106,16 @@ func Obfuscate(file *ast.File, info *types.Info, fset *token.FileSet, ignoreObj } var value byte if lit.Kind == token.CHAR { - val, _, _, err := strconv.UnquoteChar(lit.Value, '\'') + val, err := strconv.Unquote(lit.Value) if err != nil { - return true + panic(fmt.Sprintf("cannot unquote character: %v", err)) } - value = byte(val) + value = byte(val[0]) } else { val, err := strconv.ParseUint(lit.Value, 0, 8) if err != nil { - return true + panic(fmt.Sprintf("cannot parse integer: %v", err)) } value = byte(val) diff --git a/testdata/scripts/literals.txt b/testdata/scripts/literals.txt index 97dc18d..0e2b39c 100644 --- a/testdata/scripts/literals.txt +++ b/testdata/scripts/literals.txt @@ -225,9 +225,12 @@ func constantTest() { const impType = imported.ImportedType(3) } -// TODO: this only tests, that we don't break byte slices -// it was verified manually that these actually get obfuscated, -// however we should add regression tests +// TODO: This only tests that we don't break byte slices. +// It was manually verified that they do get obfuscated, +// The original bytes don't seem to show up in the binary, +// meaning that we can't test for them via binsubstr. +// We should figure out a way to test for the byte sequences. +// For now, we manually tested these when they got added. func byteTest() { a := []byte{12, 13} for _, elm := range a {