Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
516c1bdc
O
OpenCorePKG_MOD
项目概览
btwise
/
OpenCorePKG_MOD
通知
26
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OpenCorePKG_MOD
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
516c1bdc
编写于
7月 13, 2022
作者:
S
Savva Mitrofanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Utilities: Add Ext4Pkg test
上级
37942f69
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
234 addition
and
0 deletion
+234
-0
Utilities/TestExt4Dxe/Makefile
Utilities/TestExt4Dxe/Makefile
+31
-0
Utilities/TestExt4Dxe/TestExt4Dxe.c
Utilities/TestExt4Dxe/TestExt4Dxe.c
+203
-0
未找到文件。
Utilities/TestExt4Dxe/Makefile
0 → 100644
浏览文件 @
516c1bdc
## @file
# Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
##
# CC=clang DEBUG=1 FUZZ=1 SANITIZE=1 make -j4 fuzz
PROJECT
=
TestExt4Dxe
PRODUCT
=
$(PROJECT)$(INFIX)$(SUFFIX)
OBJS
=
$(PROJECT)
.o
OBJS
+=
BaseUcs2Utf8Lib.o BaseOrderedCollectionRedBlackTreeLib.o
OBJS
+=
BlockGroup.o Collation.o Crc16.o Crc32c.o Directory.o DiskUtil.o
OBJS
+=
Ext4Dxe.o Extents.o File.o Inode.o Partition.o Superblock.o
ifeq
($(UDK_PATH),)
ifneq
($(PACKAGES_PATH),)
UDK_PATH
:=
$(PACKAGES_PATH)
else
UDK_PATH
?=
../../UDK
endif
endif
OC_USER
=
$(UDK_PATH)
/OpenCorePkg
include
$(OC_USER)/User/Makefile
CFLAGS
+=
-I
$(UDK_PATH)
/RedfishPkg/Include
CFLAGS
+=
-I
$(UDK_PATH)
/edk2-platforms/Features/Ext4Pkg/Ext4Dxe
VPATH
+=
$(UDK_PATH)
/RedfishPkg/Library/BaseUcs2Utf8Lib:
$
\
$(UDK_PATH)
/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib:
$
\
$(UDK_PATH)
/edk2-platforms/Features/Ext4Pkg/Ext4Dxe
Utilities/TestExt4Dxe/TestExt4Dxe.c
0 → 100644
浏览文件 @
516c1bdc
/** @file
Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
**/
#include <Ext4Dxe.h>
#include <UserFile.h>
#include <string.h>
EFI_GUID
gEfiUnicodeCollationProtocolGuid
=
{
0x1D85CD7F
,
0xF43D
,
0x11D2
,
{
0x9A
,
0x0C
,
0x00
,
0x90
,
0x27
,
0x3F
,
0xC1
,
0x4D
}};
EFI_GUID
gEfiDiskIoProtocolGuid
=
{
0xCE345171
,
0xBA0B
,
0x11D2
,
{
0x8E
,
0x4F
,
0x00
,
0xA0
,
0xC9
,
0x69
,
0x72
,
0x3B
}};
EFI_GUID
gEfiDiskIo2ProtocolGuid
=
{
0x151c8eae
,
0x7f2c
,
0x472c
,
{
0x9e
,
0x54
,
0x98
,
0x28
,
0x19
,
0x4f
,
0x6a
,
0x88
}};
EFI_GUID
gEfiFileSystemInfoGuid
=
{
0x09576E93
,
0x6D3F
,
0x11D2
,
{
0x8E
,
0x39
,
0x00
,
0xA0
,
0xC9
,
0x69
,
0x72
,
0x3B
}};
UINT8
_gPcd_FixedAtBuild_PcdUefiVariableDefaultLang
[
4
]
=
{
101
,
110
,
103
,
0
};
UINT8
_gPcd_FixedAtBuild_PcdUefiVariableDefaultPlatformLang
[
6
]
=
{
101
,
110
,
45
,
85
,
83
,
0
};
UINTN
mFuzzOffset
;
UINTN
mFuzzSize
;
CONST
UINT8
*
mFuzzPointer
;
EFI_STATUS
EFIAPI
EfiLibInstallAllDriverProtocols2
(
IN
CONST
EFI_HANDLE
ImageHandle
,
IN
CONST
EFI_SYSTEM_TABLE
*
SystemTable
,
IN
EFI_DRIVER_BINDING_PROTOCOL
*
DriverBinding
,
IN
EFI_HANDLE
DriverBindingHandle
,
IN
CONST
EFI_COMPONENT_NAME_PROTOCOL
*
ComponentName
,
OPTIONAL
IN
CONST
EFI_COMPONENT_NAME2_PROTOCOL
*
ComponentName2
,
OPTIONAL
IN
CONST
EFI_DRIVER_CONFIGURATION_PROTOCOL
*
DriverConfiguration
,
OPTIONAL
IN
CONST
EFI_DRIVER_CONFIGURATION2_PROTOCOL
*
DriverConfiguration2
,
OPTIONAL
IN
CONST
EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*
DriverDiagnostics
,
OPTIONAL
IN
CONST
EFI_DRIVER_DIAGNOSTICS2_PROTOCOL
*
DriverDiagnostics2
OPTIONAL
)
{
abort
();
return
EFI_NOT_FOUND
;
}
EFI_STATUS
EFIAPI
EfiLibUninstallAllDriverProtocols2
(
IN
EFI_DRIVER_BINDING_PROTOCOL
*
DriverBinding
,
IN
CONST
EFI_COMPONENT_NAME_PROTOCOL
*
ComponentName
,
OPTIONAL
IN
CONST
EFI_COMPONENT_NAME2_PROTOCOL
*
ComponentName2
,
OPTIONAL
IN
CONST
EFI_DRIVER_CONFIGURATION_PROTOCOL
*
DriverConfiguration
,
OPTIONAL
IN
CONST
EFI_DRIVER_CONFIGURATION2_PROTOCOL
*
DriverConfiguration2
,
OPTIONAL
IN
CONST
EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*
DriverDiagnostics
,
OPTIONAL
IN
CONST
EFI_DRIVER_DIAGNOSTICS2_PROTOCOL
*
DriverDiagnostics2
OPTIONAL
)
{
abort
();
return
EFI_NOT_FOUND
;
}
EFI_STATUS
EFIAPI
FuzzReadDisk
(
IN
EFI_DISK_IO_PROTOCOL
*
This
,
IN
UINT32
MediaId
,
IN
UINT64
Offset
,
IN
UINTN
BufferSize
,
OUT
VOID
*
Buffer
)
{
if
(
Buffer
==
NULL
)
{
return
EFI_INVALID_PARAMETER
;
}
if
((
mFuzzSize
-
mFuzzOffset
)
<
BufferSize
)
{
return
EFI_OUT_OF_RESOURCES
;
}
CopyMem
(
Buffer
,
mFuzzPointer
,
BufferSize
);
mFuzzPointer
+=
BufferSize
;
mFuzzOffset
+=
BufferSize
;
return
EFI_SUCCESS
;
}
INT32
LLVMFuzzerTestOneInput
(
CONST
UINT8
*
FuzzData
,
UINTN
FuzzSize
)
{
EFI_STATUS
Status
;
EXT4_PARTITION
*
Part
;
EFI_FILE_PROTOCOL
*
This
;
UINT64
BufferSize
;
VOID
*
Buffer
;
EFI_FILE_PROTOCOL
*
NewHandle
;
CHAR16
*
FileName
;
mFuzzOffset
=
0
;
mFuzzPointer
=
FuzzData
;
mFuzzSize
=
FuzzSize
;
Part
=
AllocateZeroPool
(
sizeof
(
*
Part
));
if
(
Part
==
NULL
)
{
return
0
;
}
ASAN_CHECK_MEMORY_REGION
(
Part
,
sizeof
(
EXT4_PARTITION
));
InitializeListHead
(
&
Part
->
OpenFiles
);
Part
->
DiskIo
=
AllocateZeroPool
(
sizeof
(
EFI_DISK_IO_PROTOCOL
));
if
(
Part
->
DiskIo
==
NULL
)
{
FreePool
(
Part
);
return
0
;
}
ASAN_CHECK_MEMORY_REGION
(
Part
->
DiskIo
,
sizeof
(
EFI_DISK_IO_PROTOCOL
));
Part
->
DiskIo
->
ReadDisk
=
FuzzReadDisk
;
Part
->
BlockIo
=
AllocateZeroPool
(
sizeof
(
EFI_BLOCK_IO_PROTOCOL
));
if
(
Part
->
BlockIo
==
NULL
)
{
FreePool
(
Part
->
DiskIo
);
FreePool
(
Part
);
return
0
;
}
ASAN_CHECK_MEMORY_REGION
(
Part
->
BlockIo
,
sizeof
(
EFI_BLOCK_IO_PROTOCOL
));
Part
->
BlockIo
->
Media
=
AllocateZeroPool
(
sizeof
(
EFI_BLOCK_IO_MEDIA
));
if
(
Part
->
BlockIo
->
Media
==
NULL
)
{
FreePool
(
Part
->
BlockIo
);
FreePool
(
Part
->
DiskIo
);
FreePool
(
Part
);
return
0
;
}
ASAN_CHECK_MEMORY_REGION
(
Part
->
BlockIo
->
Media
,
sizeof
(
EFI_BLOCK_IO_MEDIA
));
Status
=
Ext4OpenSuperblock
(
Part
);
if
(
EFI_ERROR
(
Status
))
{
FreePool
(
Part
->
BlockIo
->
Media
);
FreePool
(
Part
->
BlockIo
);
FreePool
(
Part
->
DiskIo
);
FreePool
(
Part
);
return
0
;
}
Part
->
Interface
.
Revision
=
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION
;
Part
->
Interface
.
OpenVolume
=
Ext4OpenVolume
;
BufferSize
=
100
;
Buffer
=
AllocateZeroPool
(
BufferSize
);
if
(
Buffer
==
NULL
)
{
FreePool
(
Part
->
BlockIo
->
Media
);
FreePool
(
Part
->
BlockIo
);
FreePool
(
Part
->
DiskIo
);
FreePool
(
Part
);
return
0
;
}
ASAN_CHECK_MEMORY_REGION
(
Buffer
,
BufferSize
);
FileName
=
AllocateZeroPool
(
BufferSize
);
if
(
FileName
==
NULL
)
{
FreePool
(
Buffer
);
FreePool
(
Part
->
BlockIo
->
Media
);
FreePool
(
Part
->
BlockIo
);
FreePool
(
Part
->
DiskIo
);
FreePool
(
Part
);
return
0
;
}
ASAN_CHECK_MEMORY_REGION
(
FileName
,
BufferSize
);
if
((
mFuzzSize
-
mFuzzOffset
)
<
BufferSize
)
{
FreePool
(
Buffer
);
FreePool
(
FileName
);
FreePool
(
Part
->
BlockIo
->
Media
);
FreePool
(
Part
->
BlockIo
);
FreePool
(
Part
->
DiskIo
);
FreePool
(
Part
);
return
0
;
}
CopyMem
(
FileName
,
mFuzzPointer
,
BufferSize
-
2
);
mFuzzPointer
+=
BufferSize
-
2
;
mFuzzOffset
+=
BufferSize
-
2
;
This
=
(
EFI_FILE_PROTOCOL
*
)
Part
->
Root
;
Status
=
Ext4Open
(
This
,
&
NewHandle
,
FileName
,
EFI_FILE_MODE_READ
,
0
);
if
(
Status
==
EFI_SUCCESS
)
{
Ext4ReadFile
(
NewHandle
,
&
BufferSize
,
Buffer
);
}
FreePool
(
Buffer
);
FreePool
(
FileName
);
FreePool
(
Part
->
BlockIo
->
Media
);
FreePool
(
Part
->
BlockIo
);
FreePool
(
Part
->
DiskIo
);
FreePool
(
Part
);
return
0
;
}
int
ENTRY_POINT
(
int
argc
,
char
**
argv
)
{
uint32_t
f
;
uint8_t
*
b
;
if
((
b
=
UserReadFile
(
argc
>
1
?
argv
[
1
]
:
"in.bin"
,
&
f
))
==
NULL
)
{
DEBUG
((
DEBUG_ERROR
,
"Read fail
\n
"
));
return
-
1
;
}
LLVMFuzzerTestOneInput
(
b
,
f
);
FreePool
(
b
);
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录