Skip to content

Commit a01d542

Browse files
fix: prevent overflow in ail path processing
Related-To: NEO-15630 Signed-off-by: Jakub Nowacki <jakub.nowacki@intel.com>
1 parent 0f753a9 commit a01d542

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

shared/source/ail/windows/ail_configuration_windows.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
2-
* Copyright (C) 2021-2022 Intel Corporation
2+
* Copyright (C) 2021-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#include "shared/source/ail/ail_configuration.h"
9+
#include "shared/source/helpers/debug_helpers.h"
910
#include "shared/source/os_interface/windows/sys_calls.h"
1011

1112
// Application detection is performed using the process name of the given application.
@@ -21,6 +22,7 @@ bool AILConfiguration::initProcessExecutableName() {
2122
std::wstring_view pathView(processFilenameW);
2223

2324
auto lastPosition = pathView.find_last_of(L"\\");
25+
UNRECOVERABLE_IF(lastPosition == std::wstring_view::npos);
2426

2527
pathView.remove_prefix(lastPosition + 1u);
2628

shared/test/common/os_interface/windows/sys_calls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ DWORD getLastErrorResult = 0u;
3434
bool isShutdownInProgressRetVal = false;
3535
BOOL systemPowerStatusRetVal = 1;
3636
BYTE systemPowerStatusACLineStatusOverride = 1;
37-
const wchar_t *currentLibraryPath = L"";
37+
const wchar_t *currentLibraryPath = L"\\";
3838
uint32_t regOpenKeySuccessCount = 0u;
3939
uint32_t regQueryValueSuccessCount = 0u;
4040
uint64_t regQueryValueExpectedData = 0ull;

shared/test/unit_test/ail/linux/ail_linux_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2022 Intel Corporation
2+
* Copyright (C) 2021-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -16,13 +16,13 @@ namespace SysCalls {
1616
extern bool isInvalidAILTest;
1717
}
1818

19-
HWTEST2_F(AILTests, givenValidPathWhenAILinitProcessExecutableNameThenSuccessIsReturned, IsDG1) {
19+
HWTEST2_F(AILTests, givenValidPathWhenAILinitProcessExecutableNameThenSuccessIsReturned, MatchAny) {
2020
AILConfigurationHw<productFamily> ail;
2121

2222
EXPECT_EQ(ail.initProcessExecutableName(), true);
2323
}
2424

25-
HWTEST2_F(AILTests, givenInvalidPathWhenAILinitProcessExecutableNameThenFailIsReturned, IsDG1) {
25+
HWTEST2_F(AILTests, givenInvalidPathWhenAILinitProcessExecutableNameThenFailIsReturned, MatchAny) {
2626
VariableBackup<bool> isAILTestBackup(&SysCalls::isInvalidAILTest);
2727
SysCalls::isInvalidAILTest = true;
2828

0 commit comments

Comments
 (0)