From 95dace2eb1ae7ce2fc000cc67e134b7bfadf2c35 Mon Sep 17 00:00:00 2001 From: Adam Seskunas Date: Thu, 8 Feb 2024 21:41:13 -0800 Subject: [PATCH] tdf#154285 Check upper bound of arguments in SbRtl_CurDir The LibreOffice Basic specification says CurDir should accept one argument and in the case of a non-Windows system, ignore that argument and simply return the current directory. So check that SbRtl_CurDir accepts a maximum of two arguments. Change-Id: Ia60114fac31aa4261c8251e26ef172a0370e6abc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163150 Reviewed-by: Mike Kaganski Tested-by: Jenkins --- basic/source/runtime/methods.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index d58a2cef9ee0..34d959669747 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -371,6 +371,9 @@ void SbRtl_CurDir(StarBASIC *, SbxArray & rPar, bool) // there's no possibility to detect the current one in a way that a virtual URL // could be delivered. + if (rPar.Count() > 2) + return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); + #if defined(_WIN32) int nCurDir = 0; // Current dir // JSM if (rPar.Count() == 2)