chantra / rpms / tpm2-tss

Forked from rpms/tpm2-tss 2 years ago
Clone

Blame SOURCES/0001-tcti-device-getPollHandles-should-allow-num_handles-.patch

28cd4a
From c42450a294c4267998aa16a477e9218ee5953aa9 Mon Sep 17 00:00:00 2001
28cd4a
From: Jeffrey Ferreira <jeffpferreira@gmail.com>
28cd4a
Date: Thu, 19 Sep 2019 13:32:00 -0700
28cd4a
Subject: [PATCH] tcti-device: getPollHandles should allow num_handles query
28cd4a
28cd4a
Signed-off-by: Jeffrey Ferreira <jeffpferreira@gmail.com>
28cd4a
---
28cd4a
 src/tss2-tcti/tcti-device.c | 11 +++++++++--
28cd4a
 1 file changed, 9 insertions(+), 2 deletions(-)
28cd4a
28cd4a
diff --git a/src/tss2-tcti/tcti-device.c b/src/tss2-tcti/tcti-device.c
28cd4a
index 44c9fe2083d5..53a698cad061 100644
28cd4a
--- a/src/tss2-tcti/tcti-device.c
28cd4a
+++ b/src/tss2-tcti/tcti-device.c
28cd4a
@@ -368,12 +368,19 @@ tcti_device_get_poll_handles (
28cd4a
         return TSS2_TCTI_RC_BAD_CONTEXT;
28cd4a
     }
28cd4a
 
28cd4a
-    if (handles == NULL || num_handles == NULL) {
28cd4a
+    if (num_handles == NULL) {
28cd4a
         return TSS2_TCTI_RC_BAD_REFERENCE;
28cd4a
     }
28cd4a
 
28cd4a
+    if (handles != NULL && *num_handles < 1) {
28cd4a
+        return TSS2_TCTI_RC_INSUFFICIENT_BUFFER;
28cd4a
+    }
28cd4a
+
28cd4a
     *num_handles = 1;
28cd4a
-    handles->fd = tcti_dev->fd;
28cd4a
+    if (handles != NULL) {
28cd4a
+        handles->fd = tcti_dev->fd;
28cd4a
+    }
28cd4a
+
28cd4a
     return TSS2_RC_SUCCESS;
28cd4a
 #else
28cd4a
     (void)(tctiContext);
28cd4a
-- 
28cd4a
2.27.0
28cd4a