| 1 |
// uniso.cpp: a simple ISO image extractor program |
// uniso.cpp: a simple ISO image extractor program |
| 2 |
|
|
| 3 |
// Copyright Takeshi Mouri 2007, 2008. |
// Copyright Takeshi Mouri 2007, 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 |
int main(int argc, char* argv[]) |
int main(int argc, char* argv[]) |
| 57 |
{ |
{ |
| 58 |
try |
try |
| 92 |
const ar::iso::header& head = iso.header(); |
const ar::iso::header& head = iso.header(); |
| 93 |
|
|
| 94 |
std::cout << head.path.string() << '\n'; |
std::cout << head.path.string() << '\n'; |
| 95 |
|
if (!is_valid_path(head.path)) |
| 96 |
|
{ |
| 97 |
|
std::cerr << "Warning: invalid path" << '\n'; |
| 98 |
|
continue; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
if (head.is_symlink()) |
if (head.is_symlink()) |
| 102 |
std::cout << "-> " << head.link_path.string() << '\n'; |
std::cout << "-> " << head.link_path.string() << '\n'; |