Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
poppler
poppler
Commits
5f52816b
Commit
5f52816b
authored
Jan 03, 2022
by
Albert Astals Cid
Browse files
Make FormFieldSignature::getCheckedSignature return an optional
parent
9f5e62f4
Pipeline
#477087
passed with stages
in 14 minutes and 18 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
poppler/Form.cc
View file @
5f52816b
...
...
@@ -5,7 +5,7 @@
// This file is licensed under the GPLv2 or later
//
// Copyright 2006-2008 Julien Rebetez <julienr@svn.gnome.org>
// Copyright 2007-2012, 2015-202
1
Albert Astals Cid <aacid@kde.org>
// Copyright 2007-2012, 2015-202
2
Albert Astals Cid <aacid@kde.org>
// Copyright 2007-2008, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright 2007, 2013, 2016, 2019 Adrian Johnson <ajohnson@redneon.com>
// Copyright 2007 Iñigo Martínez <inigomartinez@gmail.com>
...
...
@@ -815,7 +815,7 @@ std::vector<Goffset> FormWidgetSignature::getSignedRangeBounds() const
return
static_cast
<
FormFieldSignature
*>
(
field
)
->
getSignedRangeBounds
();
}
GooString
*
FormWidgetSignature
::
getCheckedSignature
(
Goffset
*
checkedFileSize
)
std
::
optional
<
GooString
>
FormWidgetSignature
::
getCheckedSignature
(
Goffset
*
checkedFileSize
)
{
return
static_cast
<
FormFieldSignature
*>
(
field
)
->
getCheckedSignature
(
checkedFileSize
);
}
...
...
@@ -2241,7 +2241,7 @@ std::vector<Goffset> FormFieldSignature::getSignedRangeBounds() const
return
range_vec
;
}
GooString
*
FormFieldSignature
::
getCheckedSignature
(
Goffset
*
checkedFileSize
)
std
::
optional
<
GooString
>
FormFieldSignature
::
getCheckedSignature
(
Goffset
*
checkedFileSize
)
{
Goffset
start
=
0
;
Goffset
end
=
0
;
...
...
@@ -2274,7 +2274,7 @@ GooString *FormFieldSignature::getCheckedSignature(Goffset *checkedFileSize)
do
{
c1
=
stream
->
getChar
();
if
(
c1
==
EOF
)
return
nullptr
;
return
{}
;
gstr
.
append
(
static_cast
<
char
>
(
c1
));
}
while
(
++
pos
<
len
);
if
(
gstr
.
getChar
(
0
)
==
'3'
&&
gstr
.
getChar
(
1
)
==
'0'
)
{
...
...
@@ -2329,12 +2329,12 @@ GooString *FormFieldSignature::getCheckedSignature(Goffset *checkedFileSize)
len
=
0
;
}
if
(
len
>
0
)
{
return
new
GooString
(
&
gstr
,
0
,
len
);
return
GooString
(
&
gstr
,
0
,
len
);
}
}
}
}
return
nullptr
;
return
{}
;
}
void
FormFieldSignature
::
print
(
int
indent
)
...
...
poppler/Form.h
View file @
5f52816b
...
...
@@ -6,7 +6,7 @@
//
// Copyright 2006 Julien Rebetez <julienr@svn.gnome.org>
// Copyright 2007, 2008, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright 2007-2010, 2012, 2015-202
1
Albert Astals Cid <aacid@kde.org>
// Copyright 2007-2010, 2012, 2015-202
2
Albert Astals Cid <aacid@kde.org>
// Copyright 2010 Mark Riedesel <mark@klowner.com>
// Copyright 2011 Pino Toscano <pino@kde.org>
// Copyright 2012 Fabio D'Urso <fabiodurso@hotmail.it>
...
...
@@ -38,6 +38,7 @@
#include
<ctime>
#include
<optional>
#include
<set>
#include
<vector>
...
...
@@ -316,7 +317,7 @@ public:
// checks the length encoding of the signature and returns the hex encoded signature
// if the check passed (and the checked file size as output parameter in checkedFileSize)
// otherwise a nullptr is returned
GooString
*
getCheckedSignature
(
Goffset
*
checkedFileSize
);
std
::
optional
<
GooString
>
getCheckedSignature
(
Goffset
*
checkedFileSize
);
const
GooString
*
getSignature
()
const
;
...
...
@@ -607,7 +608,7 @@ public:
// checks the length encoding of the signature and returns the hex encoded signature
// if the check passed (and the checked file size as output parameter in checkedFileSize)
// otherwise a nullptr is returned
GooString
*
getCheckedSignature
(
Goffset
*
checkedFileSize
);
std
::
optional
<
GooString
>
getCheckedSignature
(
Goffset
*
checkedFileSize
);
~
FormFieldSignature
()
override
;
Object
*
getByteRange
()
{
return
&
byte_range
;
}
...
...
qt5/src/poppler-form.cc
View file @
5f52816b
/* poppler-form.h: qt interface to poppler
* Copyright (C) 2007-2008, 2011, Pino Toscano <pino@kde.org>
* Copyright (C) 2008, 2011, 2012, 2015-202
1
Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2008, 2011, 2012, 2015-202
2
Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2011 Carlos Garcia Campos <carlosgc@gnome.org>
* Copyright (C) 2012, Adam Reichold <adamreichold@myopera.com>
* Copyright (C) 2016, Hanno Meyer-Thurow <h.mth@web.de>
...
...
@@ -1049,11 +1049,10 @@ SignatureValidationInfo FormFieldSignature::validate(int opt, const QDateTime &v
priv
->
range_bounds
.
append
(
bound
);
}
}
GooString
*
checkedSignature
=
fws
->
getCheckedSignature
(
&
priv
->
docLength
);
const
std
::
optional
<
GooString
>
checkedSignature
=
fws
->
getCheckedSignature
(
&
priv
->
docLength
);
if
(
priv
->
range_bounds
.
size
()
==
4
&&
checkedSignature
)
{
priv
->
signature
=
QByteArray
::
fromHex
(
checkedSignature
->
c_str
());
}
delete
checkedSignature
;
return
SignatureValidationInfo
(
priv
);
}
...
...
qt6/src/poppler-form.cc
View file @
5f52816b
/* poppler-form.h: qt interface to poppler
* Copyright (C) 2007-2008, 2011, Pino Toscano <pino@kde.org>
* Copyright (C) 2008, 2011, 2012, 2015-202
1
Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2008, 2011, 2012, 2015-202
2
Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2011 Carlos Garcia Campos <carlosgc@gnome.org>
* Copyright (C) 2012, Adam Reichold <adamreichold@myopera.com>
* Copyright (C) 2016, Hanno Meyer-Thurow <h.mth@web.de>
...
...
@@ -1049,11 +1049,10 @@ SignatureValidationInfo FormFieldSignature::validate(int opt, const QDateTime &v
priv
->
range_bounds
.
append
(
bound
);
}
}
GooString
*
checkedSignature
=
fws
->
getCheckedSignature
(
&
priv
->
docLength
);
const
std
::
optional
<
GooString
>
checkedSignature
=
fws
->
getCheckedSignature
(
&
priv
->
docLength
);
if
(
priv
->
range_bounds
.
size
()
==
4
&&
checkedSignature
)
{
priv
->
signature
=
QByteArray
::
fromHex
(
checkedSignature
->
c_str
());
}
delete
checkedSignature
;
return
SignatureValidationInfo
(
priv
);
}
...
...
utils/pdfsig.cc
View file @
5f52816b
...
...
@@ -375,9 +375,8 @@ int main(int argc, char *argv[])
FormFieldSignature
*
ffs
=
signatures
.
at
(
signatureNumber
-
1
);
Goffset
file_size
=
0
;
GooString
*
sig
=
ffs
->
getCheckedSignature
(
&
file_size
);
const
std
::
optional
<
GooString
>
sig
=
ffs
->
getCheckedSignature
(
&
file_size
);
if
(
sig
)
{
delete
sig
;
printf
(
"Signature number %d is already signed
\n
"
,
signatureNumber
);
return
2
;
}
...
...
@@ -468,13 +467,12 @@ int main(int argc, char *argv[])
if
(
ranges
.
size
()
==
4
)
{
printf
(
" - Signed Ranges: [%lld - %lld], [%lld - %lld]
\n
"
,
ranges
[
0
],
ranges
[
1
],
ranges
[
2
],
ranges
[
3
]);
Goffset
checked_file_size
;
GooString
*
signature
=
signatures
.
at
(
i
)
->
getCheckedSignature
(
&
checked_file_size
);
const
std
::
optional
<
GooString
>
signature
=
signatures
.
at
(
i
)
->
getCheckedSignature
(
&
checked_file_size
);
if
(
signature
&&
checked_file_size
==
ranges
[
3
])
{
printf
(
" - Total document signed
\n
"
);
}
else
{
printf
(
" - Not total document signed
\n
"
);
}
delete
signature
;
}
printf
(
" - Signature Validation: %s
\n
"
,
getReadableSigState
(
sig_info
->
getSignatureValStatus
()));
gfree
(
time_str
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment