2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-05 11:50:53 +00:00

fix bug in C API, test invalid password specifically

git-svn-id: svn+q:///qpdf/trunk@832 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
Jay Berkenbilt 2009-10-20 00:59:38 +00:00
parent 8b073eed28
commit ad0ab25d66
5 changed files with 26 additions and 8 deletions

5
TODO
View File

@ -16,11 +16,6 @@
* Add comments for the security functions that map them back to the
items in Adobe's products.
* Change the C error interface so that warnings and errors are
pointers that can be queried using more C API functions. We need a
way to get a full string as well as an error code, file name,
offset, and message.
* "Delphi wrapper unit 'qpdf.pas' created by Zarko Gajic
(http://delphi.about.com). .. use at your own risk and for whatever
the purpose you want .. no support provided. Sample code provided."

View File

@ -51,7 +51,7 @@ static void call_read(qpdf_data qpdf)
}
// must set qpdf->filename
static void call_init_write(qpdf_data qpdf)
void call_init_write(qpdf_data qpdf)
{
qpdf->qpdf_writer = new QPDFWriter(*(qpdf->qpdf), qpdf->filename);
}
@ -76,10 +76,12 @@ static QPDF_ERROR_CODE trap_errors(qpdf_data qpdf, void (*fn)(qpdf_data))
catch (std::runtime_error& e)
{
qpdf->error = new QPDFExc(qpdf_e_system, "", "", 0, e.what());
status |= QPDF_ERRORS;
}
catch (std::exception& e)
{
qpdf->error = new QPDFExc(qpdf_e_internal, "", "", 0, e.what());
status |= QPDF_ERRORS;
}
if (qpdf_more_warnings(qpdf))

View File

@ -830,7 +830,7 @@ my @encrypted_files =
['long-password', 'asdf asdf asdf asdf asdf asdf qwer'],
['long-password', 'asdf asdf asdf asdf asdf asdf qw']);
$n_tests += 3 + (2 * (@encrypted_files)) + (6 * (@encrypted_files - 3)) + 8;
$n_tests += 3 + (2 * (@encrypted_files)) + (6 * (@encrypted_files - 3)) + 0;
$td->runtest("encrypted file",
{$td->COMMAND => "test_driver 2 U25A0.pdf"},
@ -952,6 +952,10 @@ $td->runtest("invalid password",
{$td->STRING => "enc-R2,V1,U=view.pdf: invalid password\n",
$td->EXIT_STATUS => 2},
$td->NORMALIZE_NEWLINES);
$td->runtest("C API: invalid password",
{$td->COMMAND => "qpdf-ctest 2 enc-R2,V1,U=view.pdf '' a.qdf"},
{$td->FILE => "c-invalid-password.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
my @cenc = (
[11, 'hybrid-xref.pdf', "''", 'r2', ""],

View File

@ -0,0 +1,5 @@
error: enc-R2,V1,U=view.pdf: invalid password
code: 4
file: enc-R2,V1,U=view.pdf
pos : 0
text: invalid password

View File

@ -1,3 +1,15 @@
warning: append-page-content-damaged.pdf: file is damaged
code: 5
file: append-page-content-damaged.pdf
pos : 0
text: file is damaged
warning: append-page-content-damaged.pdf: can't find startxref
warning: Attempting to reconstruct cross-reference table
code: 5
file: append-page-content-damaged.pdf
pos : 0
text: can't find startxref
warning: append-page-content-damaged.pdf: Attempting to reconstruct cross-reference table
code: 5
file: append-page-content-damaged.pdf
pos : 0
text: Attempting to reconstruct cross-reference table