Skip to content

Commit a09f3f3

Browse files
some fix
1 parent 553925e commit a09f3f3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

libc/src/__support/OSUtil/linux/random.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
//===- Linux implementation of secure random buffer generation --*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
18
#include "src/__support/OSUtil/linux/random.h"
29
#include "src/__support/CPP/mutex.h"
310
#include "src/__support/CPP/new.h"
411
#include "src/__support/OSUtil/linux/syscall.h"
512
#include "src/__support/OSUtil/linux/vdso.h"
6-
#include "src/__support/OSUtil/linux/x86_64/vdso.h"
713
#include "src/__support/libc_assert.h"
814
#include "src/__support/memory_size.h"
915
#include "src/__support/threads/callonce.h"
@@ -307,8 +313,13 @@ void random_fill(void *buf, size_t size) {
307313
random_fill_impl(
308314
[state](void *buf, size_t size) {
309315
vdso::TypedSymbol<vdso::VDSOSym::GetRandom> vgetrandom;
310-
return vgetrandom(buf, size, 0, state,
311-
StateFactory::size_of_opaque_state());
316+
int res = vgetrandom(buf, size, 0, state,
317+
StateFactory::size_of_opaque_state());
318+
if (res < 0) {
319+
libc_errno = -res;
320+
return -1;
321+
}
322+
return res;
312323
},
313324
buf, size);
314325
} else {

libc/test/integration/src/__support/OSUtil/linux/random_fill_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- Tests for pthread_equal -------------------------------------------===//
1+
//===-- Tests for random_fill ---------------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

0 commit comments

Comments
 (0)