commit 42af6f6a1c9897afcb8a2c8fa5d86039c74d3bf9
parent 6f53e6d134a27a6958dd76c67b6a110ec822274c
Author: Santtu Lakkala <inz@inz.fi>
Date: Thu, 18 Jan 2024 13:34:08 +0200
Change key list format to match token generation input
Diffstat:
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dtotp b/dtotp
@@ -5,7 +5,7 @@ ID=
if [ "$1" ]; then
ID="*$1*"
else
- ID=$(totp -K - -l <<FOO | cut -d ' ' -f1 | dmenu -sb '#000000' -sf '#c6f24b' -nb '#000000' -nf '#c0c0c0'
+ ID=$(totp -K - -l <<FOO | dmenu -sb '#000000' -sf '#c6f24b' -nb '#000000' -nf '#c0c0c0'
$KEY
FOO
)
diff --git a/main.c b/main.c
@@ -72,7 +72,10 @@ void print_key(struct token *token, void *data)
(void)data;
- fprintf(stream, "%.*s by %.*s\n", (int)bytes_len(token->desc), token->desc.data, (int)bytes_len(token->issuer), token->issuer.data);
+ fprintf(stream, "%.*s%s%.*s\n",
+ (int)bytes_len(token->issuer), token->issuer.data,
+ bytes_len(token->issuer) ? ":" : "",
+ (int)bytes_len(token->desc), token->desc.data);
}
static void print_uriencode(FILE *stream, struct bytes data, bool getarg)
@@ -129,7 +132,7 @@ void generate_token(struct token *token, void *data)
struct generate_data *d = data;
uint32_t modulo = 1;
uint8_t i;
- char descbuf[512];
+ char descbuf[2 * UINT8_MAX + 2];
char *dp = descbuf;
if (bytes_len(token->issuer)) {