| 486 | } |
| 487 | |
| 488 | const WCHAR * // get decrypted path (used only in reverse mode) |
| 489 | decrypt_path(CryptContext *con, const WCHAR *path, wstring& storage) |
| 490 | { |
| 491 | const WCHAR *rval = NULL; |
| 492 | |
| 493 | HANDLE hFind = NULL; |
| 494 | |
| 495 | CryptConfig *config = con->GetConfig(); |
| 496 | |
| 497 | bool done = false; |
| 498 | |
| 499 | try { |
| 500 | |
| 501 | if (!config->m_reverse) |
| 502 | throw(-1); |
| 503 | |
| 504 | storage = config->GetBaseDir(); |
| 505 | |
| 506 | if (config->m_PlaintextNames || (path[0] == '\\' && path[1] == '\0')) { |
| 507 | |
| 508 | storage += path; |
| 509 | |
| 510 | } else { |
| 511 | |
| 512 | KeyDecryptor kdc(&config->m_keybuf_manager); |
| 513 | |
| 514 | // we can short-circuit the process in the case where the final file or dir is a long file name |
| 515 | // and it is found in the long file name (lfn) cache |
| 516 | |
| 517 | const WCHAR *last_elem = wcsrchr(path, '\\'); |
| 518 | |
| 519 | if (last_elem) { |
| 520 | last_elem++; |
| 521 | if (is_long_name(last_elem)) { |
| 522 | wstring base64_hash; |
| 523 | if (!extract_lfn_base64_hash(&last_elem[0], base64_hash)) { |
| 524 | throw(-1); |
| 525 | } |
| 526 | wstring lfn_path; |
| 527 | if (con->m_lfn_cache.lookup(&base64_hash[0], &storage, NULL)) { |
| 528 | done = true; |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | |
| 534 | |
| 535 | if (!done) { |
| 536 | |
| 537 | wstring diriv_path = L""; |
| 538 | |
| 539 | if (*path && path[0] == '\\') { |
| 540 | storage.push_back('\\'); |
| 541 | path++; |
| 542 | } |
| 543 | |
| 544 | const TCHAR *p = path; |
| 545 |
no test coverage detected