From 2a204508ce9551525ab4671cd7cdffdb1fd649d9 Mon Sep 17 00:00:00 2001
From: "Ruslan (The BadAss SysMan) Laishev" <ruslan.laishev@demlabs.net>
Date: Thu, 10 Nov 2022 12:48:53 +0300
Subject: [PATCH] [*] Sign/unsign comparison fix

---
 dap-sdk/core/src/dap_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/dap-sdk/core/src/dap_common.c b/dap-sdk/core/src/dap_common.c
index 4a703a57e5..62264d0bd5 100755
--- a/dap-sdk/core/src/dap_common.c
+++ b/dap-sdk/core/src/dap_common.c
@@ -457,7 +457,7 @@ void	_log_it_ext   (
 va_list arglist;
 const char	lfmt [] = {"%02u-%02u-%04u %02u:%02u:%02u.%03u  "  PID_FMT "  %s [%s:%u] "};
 char	out[1024] = {0};
-int     olen, len;
+size_t     olen, len;
 struct tm _tm;
 struct timespec now;
 
@@ -469,7 +469,7 @@ struct timespec now;
 	localtime_r((time_t *)&now, &_tm);
 #endif
 
-	olen = snprintf (out, sizeof(out), lfmt, _tm.tm_mday, _tm.tm_mon + 1, 1900 + _tm.tm_year,
+	olen = snprintf (out, sizeof(out) - 1, lfmt, _tm.tm_mday, _tm.tm_mon + 1, 1900 + _tm.tm_year,
 			_tm.tm_hour, _tm.tm_min, _tm.tm_sec, (unsigned) now.tv_nsec/(1024*1024),
             dap_gettid(), s_log_level_tag[a_ll], a_rtn_name, a_line_no);
 
@@ -484,7 +484,7 @@ struct timespec now;
 	** Format variable part of string line
 	*/
 	va_start (arglist, a_fmt);
-	olen += vsnprintf(out + olen, sizeof(out) - olen, a_fmt, arglist);
+	olen += vsnprintf(out + olen, sizeof(out) - olen - 1, a_fmt, arglist);
 	va_end (arglist);
 
 	olen = MIN(olen, sizeof(out) - 1);
-- 
GitLab