aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-11 16:24:51 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-08-11 16:24:51 +0200
commit39cae09f33fda0336f32263ab0e4b01e6516b475 (patch)
tree776574eb4e237376e0e406efd0d54b0a2f3d1d78
parent1fc0948261deb6f040f96ed53c588da2d2aeafde (diff)
Nicer memory management
-rw-r--r--main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/main.c b/main.c
index 572e5b5..b161735 100644
--- a/main.c
+++ b/main.c
@@ -161,7 +161,8 @@ uri_parse(struct totp_config *conf, const char *uri_raw)
if (STREQ(p->key, "secret")) {
if (p->value == NULL)
WARNX_AND_RET("Secret key has no value");
- conf->enc_sec = p->value;
+ if ((conf->enc_sec = strdup(p->value)) == NULL)
+ err(EXIT_FAILURE, "strdup");
} else if (STREQ(p->key, "digits")) {
if (p->value == NULL)
WARNX_AND_RET(empty_param, "digits");
@@ -225,8 +226,9 @@ totp(struct totp_config conf, uint32_t *code)
| (mac[off + 1] & 0xFF) << 16
| (mac[off + 2] & 0xFF) << 8
| (mac[off + 3] & 0xFF) << 0;
-
*code = binc % pow32(10, conf.len);
+
+ free(key);
return true;
}