Check rng return value when generating serial numbers in pki utility
This commit is contained in:
committed by
Martin Willi
parent
5668a99a12
commit
e93bb353d5
@@ -356,11 +356,11 @@ static int issue()
|
|||||||
error = "no random number generator found";
|
error = "no random number generator found";
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
rng->allocate_bytes(rng, 8, &serial);
|
if (!rng_allocate_bytes_not_zero(rng, 8, &serial, FALSE))
|
||||||
while (*serial.ptr == 0x00)
|
|
||||||
{
|
{
|
||||||
/* we don't accept a serial number with leading zeroes */
|
error = "failed to generate serial number";
|
||||||
rng->get_bytes(rng, 1, serial.ptr);
|
rng->destroy(rng);
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
rng->destroy(rng);
|
rng->destroy(rng);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,11 +298,11 @@ static int self()
|
|||||||
error = "no random number generator found";
|
error = "no random number generator found";
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
rng->allocate_bytes(rng, 8, &serial);
|
if (!rng_allocate_bytes_not_zero(rng, 8, &serial, FALSE))
|
||||||
while (*serial.ptr == 0x00)
|
|
||||||
{
|
{
|
||||||
/* we don't accept a serial number with leading zeroes */
|
error = "failed to generate serial number";
|
||||||
rng->get_bytes(rng, 1, serial.ptr);
|
rng->destroy(rng);
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
rng->destroy(rng);
|
rng->destroy(rng);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user