From d023058630958842f0f521ba2bef43b12955b9d8 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 6 Jul 2025 12:48:24 -0400 Subject: [PATCH] Properly return errors for non-persistent TOTP copy --- core/copy.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/copy.go b/core/copy.go index d9a2e8d..767e13d 100644 --- a/core/copy.go +++ b/core/copy.go @@ -28,16 +28,24 @@ func CopyArgument(targetLocation string, field int) error { } var copySubject string // will store data to be copied + // handle non-persistent TOTP copy + var realField int + if field == -1 { + realField = 2 + } else { + realField = field + } + // ensure field exists in entry - if len(decryptedEntry) > field { + if len(decryptedEntry) > realField { // ensure field is not empty - if field > -1 && decryptedEntry[field] == "" { + if decryptedEntry[realField] == "" { return errors.New("field is empty") } - if field != 2 && field != -1 { - copySubject = decryptedEntry[field] + if realField != 2 { + copySubject = decryptedEntry[realField] } else { // TOTP mode var secret string // stores secret for TOTP generation var forSteam bool // indicates whether to generate TOTP in Steam format