Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Don't allow extraction of tar files outside of the target directory, …
…added tar tests
- Loading branch information
Showing
21 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| --extract test.tar |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Tar path points outside of the extraction directory: ./../hello.txt |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| --extract test.tar.bz2 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| hello.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| --extract test.tar |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| hello.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Import('*') | ||
|
|
||
| # Local includes | ||
| env.Append(CPPPATH = ['#']) | ||
|
|
||
| prog = env.Program('tar', 'tar.cpp') | ||
|
|
||
| Return('prog') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /******************************************************************************\ | ||
| This file is part of the C! library. A.K.A the cbang library. | ||
| Copyright (c) 2003-2019, Cauldron Development LLC | ||
| Copyright (c) 2003-2017, Stanford University | ||
| All rights reserved. | ||
| The C! library is free software: you can redistribute it and/or | ||
| modify it under the terms of the GNU Lesser General Public License | ||
| as published by the Free Software Foundation, either version 2.1 of | ||
| the License, or (at your option) any later version. | ||
| The C! library is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| Lesser General Public License for more details. | ||
| You should have received a copy of the GNU Lesser General Public | ||
| License along with the C! library. If not, see | ||
| <http://www.gnu.org/licenses/>. | ||
| In addition, BSD licensing may be granted on a case by case basis | ||
| by written permission from at least one of the copyright holders. | ||
| You may request written permission by emailing the authors. | ||
| For information regarding this software email: | ||
| Joseph Coffland | ||
| joseph@cauldrondevelopment.com | ||
| \******************************************************************************/ | ||
|
|
||
| #include <cbang/tar/TarFileReader.h> | ||
| #include <cbang/Catch.h> | ||
|
|
||
| #include <iostream> | ||
|
|
||
| using namespace cb; | ||
| using namespace std; | ||
|
|
||
|
|
||
| int main(int argc, char *argv[]) { | ||
| try { | ||
| for (int i = 1; i < argc; i++) { | ||
| string arg = argv[i]; | ||
|
|
||
| if (arg == "--extract" && i < argc - 1) { | ||
| TarFileReader reader(argv[++i]); | ||
|
|
||
| while (reader.hasMore()) | ||
| cout << reader.extract() << endl; | ||
|
|
||
| } else THROWS("Invalid arg '" << arg << "'"); | ||
| } | ||
|
|
||
| return 0; | ||
|
|
||
| } catch (const Exception &e) {cerr << e.getMessage();} | ||
|
|
||
| return 1; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "command": "%(suite-dir)s/tar" | ||
| } |