aboutsummaryrefslogtreecommitdiff
path: root/contrib/libfido2/src/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libfido2/src/io.c')
-rw-r--r--contrib/libfido2/src/io.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/contrib/libfido2/src/io.c b/contrib/libfido2/src/io.c
index 70f777fb49a0..a9715b5b4bf8 100644
--- a/contrib/libfido2/src/io.c
+++ b/contrib/libfido2/src/io.c
@@ -1,7 +1,8 @@
/*
- * Copyright (c) 2018 Yubico AB. All rights reserved.
+ * Copyright (c) 2018-2022 Yubico AB. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#include "fido.h"
@@ -331,14 +332,25 @@ fido_rx(fido_dev_t *d, uint8_t cmd, void *buf, size_t count, int *ms)
int
fido_rx_cbor_status(fido_dev_t *d, int *ms)
{
- unsigned char reply[FIDO_MAXMSG];
- int reply_len;
+ unsigned char *msg;
+ int msglen;
+ int r;
- if ((reply_len = fido_rx(d, CTAP_CMD_CBOR, &reply, sizeof(reply),
- ms)) < 0 || (size_t)reply_len < 1) {
+ if ((msg = malloc(FIDO_MAXMSG)) == NULL) {
+ r = FIDO_ERR_INTERNAL;
+ goto out;
+ }
+
+ if ((msglen = fido_rx(d, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0 ||
+ (size_t)msglen < 1) {
fido_log_debug("%s: fido_rx", __func__);
- return (FIDO_ERR_RX);
+ r = FIDO_ERR_RX;
+ goto out;
}
- return (reply[0]);
+ r = msg[0];
+out:
+ freezero(msg, FIDO_MAXMSG);
+
+ return (r);
}