* [PATCH v2 1/2] MdeModulePkg/RegularExpressionDxe: Fix memory assert in FreePool()
@ 2021-07-05 2:41 Nickle Wang
2021-07-05 2:41 ` [PATCH v2 2/2] MdeModulePkg: Update YAML file to fix CI error Nickle Wang
0 siblings, 1 reply; 3+ messages in thread
From: Nickle Wang @ 2021-07-05 2:41 UTC (permalink / raw)
To: devel; +Cc: gaoliming, jian.j.wang, hao.a.wu, Nickle Wang
Memory buffer that is allocated by malloc() and realloc() will be
shifted by 8 bytes because Oniguruma keeps its memory signature. This 8
bytes shift is not handled while calling free() to release memory. Add
free() function to check Oniguruma signature before release memory
because memory buffer is not touched when using calloc().
Signed-off-by: Nickle Wang <nickle.wang@hpe.com>
---
.../RegularExpressionDxe/OnigurumaUefiPort.c | 19 ++++++++++++++++++-
.../RegularExpressionDxe/OnigurumaUefiPort.h | 14 ++------------
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.c b/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.c
index 9aa7b0a68e..4659c4473e 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.c
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.c
@@ -2,7 +2,7 @@
Module to rewrite stdlib references within Oniguruma
- (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP<BR>
+ (C) Copyright 2014-2021 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -96,3 +96,20 @@ void* memset (void *dest, char ch, unsigned int count)
return SetMem (dest, count, ch);
}
+void free(void *ptr)
+{
+ VOID *EvalOnce;
+ ONIGMEM_HEAD *PoolHdr;
+
+ EvalOnce = ptr;
+ if (EvalOnce == NULL) {
+ return;
+ }
+
+ PoolHdr = (ONIGMEM_HEAD *)EvalOnce - 1;
+ if (PoolHdr->Signature == ONIGMEM_HEAD_SIGNATURE) {
+ FreePool (PoolHdr);
+ } else {
+ FreePool (EvalOnce);
+ }
+}
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h b/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h
index 20b75c3361..0bdb7be529 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h
@@ -2,7 +2,7 @@
Module to rewrite stdlib references within Oniguruma
- (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP<BR>
+ (C) Copyright 2014-2021 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -46,17 +46,6 @@ typedef INTN intptr_t;
#endif
#define calloc(n,s) AllocateZeroPool((n)*(s))
-
-#define free(p) \
- do { \
- VOID *EvalOnce; \
- \
- EvalOnce = (p); \
- if (EvalOnce != NULL) { \
- FreePool (EvalOnce); \
- } \
- } while (FALSE)
-
#define xmemmove(Dest,Src,Length) CopyMem(Dest,Src,Length)
#define xmemcpy(Dest,Src,Length) CopyMem(Dest,Src,Length)
#define xmemset(Buffer,Value,Length) SetMem(Buffer,Length,Value)
@@ -98,6 +87,7 @@ void* malloc(size_t size);
void* realloc(void *ptr, size_t size);
void* memcpy (void *dest, const void *src, unsigned int count);
void* memset (void *dest, char ch, unsigned int count);
+void free(void *ptr);
#define exit(n) ASSERT(FALSE);
--
2.31.1.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] MdeModulePkg: Update YAML file to fix CI error
2021-07-05 2:41 [PATCH v2 1/2] MdeModulePkg/RegularExpressionDxe: Fix memory assert in FreePool() Nickle Wang
@ 2021-07-05 2:41 ` Nickle Wang
2021-07-06 3:48 ` 回复: " gaoliming
0 siblings, 1 reply; 3+ messages in thread
From: Nickle Wang @ 2021-07-05 2:41 UTC (permalink / raw)
To: devel; +Cc: gaoliming, jian.j.wang, hao.a.wu, Nickle Wang
Add OnigurumaUefiPort.h and OnigurumaUefiPort.c into ECC exception in
MdeModulePkg.ci.yaml in order to fix CI error.
Signed-off-by: Nickle Wang <nickle.wang@hpe.com>
---
MdeModulePkg/MdeModulePkg.ci.yaml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/MdeModulePkg/MdeModulePkg.ci.yaml b/MdeModulePkg/MdeModulePkg.ci.yaml
index 4c71468bd3..8e01caf94c 100644
--- a/MdeModulePkg/MdeModulePkg.ci.yaml
+++ b/MdeModulePkg/MdeModulePkg.ci.yaml
@@ -3,6 +3,7 @@
#
# Copyright (c) Microsoft Corporation
# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
{
@@ -24,7 +25,9 @@
"Library/BrotliCustomDecompressLib/brotli",
"Universal/RegularExpressionDxe/oniguruma",
"Library/LzmaCustomDecompressLib/Sdk/DOC",
- "Library/LzmaCustomDecompressLib/Sdk/C"
+ "Library/LzmaCustomDecompressLib/Sdk/C",
+ "Universal/RegularExpressionDxe/OnigurumaUefiPort.h",
+ "Universal/RegularExpressionDxe/OnigurumaUefiPort.c"
]
},
## options defined ci/Plugin/CompilerPlugin
--
2.31.1.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* 回复: [PATCH v2 2/2] MdeModulePkg: Update YAML file to fix CI error
2021-07-05 2:41 ` [PATCH v2 2/2] MdeModulePkg: Update YAML file to fix CI error Nickle Wang
@ 2021-07-06 3:48 ` gaoliming
0 siblings, 0 replies; 3+ messages in thread
From: gaoliming @ 2021-07-06 3:48 UTC (permalink / raw)
To: 'Nickle Wang', devel; +Cc: jian.j.wang, hao.a.wu
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> -----邮件原件-----
> 发件人: Nickle Wang <nickle.wang@hpe.com>
> 发送时间: 2021年7月5日 10:41
> 收件人: devel@edk2.groups.io
> 抄送: gaoliming@byosoft.com.cn; jian.j.wang@intel.com;
> hao.a.wu@intel.com; Nickle Wang <nickle.wang@hpe.com>
> 主题: [PATCH v2 2/2] MdeModulePkg: Update YAML file to fix CI error
>
> Add OnigurumaUefiPort.h and OnigurumaUefiPort.c into ECC exception in
> MdeModulePkg.ci.yaml in order to fix CI error.
>
> Signed-off-by: Nickle Wang <nickle.wang@hpe.com>
> ---
> MdeModulePkg/MdeModulePkg.ci.yaml | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/MdeModulePkg/MdeModulePkg.ci.yaml
> b/MdeModulePkg/MdeModulePkg.ci.yaml
> index 4c71468bd3..8e01caf94c 100644
> --- a/MdeModulePkg/MdeModulePkg.ci.yaml
> +++ b/MdeModulePkg/MdeModulePkg.ci.yaml
> @@ -3,6 +3,7 @@
> #
>
> # Copyright (c) Microsoft Corporation
>
> # Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
>
> +# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
>
> # SPDX-License-Identifier: BSD-2-Clause-Patent
>
> ##
>
> {
>
> @@ -24,7 +25,9 @@
> "Library/BrotliCustomDecompressLib/brotli",
>
> "Universal/RegularExpressionDxe/oniguruma",
>
> "Library/LzmaCustomDecompressLib/Sdk/DOC",
>
> - "Library/LzmaCustomDecompressLib/Sdk/C"
>
> + "Library/LzmaCustomDecompressLib/Sdk/C",
>
> + "Universal/RegularExpressionDxe/OnigurumaUefiPort.h",
>
> + "Universal/RegularExpressionDxe/OnigurumaUefiPort.c"
>
> ]
>
> },
>
> ## options defined ci/Plugin/CompilerPlugin
>
> --
> 2.31.1.windows.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-06 3:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-05 2:41 [PATCH v2 1/2] MdeModulePkg/RegularExpressionDxe: Fix memory assert in FreePool() Nickle Wang
2021-07-05 2:41 ` [PATCH v2 2/2] MdeModulePkg: Update YAML file to fix CI error Nickle Wang
2021-07-06 3:48 ` 回复: " gaoliming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox