提交 6ada227e 编写于 作者: W w00348538 提交者: public tcshversion

TicketNo:DTS2020090402983

Description: change fread to read
Team:EMUI
Feature or Bugfix:Bugfix
Binary Source:No
PrivateCode(Yes/No):No

Change-Id: I2d2f0d309d8d1b60976b139f6b0b5f7b5b76b038
Reviewed-on: http://mgit-tm.rnd.huawei.com/10633471Tested-by: Npublic jenkins <public_jenkins@notesmail.huawei.com>
Reviewed-by: Nwangjing 00270068 <wangjing6@huawei.com>
上级 78a2fba8
......@@ -115,12 +115,12 @@ static int getrandom_wrapper( void *buf, size_t buflen, unsigned int flags )
#endif /* __linux__ */
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
int mbedtls_platform_entropy_poll( void *data,
unsigned char *output, size_t len, size_t *olen )
{
FILE *file;
size_t read_len;
int ret;
((void) data);
......@@ -140,18 +140,18 @@ int mbedtls_platform_entropy_poll( void *data,
*olen = 0;
file = fopen( "/dev/urandom", "rb" );
if( file == NULL )
int fd = open("/dev/urandom", O_RDONLY);
if (fd == -1)
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
read_len = fread( output, 1, len, file );
if( read_len != len )
ssize_t read_len = read(fd, output, len);
if ((read_len == -1) || ((size_t)read_len != len))
{
fclose( file );
close(fd);
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
}
fclose( file );
close(fd);
*olen = len;
return( 0 );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册