>From 4f895878f85988c292454662ae07ba3e72d7e7ba Mon Sep 17 00:00:00 2001 From: Roman Mindalev <li...@r000n.net> Date: Wed, 11 Mar 2009 21:25:52 +0300 Subject: [ntdll] Care about arch and name fields in assembly_identity structure
On parsing of a manifest is possible access to zero address and crash. It's happens because arch and name manifest attributes can be not specified and pointers in assembly_identity structure can be uninitialized. This patch adds check for these fields --- dlls/ntdll/actctx.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c index 79d475f..25c590a 100644 --- a/dlls/ntdll/actctx.c +++ b/dlls/ntdll/actctx.c @@ -496,17 +496,19 @@ static WCHAR *build_assembly_dir(struct assembly_identity* ai) static const WCHAR noneW[] = {'n','o','n','e',0}; static const WCHAR mskeyW[] = {'d','e','a','d','b','e','e','f',0}; + const WCHAR *arch = ai->arch ? ai->arch : noneW; const WCHAR *key = ai->public_key ? ai->public_key : noneW; const WCHAR *lang = ai->language ? ai->language : noneW; - SIZE_T size = (strlenW(ai->arch) + 1 + strlenW(ai->name) + 1 + strlenW(key) + 24 + 1 + - strlenW(lang) + 1) * sizeof(WCHAR) + sizeof(mskeyW); + const WCHAR *name = ai->name ? ai->name : noneW; + SIZE_T size = (strlenW(arch) + 1 + strlenW(name) + 1 + strlenW(key) + 24 + 1 + + strlenW(lang) + 1) * sizeof(WCHAR) + sizeof(mskeyW); WCHAR *ret; if (!(ret = RtlAllocateHeap( GetProcessHeap(), 0, size ))) return NULL; - strcpyW( ret, ai->arch ); + strcpyW( ret, arch ); strcatW( ret, undW ); - strcatW( ret, ai->name ); + strcatW( ret, name ); strcatW( ret, undW ); strcatW( ret, key ); strcatW( ret, undW ); -- 1.6.2