diff --git a/src/tss2-tcti/tctildr-dl.c b/src/tss2-tcti/tctildr-dl.c index 622637dce..363d32b66 100644 --- a/src/tss2-tcti/tctildr-dl.c +++ b/src/tss2-tcti/tctildr-dl.c @@ -202,7 +202,14 @@ get_info_default(const TSS2_TCTI_INFO **info, return TSS2_TCTI_RC_IO_ERROR; #else size_t i; + if (ARRAY_SIZE(tctis) == 0) { + LOG_ERROR("No default TCTIs configured during compilation"); + return TSS2_TCTI_RC_IO_ERROR; + } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" for (i = 0; i < ARRAY_SIZE(tctis); i++) { +#pragma GCC diagnostic pop name = tctis[i].file; LOG_DEBUG("name: %s", name); if (name == NULL) { @@ -256,7 +263,14 @@ tctildr_get_default(TSS2_TCTI_CONTEXT ** tcticontext, void **dlhandle) TSS2_RC r; size_t i; + if (ARRAY_SIZE(tctis) == 0) { + LOG_ERROR("No default TCTIs configured during compilation"); + return TSS2_TCTI_RC_IO_ERROR; + } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" for (i = 0; i < ARRAY_SIZE(tctis); i++) { +#pragma GCC diagnostic pop LOG_DEBUG("Attempting to connect using standard TCTI: %s", tctis[i].description); r = tcti_from_file(tctis[i].file, tctis[i].conf, tcticontext, diff --git a/src/tss2-tcti/tctildr-nodl.c b/src/tss2-tcti/tctildr-nodl.c index 7489b542a..32cd8b3b5 100644 --- a/src/tss2-tcti/tctildr-nodl.c +++ b/src/tss2-tcti/tctildr-nodl.c @@ -137,7 +137,14 @@ tctildr_get_default(TSS2_TCTI_CONTEXT ** tcticontext, void **dlhandle) } *tcticontext = NULL; + if (ARRAY_SIZE(tctis) == 0) { + LOG_ERROR("No default TCTIs configured during compilation"); + return TSS2_TCTI_RC_IO_ERROR; + } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" for (size_t i = 0; i < ARRAY_SIZE(tctis); i++) { +#pragma GCC diagnostic pop LOG_DEBUG("Attempting to connect using standard TCTI: %s", tctis[i].description); rc = tcti_from_init (tctis[i].init, @@ -168,7 +175,14 @@ tctildr_get_tcti (const char *name, return tctildr_get_default (tcti, data); } + if (ARRAY_SIZE(tctis) == 0) { + LOG_ERROR("No default TCTIs configured during compilation"); + return TSS2_TCTI_RC_IO_ERROR; + } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" for (size_t i = 0; i < ARRAY_SIZE(tctis); ++i) { +#pragma GCC diagnostic pop for (size_t j = 0; j < NAME_ARRAY_SIZE; ++j) { if (strcmp (name, tctis[i].names[j])) continue; diff --git a/src/tss2-tcti/tctildr.c b/src/tss2-tcti/tctildr.c index 96b11c70f..3deecc4aa 100644 --- a/src/tss2-tcti/tctildr.c +++ b/src/tss2-tcti/tctildr.c @@ -39,6 +39,9 @@ static char *strndup(const char* s, size_t n) #endif #else #include +#ifndef PATH_MAX +#define PATH_MAX 256 +#endif #endif #include #include