Check rng return value when generating serial numbers in pki utility

This commit is contained in:
Tobias Brunner
2012-07-16 14:53:35 +02:00
committed by Martin Willi
parent 5668a99a12
commit e93bb353d5
2 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -356,11 +356,11 @@ static int issue()
error = "no random number generator found";
goto end;
}
rng->allocate_bytes(rng, 8, &serial);
while (*serial.ptr == 0x00)
if (!rng_allocate_bytes_not_zero(rng, 8, &serial, FALSE))
{
/* we don't accept a serial number with leading zeroes */
rng->get_bytes(rng, 1, serial.ptr);
error = "failed to generate serial number";
rng->destroy(rng);
goto end;
}
rng->destroy(rng);
}
+4 -4
View File
@@ -298,11 +298,11 @@ static int self()
error = "no random number generator found";
goto end;
}
rng->allocate_bytes(rng, 8, &serial);
while (*serial.ptr == 0x00)
if (!rng_allocate_bytes_not_zero(rng, 8, &serial, FALSE))
{
/* we don't accept a serial number with leading zeroes */
rng->get_bytes(rng, 1, serial.ptr);
error = "failed to generate serial number";
rng->destroy(rng);
goto end;
}
rng->destroy(rng);
}