зеркало из https://github.com/microsoft/lsvmtools.git
ext2.c: fixed usage of hard coded file times (using time() now).
grubcfg.c: fix memory leak in failure case.
This commit is contained in:
Родитель
08dba25e1c
Коммит
38755fc451
|
@ -37,6 +37,7 @@
|
|||
# include <string.h>
|
||||
#endif /* defined(BUILD_EFI) */
|
||||
|
||||
#include <time.h>
|
||||
#include "utils.h"
|
||||
#include "buf.h"
|
||||
#include "strings.h"
|
||||
|
@ -3472,7 +3473,7 @@ static EXT2Err _UpdateInodeBlockPointers(
|
|||
r -= n;
|
||||
}
|
||||
|
||||
/* ATTN: triple indirect block numbers not handled! */
|
||||
/* Note: triple indirect block numbers not handled! */
|
||||
if (r > 0)
|
||||
{
|
||||
GOTO(done);
|
||||
|
@ -4023,7 +4024,8 @@ static EXT2Err _CreateFileInode(
|
|||
|
||||
/* Initialize the inode */
|
||||
{
|
||||
const UINT32 time = 1464821956; /* ATTN: hardcoded for now */
|
||||
/* Uses posix_time() for EFI */
|
||||
const UINT32 t = time(NULL);
|
||||
|
||||
Memset(&inode, 0, sizeof(EXT2Inode));
|
||||
|
||||
|
@ -4038,9 +4040,9 @@ static EXT2Err _CreateFileInode(
|
|||
inode.i_size = size;
|
||||
|
||||
/* Set the access, creation, and mtime to the same value */
|
||||
inode.i_atime = time;
|
||||
inode.i_ctime = time;
|
||||
inode.i_mtime = time;
|
||||
inode.i_atime = t;
|
||||
inode.i_ctime = t;
|
||||
inode.i_mtime = t;
|
||||
|
||||
/* Linux-specific value */
|
||||
inode.i_osd1 = 1;
|
||||
|
@ -4103,7 +4105,7 @@ static EXT2Err _CreateDirInodeAndBlock(
|
|||
|
||||
/* Initialize the inode */
|
||||
{
|
||||
const UINT32 time = 1464821956; /* ATTN: hardcoded for now */
|
||||
const UINT32 t = time(NULL);
|
||||
|
||||
Memset(&inode, 0, sizeof(EXT2Inode));
|
||||
|
||||
|
@ -4118,9 +4120,9 @@ static EXT2Err _CreateDirInodeAndBlock(
|
|||
inode.i_size = ext2->block_size;
|
||||
|
||||
/* Set the access, creation, and mtime to the same value */
|
||||
inode.i_atime = time;
|
||||
inode.i_ctime = time;
|
||||
inode.i_mtime = time;
|
||||
inode.i_atime = t;
|
||||
inode.i_ctime = t;
|
||||
inode.i_mtime = t;
|
||||
|
||||
/* Linux-specific value */
|
||||
inode.i_osd1 = 1;
|
||||
|
|
|
@ -315,6 +315,24 @@ static int _GetToken(const char** text, const char** tok)
|
|||
return 'I';
|
||||
}
|
||||
|
||||
static void _ReleaseCommands(
|
||||
GRUBCommand* commands,
|
||||
UINTN numCommands)
|
||||
{
|
||||
UINTN i;
|
||||
|
||||
for (i = 0; i < numCommands; i++)
|
||||
{
|
||||
StrArr sa;
|
||||
sa.data = commands[i].argv;
|
||||
sa.size = commands[i].argc;
|
||||
sa.capacity = sa.size;
|
||||
StrArrRelease(&sa);
|
||||
}
|
||||
|
||||
Free(commands);
|
||||
}
|
||||
|
||||
static int _Parse(
|
||||
const char* data,
|
||||
GRUBCommand** commandsOut,
|
||||
|
@ -387,7 +405,9 @@ done:
|
|||
|
||||
if (rc != 0)
|
||||
{
|
||||
/* ATTN: release here! */
|
||||
_ReleaseCommands(commands, numCommands);
|
||||
*commandsOut = NULL;
|
||||
*numCommandsOut = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -422,34 +442,6 @@ INLINE void _Dump(
|
|||
}
|
||||
}
|
||||
|
||||
static void _FreeCommand(GRUBCommand* cmd)
|
||||
{
|
||||
UINTN i;
|
||||
|
||||
for (i = 0; i < cmd->argc; i++)
|
||||
{
|
||||
Free(cmd->argv[i]);
|
||||
}
|
||||
|
||||
Free(cmd->argv);
|
||||
}
|
||||
|
||||
static void _Release(
|
||||
GRUBCommand* commands,
|
||||
UINTN numCommands)
|
||||
{
|
||||
UINTN i;
|
||||
|
||||
(void)_FreeCommand;
|
||||
|
||||
for (i = 0; i < numCommands; i++)
|
||||
{
|
||||
_FreeCommand(&commands[i]);
|
||||
}
|
||||
|
||||
Free(commands);
|
||||
}
|
||||
|
||||
INLINE void _Indent(UINTN depth)
|
||||
{
|
||||
UINTN i;
|
||||
|
@ -749,7 +741,7 @@ done:
|
|||
Free(data);
|
||||
|
||||
if (commands)
|
||||
_Release(commands, numCommands);
|
||||
_ReleaseCommands(commands, numCommands);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче