tests: Add safeguards against nullptr deref
* t-gpgconf.c (main): Test some values before dereferencing them.
This commit is contained in:
parent
abfd241d1a
commit
ca69df8c8d
@ -309,9 +309,10 @@ main (void)
|
|||||||
fail_if_err (err);
|
fail_if_err (err);
|
||||||
if (lookup (conf, "dirmngr", "verbose", &comp, &opt))
|
if (lookup (conf, "dirmngr", "verbose", &comp, &opt))
|
||||||
{
|
{
|
||||||
/* Found. */
|
/* Found. */
|
||||||
test (opt->alt_type == GPGME_CONF_NONE);
|
test (opt->alt_type == GPGME_CONF_NONE);
|
||||||
test ((unsigned long) opt->value->value.count == count);
|
test (opt->value);
|
||||||
|
test ((unsigned long) opt->value->value.count == count);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, ".");
|
fprintf (stderr, ".");
|
||||||
@ -350,9 +351,11 @@ main (void)
|
|||||||
fail_if_err (err);
|
fail_if_err (err);
|
||||||
if (lookup (conf, "gpg", "keyserver", &comp, &opt))
|
if (lookup (conf, "gpg", "keyserver", &comp, &opt))
|
||||||
{
|
{
|
||||||
/* Found. */
|
/* Found. */
|
||||||
test (opt->alt_type == GPGME_CONF_STRING);
|
test (opt->alt_type == GPGME_CONF_STRING);
|
||||||
test (strcmp (opt->value->value.string, values[i%2]) == 0);
|
test (opt->value);
|
||||||
|
test (opt->value->value.string);
|
||||||
|
test (strcmp (opt->value->value.string, values[i%2]) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, ".");
|
fprintf (stderr, ".");
|
||||||
|
Loading…
Reference in New Issue
Block a user