mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Handle --encrypt -- without crashing
This commit is contained in:
parent
a2c4a2b12a
commit
1f45686843
@ -163,6 +163,7 @@ ArgParser::argShowCrypto()
|
|||||||
void
|
void
|
||||||
ArgParser::argEncrypt()
|
ArgParser::argEncrypt()
|
||||||
{
|
{
|
||||||
|
this->c_enc = c_main->encrypt(0, "", "");
|
||||||
this->accumulated_args.clear();
|
this->accumulated_args.clear();
|
||||||
this->ap.selectOptionTable(O_ENCRYPTION);
|
this->ap.selectOptionTable(O_ENCRYPTION);
|
||||||
}
|
}
|
||||||
|
@ -1042,6 +1042,9 @@ QPDFJob::EncConfig::EncConfig(Config* c) :
|
|||||||
QPDFJob::Config*
|
QPDFJob::Config*
|
||||||
QPDFJob::EncConfig::endEncrypt()
|
QPDFJob::EncConfig::endEncrypt()
|
||||||
{
|
{
|
||||||
|
if (config->o.m->keylen == 0) {
|
||||||
|
usage("encryption key length is required");
|
||||||
|
}
|
||||||
config->o.m->encrypt = true;
|
config->o.m->encrypt = true;
|
||||||
config->o.m->decrypt = false;
|
config->o.m->decrypt = false;
|
||||||
config->o.m->copy_encryption = false;
|
config->o.m->copy_encryption = false;
|
||||||
|
@ -15,7 +15,7 @@ cleanup();
|
|||||||
|
|
||||||
my $td = new TestDriver('arg-parsing');
|
my $td = new TestDriver('arg-parsing');
|
||||||
|
|
||||||
my $n_tests = 21;
|
my $n_tests = 22;
|
||||||
|
|
||||||
$td->runtest("required argument",
|
$td->runtest("required argument",
|
||||||
{$td->COMMAND => "qpdf --password minimal.pdf"},
|
{$td->COMMAND => "qpdf --password minimal.pdf"},
|
||||||
@ -107,6 +107,11 @@ $td->runtest("empty and replace-input",
|
|||||||
{$td->REGEXP => ".*--replace-input may not be used with --empty.*",
|
{$td->REGEXP => ".*--replace-input may not be used with --empty.*",
|
||||||
$td->EXIT_STATUS => 2},
|
$td->EXIT_STATUS => 2},
|
||||||
$td->NORMALIZE_NEWLINES);
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
$td->runtest("missing key length",
|
||||||
|
{$td->COMMAND => "qpdf --encrypt --"},
|
||||||
|
{$td->REGEXP => ".*encryption key length is required",
|
||||||
|
$td->EXIT_STATUS => 2},
|
||||||
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
|
||||||
# Disallow mixing positional and flag-style encryption arguments.
|
# Disallow mixing positional and flag-style encryption arguments.
|
||||||
my @bad_enc = (
|
my @bad_enc = (
|
||||||
|
Loading…
Reference in New Issue
Block a user