| 309 | } |
| 310 | |
| 311 | BOOL ShellCache::IsContextPathAllowed(const std::wstring& path) |
| 312 | { |
| 313 | Locker lock(m_critSec); |
| 314 | ExcludeContextValid(); |
| 315 | for (const auto& exPath : excontextvector) |
| 316 | { |
| 317 | if (exPath.empty()) |
| 318 | continue; |
| 319 | const size_t filterlen = exPath.size(); |
| 320 | const wchar_t last_character = exPath.at(filterlen - 1); |
| 321 | if (last_character == L'*') |
| 322 | { |
| 323 | if (_wcsnicmp(exPath.c_str(), path.c_str(), filterlen - 1) == 0) |
| 324 | return FALSE; |
| 325 | } |
| 326 | else if (last_character == L'\\') |
| 327 | { |
| 328 | if (path.length() < filterlen - 1) |
| 329 | // path is a parent of the current filter. Don't filter |
| 330 | continue; |
| 331 | |
| 332 | if (path.length() == filterlen - 1) |
| 333 | { |
| 334 | // path MAY be the filtered path without trailing backslash. |
| 335 | // compare with the filter excluding trailing backslash! |
| 336 | if (_wcsnicmp(exPath.c_str(), path.c_str(), filterlen - 1) == 0) |
| 337 | return FALSE; |
| 338 | } |
| 339 | else |
| 340 | { |
| 341 | // path is at least as large as the filter. compare with the whole filter! |
| 342 | if (_wcsnicmp(exPath.c_str(), path.c_str(), filterlen) == 0) |
| 343 | return FALSE; |
| 344 | } |
| 345 | } |
| 346 | else if (_wcsicmp(exPath.c_str(), path.c_str()) == 0) |
| 347 | return FALSE; |
| 348 | } |
| 349 | return TRUE; |
| 350 | } |
| 351 | |
| 352 | BOOL ShellCache::IsPathAllowed(LPCWSTR path) |
| 353 | { |
no test coverage detected