package: prevent creating a package that contains itself.
Fixes #10117. Change-Id: I4be59189a47dd0ad400fe46786d7058be4ed6d3f Reviewed-on: https://review.haiku-os.org/c/haiku/+/2778 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
984492f14a
commit
82817fee45
@@ -14,6 +14,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
#include <Path.h>
|
||||||
|
|
||||||
#include <package/PackageInfo.h>
|
#include <package/PackageInfo.h>
|
||||||
#include <package/hpkg/HPKGDefs.h>
|
#include <package/hpkg/HPKGDefs.h>
|
||||||
@@ -120,6 +121,18 @@ command_create(int argc, const char* const* argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BPath outputPath(packageFileName, NULL, true);
|
||||||
|
BPath inputPath(changeToDirectory, NULL, true);
|
||||||
|
BPath parent;
|
||||||
|
while (outputPath.GetParent(&parent) == B_OK) {
|
||||||
|
if (outputPath == inputPath) {
|
||||||
|
fprintf(stderr, "Error: output package can't be in the same "
|
||||||
|
"directory as input files.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
outputPath = parent;
|
||||||
|
}
|
||||||
|
|
||||||
// create package
|
// create package
|
||||||
BPackageWriterParameters writerParameters;
|
BPackageWriterParameters writerParameters;
|
||||||
writerParameters.SetCompressionLevel(compressionLevel);
|
writerParameters.SetCompressionLevel(compressionLevel);
|
||||||
|
|||||||
Reference in New Issue
Block a user