diff --git a/plugins/pass/store/store.go b/plugins/pass/store/store.go index fc79fa75..2726ef0a 100644 --- a/plugins/pass/store/store.go +++ b/plugins/pass/store/store.go @@ -33,7 +33,7 @@ func NewPassValue(value []byte) *PassValue { } func (m *PassValue) Marshal() ([]byte, error) { - return m.value, nil + return append([]byte(nil), m.value...), nil } func (m *PassValue) Unmarshal(data []byte) error { diff --git a/plugins/pass/store/store_test.go b/plugins/pass/store/store_test.go index 4c53c217..60e3e9fd 100644 --- a/plugins/pass/store/store_test.go +++ b/plugins/pass/store/store_test.go @@ -34,3 +34,15 @@ func TestPassValueUnmarshalCopies(t *testing.T) { require.NoError(t, err) assert.Equal(t, []byte("hunter2"), out) } + +func TestPassValueMarshalCopies(t *testing.T) { + pv := NewPassValue([]byte("hunter2")) + + out, err := pv.Marshal() + require.NoError(t, err) + clear(out) + + again, err := pv.Marshal() + require.NoError(t, err) + assert.Equal(t, []byte("hunter2"), again) +}