always set length of arrays in pe signatures
Instead of leaving the length fields undefined if the arrays are empty,
set them to 0. This is related to and other such changes, where
getting an undefined value when checking a length parameter is
unexpected.
@@ -1693,14 +1693,14 @@ void _process_authenticode(
yr_free(digest_ascii);
}
- if (authenticode->certs)
- {
yr_set_integer(
- authenticode->certs->count,
+ authenticode->certs ? authenticode->certs->count : 0,
pe->object,
"signatures[%i].number_of_certificates",
*sig_count);
+ if (authenticode->certs)
+ {
for (int k = 0; k < authenticode->certs->count; ++k)
{
write_certificate(
@@ -1748,14 +1748,14 @@ void _process_authenticode(
yr_free(digest_ascii);
}
- if (signer->chain)
- {
yr_set_integer(
- signer->chain->count,
+ signer->chain ? signer->chain->count : 0,
pe->object,
"signatures[%i].signer_info.length_of_chain",
*sig_count);
+ if (signer->chain)
+ {
for (int k = 0; k < signer->chain->count; ++k)
{
write_certificate(
@@ -1767,14 +1767,15 @@ void _process_authenticode(
}
}
}
- if (authenticode->countersigs)
- {
+
yr_set_integer(
- authenticode->countersigs->count,
+ authenticode->countersigs ? authenticode->countersigs->count : 0,
pe->object,
"signatures[%i].number_of_countersignatures",
*sig_count);
+ if (authenticode->countersigs)
+ {
for (int j = 0; j < authenticode->countersigs->count; ++j)
{
const Countersignature* counter =
@@ -1814,15 +1815,15 @@ void _process_authenticode(
yr_free(digest_ascii);
}
- if (counter->chain)
- {
yr_set_integer(
- counter->chain->count,
+ counter->chain ? counter->chain->count : 0,
pe->object,
"signatures[%i].countersignatures[%i].length_of_chain",
*sig_count,
j);
+ if (counter->chain)
+ {
for (int k = 0; k < counter->chain->count; ++k)
{
write_certificate(
