From 2084d287e56d1e7896b2800b121c48a6fb70c3be Mon Sep 17 00:00:00 2001 From: Maxime Gervais Date: Wed, 8 Jan 2025 15:58:19 +0100 Subject: [PATCH] Fix runtime error with hardened libc Signed-off-by: Maxime Gervais --- Source/ThirdParty/ccdecoder/ccdecoder_subrip.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/ThirdParty/ccdecoder/ccdecoder_subrip.c b/Source/ThirdParty/ccdecoder/ccdecoder_subrip.c index 9033c45f5..9c25f38a8 100644 --- a/Source/ThirdParty/ccdecoder/ccdecoder_subrip.c +++ b/Source/ThirdParty/ccdecoder/ccdecoder_subrip.c @@ -54,8 +54,11 @@ void to_timestamp(double Value_Double, wchar_t Result[20]) /* Hours */ Hours=value/(60*60*1000); - if (Hours>=1000) - return; /* Not supported */ + if (Hours>=1000) /* Not supported */ + { + memcpy(Result, L"??:??:??.???", 13*sizeof(wchar_t)); + return; + } if (Hours>=100) { Result[pos]=L'0'+(wchar_t)Hours/100; @@ -160,7 +163,7 @@ wchar_t* ccdecoder_subrip_parse(ccdecoder_subrip_handle* handle, ccdecoder_capti to_timestamp(priv->pts, pts_In); to_timestamp(pts, pts_Out); swprintf(ToReturn_Current, ToReturn_size, L"%i\n", (int)priv->Number); ToReturn_Current+=wcslen(ToReturn_Current); - swprintf(ToReturn_Current, ToReturn_size, L"%ls --> %ls\n", pts_In, pts_Out); ToReturn_Current+=wcslen(ToReturn_Current); + swprintf(ToReturn_Current, ToReturn_size-(ToReturn_Current-ToReturn), L"%ls --> %ls\n", pts_In, pts_Out); ToReturn_Current+=wcslen(ToReturn_Current); for (Output_Y=0; priv->Characters[Output_Y][0].value; Output_Y++) { uint8_t attributes=ccdecoder_noattribute;