1
0
Fork 0
forked from len0rd/rockbox

Don't leak a file handle if nvram.bin is <8 bytes in size

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27011 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sparmann 2010-06-21 12:34:28 +00:00
parent 8eeec17041
commit 9092f7aa45

View file

@ -119,12 +119,14 @@ static bool read_nvram_data(char* buf, int max_len)
int var_count = 0, i = 0, buf_pos = 0;
#ifndef HAVE_RTC_RAM
int fd = open(NVRAM_FILE,O_RDONLY);
int bytes;
if (fd < 0)
return false;
memset(buf,0,max_len);
if (read(fd,buf,max_len) < 8) /* min is 8 bytes,magic, ver, vars, crc32 */
return false;
bytes = read(fd,buf,max_len);
close(fd);
if (bytes < 8) /* min is 8 bytes,magic, ver, vars, crc32 */
return false;
#else
memset(buf,0,max_len);
/* read rtc block */