1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

common: Do not deref vars in tests after a fail().

* common/t-convert.c (test_bin2hex): Turn if conditions into if-else
chains to avoid accessing unchecked data.
(test_bin2hexcolon): Ditto.
* common/t-mapstrings.c (test_map_static_macro_string): Ditto.
* common/t-stringhelp.c (test_percent_escape): Ditto.
(test_make_filename_try): Ditto.
(test_make_absfilename_try): Ditto.
* common/t-timestuff.c (test_timegm): Ditto.
--

Note that these dereference only occur after failed regression tests.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-01-06 08:31:38 +01:00
parent e70f7a54f2
commit 0a00115ee2
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
4 changed files with 40 additions and 37 deletions

View file

@ -232,13 +232,13 @@ test_bin2hex (void)
p = bin2hex (stuff, 20, NULL);
if (!p)
fail (0);
if (strcmp (p, hexstuff))
else if (strcmp (p, hexstuff))
fail (0);
p = bin2hex (stuff, (size_t)(-1), NULL);
if (p)
fail (0);
if (errno != ENOMEM)
else if (errno != ENOMEM)
fail (1);
}
@ -264,13 +264,13 @@ test_bin2hexcolon (void)
p = bin2hexcolon (stuff, 20, NULL);
if (!p)
fail (0);
if (strcmp (p, hexstuff))
else if (strcmp (p, hexstuff))
fail (0);
p = bin2hexcolon (stuff, (size_t)(-1), NULL);
if (p)
fail (0);
if (errno != ENOMEM)
else if (errno != ENOMEM)
fail (1);
}