diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2020-05-25 14:54:00 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2020-05-25 14:54:00 +0000 |
commit | 00d3e4ac379d76d6fdaacb288af1b76a4c4ed326 (patch) | |
tree | 28b4331308af4b4d4a638ae70e755d22047b0a3b /sys/arch/arm64/stand | |
parent | 224691bb5a0444892f424849d6250cc62c3d3a89 (diff) |
Adjust fwrandom() to return 0 for sucess, -1 for failure
Diffstat (limited to 'sys/arch/arm64/stand')
-rw-r--r-- | sys/arch/arm64/stand/efiboot/efirng.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/arch/arm64/stand/efiboot/efirng.c b/sys/arch/arm64/stand/efiboot/efirng.c index a90f86d57f7..9d769e75b47 100644 --- a/sys/arch/arm64/stand/efiboot/efirng.c +++ b/sys/arch/arm64/stand/efiboot/efirng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efirng.c,v 1.1 2018/04/08 13:27:22 kettenis Exp $ */ +/* $OpenBSD: efirng.c,v 1.2 2020/05/25 14:53:58 deraadt Exp $ */ /* * Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org> @@ -59,23 +59,25 @@ typedef struct _EFI_RNG_PROTOCOL { static EFI_GUID rng_guid = EFI_RNG_PROTOCOL_GUID; -void +int fwrandom(char *buf, size_t buflen) { EFI_STATUS status; EFI_RNG_PROTOCOL *rng = NULL; UINT8 *random; size_t i; + int ret = 0; status = EFI_CALL(BS->LocateProtocol, &rng_guid, NULL, (void **)&rng); if (rng == NULL || EFI_ERROR(status)) - return; + return -1; random = alloc(buflen); status = EFI_CALL(rng->GetRNG, rng, NULL, buflen, random); if (EFI_ERROR(status)) { printf("RNG GetRNG() failed (%d)\n", status); + ret = -1; goto out; } @@ -84,4 +86,5 @@ fwrandom(char *buf, size_t buflen) out: free(random, buflen); + return ret; } |