From 1947f28a7094f34c0942dcdf7305fa2a86b38554 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 19 Sep 2024 13:16:18 +0200 Subject: [PATCH] [codec,fdk] fix use of strcat --- libfreerdp/codec/dsp_fdk_impl.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/libfreerdp/codec/dsp_fdk_impl.c b/libfreerdp/codec/dsp_fdk_impl.c index 7e139c800..7a7579034 100644 --- a/libfreerdp/codec/dsp_fdk_impl.c +++ b/libfreerdp/codec/dsp_fdk_impl.c @@ -210,16 +210,24 @@ static void log_enc_info(const AACENC_InfoStruct* info, fdk_log_fkt_t log) assert(info); assert(log); - strcat(confBuf, "{"); + size_t offset = 0; + size_t remain = sizeof(confBuf) - 1; + int rc = snprintf(confBuf, remain, "{"); + if (rc <= 0) + return; + offset += (size_t)rc; + for (size_t x = 0; x < 64; x++) { - char tmp[12] = { 0 }; - sprintf(tmp, "0x%02x", (int)info->confBuf[x]); - if (x > 0) - strcat(confBuf, ", "); - strcat(confBuf, tmp); + rc = snprintf(&confBuf[offset], remain - offset, "0x%02x%s", (int)info->confBuf[x], + (x > 0) ? ", " : ""); + if (rc <= 0) + return; } - strcat(confBuf, "}"); + + rc = snprintf(confBuf, remain - offset, "}"); + if (rc <= 0) + return; log(WLOG_DEBUG, "[encoder info] "