| 1 |
// unlha.cpp: a simple LZH decompressing program |
// unlha.cpp: a simple LZH decompressing program |
| 2 |
|
|
| 3 |
// Copyright Takeshi Mouri 2006-2008. |
// Copyright Takeshi Mouri 2006-2018. |
| 4 |
// Distributed under the Boost Software License, Version 1.0. |
// Distributed under the Boost Software License, Version 1.0. |
| 5 |
// (See accompanying file LICENSE_1_0.txt or copy at |
// (See accompanying file LICENSE_1_0.txt or copy at |
| 6 |
// http://www.boost.org/LICENSE_1_0.txt) |
// http://www.boost.org/LICENSE_1_0.txt) |
| 38 |
#endif |
#endif |
| 39 |
} |
} |
| 40 |
|
|
| 41 |
|
template<class Path> |
| 42 |
|
bool is_valid_path(const Path& ph) |
| 43 |
|
{ |
| 44 |
|
#if !defined(HAMIGAKI_ALLOW_DIRECTORY_TRAVERSAL) |
| 45 |
|
if (ph.has_root_name() || ph.has_root_directory()) |
| 46 |
|
return false; |
| 47 |
|
for (typename Path::iterator it = ph.begin(); it != ph.end(); ++it) |
| 48 |
|
{ |
| 49 |
|
if (*it == "..") |
| 50 |
|
return false; |
| 51 |
|
} |
| 52 |
|
#endif |
| 53 |
|
return true; |
| 54 |
|
} |
| 55 |
|
|
| 56 |
inline fs_ex::timestamp make_timestamp(boost::uint64_t ft) |
inline fs_ex::timestamp make_timestamp(boost::uint64_t ft) |
| 57 |
{ |
{ |
| 58 |
return fs_ex::timestamp::from_windows_file_time(ft); |
return fs_ex::timestamp::from_windows_file_time(ft); |
| 77 |
const ar::lha::header& head = lzh.header(); |
const ar::lha::header& head = lzh.header(); |
| 78 |
|
|
| 79 |
std::cout << head.path.string() << '\n'; |
std::cout << head.path.string() << '\n'; |
| 80 |
|
if (!is_valid_path(head.path)) |
| 81 |
|
{ |
| 82 |
|
std::cerr << "Warning: invalid path" << '\n'; |
| 83 |
|
continue; |
| 84 |
|
} |
| 85 |
|
|
| 86 |
if (!head.link_path.empty()) |
if (!head.link_path.empty()) |
| 87 |
{ |
{ |