mirror of
https://github.com/hashcat/hashcat.git
synced 2025-01-23 14:10:57 +00:00
tainted string: test #2, try to limit the length of the compute variable
This commit is contained in:
parent
7858f37800
commit
d21fbe0b2f
14
src/shared.c
14
src/shared.c
@ -258,18 +258,18 @@ void setup_environment_variables ()
|
|||||||
{
|
{
|
||||||
static char display[100];
|
static char display[100];
|
||||||
|
|
||||||
snprintf (display, sizeof (display) - 1, "DISPLAY=%s", compute);
|
u32 compute_len_max = sizeof (display);
|
||||||
|
|
||||||
// we only use this check to avoid "tainted string" warnings
|
// we only use this check to avoid "tainted string" warnings
|
||||||
|
|
||||||
u32 display_len_max = sizeof (display);
|
u32 compute_len = strnlen (compute, compute_len_max);
|
||||||
|
|
||||||
u32 display_len = strnlen (display, display_len_max);
|
if (compute_len > 0) // should be always true
|
||||||
|
{
|
||||||
|
if (compute_len < compute_len_max) // some upper bound is always good
|
||||||
|
{
|
||||||
|
snprintf (display, compute_len_max, "DISPLAY=%s", compute);
|
||||||
|
|
||||||
if (display_len > 0) // should be always true
|
|
||||||
{
|
|
||||||
if (display_len < display_len_max) // some upper bound is always good
|
|
||||||
{
|
|
||||||
putenv (display);
|
putenv (display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user