summaryrefslogtreecommitdiffstats
path: root/libraries/libu2f-host/patches/0016-Handle-the-case-when-new_device-returns-NULL-malloc-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/libu2f-host/patches/0016-Handle-the-case-when-new_device-returns-NULL-malloc-.patch')
-rw-r--r--libraries/libu2f-host/patches/0016-Handle-the-case-when-new_device-returns-NULL-malloc-.patch30
1 files changed, 30 insertions, 0 deletions
diff --git a/libraries/libu2f-host/patches/0016-Handle-the-case-when-new_device-returns-NULL-malloc-.patch b/libraries/libu2f-host/patches/0016-Handle-the-case-when-new_device-returns-NULL-malloc-.patch
new file mode 100644
index 0000000000..d85161cd25
--- /dev/null
+++ b/libraries/libu2f-host/patches/0016-Handle-the-case-when-new_device-returns-NULL-malloc-.patch
@@ -0,0 +1,30 @@
+From d944fafe8cee766e5c3c601a16797b890420802c Mon Sep 17 00:00:00 2001
+From: Gabriel Kihlman <g.kihlman@yubico.com>
+Date: Wed, 18 Dec 2019 12:34:30 +0100
+Subject: [PATCH 16/25] Handle the case when new_device() returns NULL (malloc
+ failure)
+
+Signed-off-by: Gustavo B. Schenkel <gustavo.schenkel@gmail.com>
+---
+ u2f-host/devs.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/u2f-host/devs.c b/u2f-host/devs.c
+index aa76c9f..7650743 100644
+--- a/u2f-host/devs.c
++++ b/u2f-host/devs.c
+@@ -435,6 +435,11 @@ u2fh_devs_discover (u2fh_devs * devs, unsigned *max_index)
+ if (usage_page == FIDO_USAGE_PAGE && usage == FIDO_USAGE_U2FHID)
+ {
+ dev = new_device (devs);
++ if (dev == NULL)
++ {
++ res = U2FH_MEMORY_ERROR;
++ goto out;
++ }
+ dev->devh = hid_open_path (cur_dev->path);
+ if (dev->devh != NULL)
+ {
+--
+2.32.0
+