From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web10.1471.1579201646852750425 for ; Thu, 16 Jan 2020 11:07:27 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CNyjW8se; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579201645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZiOD97YKZI569MMSnP2ehw7z8sqIxi6qboIZ4Rup+8o=; b=CNyjW8seUj2KPe5sQd4CLBltrnjaMnUAoTywqE8YZgXjOYzzqliJTSHE5rfLdWgXM5Eqvj knY5X4ROQBBLI2Vnu9QdfZXvsPhnd88/2csMd5hRti9SsteemL4uHnMTEPG2Znx/NltWI0 l5BZY0MZhmOYwSJrNpayhM+isPeXUoc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-205-gpRzJHPYMK-NsQKh8WEQBA-1; Thu, 16 Jan 2020 14:07:20 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 333808017CC; Thu, 16 Jan 2020 19:07:19 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-120.ams2.redhat.com [10.36.116.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14E1A80890; Thu, 16 Jan 2020 19:07:17 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Chao Zhang , Jian J Wang , Jiewen Yao Subject: [PATCH 07/11] SecurityPkg/DxeImageVerificationHandler: unnest AddImageExeInfo() call Date: Thu, 16 Jan 2020 20:07:01 +0100 Message-Id: <20200116190705.18816-8-lersek@redhat.com> In-Reply-To: <20200116190705.18816-1-lersek@redhat.com> References: <20200116190705.18816-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: gpRzJHPYMK-NsQKh8WEQBA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: base64 QmVmb3JlIHRoZSAiRG9uZSIgbGFiZWwgYXQgdGhlIGVuZCBvZiBEeGVJbWFnZVZlcmlmaWNhdGlv bkhhbmRsZXIoKSwgd2UKbm93IGhhdmUgYSBzaW5nbGUgYWNjZXNzIHRvICJTdGF0dXMiOiB3ZSBz ZXQgIlN0YXR1cyIgdG8gRUZJX0FDQ0VTU19ERU5JRUQKYXQgdGhlIHRvcCBvZiB0aGUgZnVuY3Rp b24uIFRoZXJlZm9yZSwgdGhlIChTdGF0dXMgIT0gRUZJX1NVQ0NFU1MpCmNvbmRpdGlvbiBpcyBh bHdheXMgdHJ1ZSB1bmRlciB0aGUgIkRvbmUiIGxhYmVsLgoKQWNjb3JkaW5nbHksIHVubmVzdCB0 aGUgQWRkSW1hZ2VFeGVJbmZvKCkgY2FsbCBkZXBlbmRlbnQgb24gdGhhdApjb25kaXRpb24sIHJl bW92ZSB0aGUgY29uZGl0aW9uLCBhbmQgYWxzbyByZW5hbWUgdGhlICJEb25lIiBsYWJlbCB0bwoi RmFpbGVkIi4KCkZ1bmN0aW9uYWxseSwgdGhpcyBwYXRjaCBpcyBhIG5vLW9wLiBJdCdzIGVhc2ll ciB0byByZXZpZXcgd2l0aDoKCiAgZ2l0IHNob3cgLWIgLVcKCkNjOiBDaGFvIFpoYW5nIDxjaGFv LmIuemhhbmdAaW50ZWwuY29tP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F1dGhlbnRpY2F0aW9uU3RhdHVzLA0KICAgSU4gIENPTlNUIEVGSV9ERVZJQ0Vf UEFUSF9QUk9UT0NPTCAgICpGaWxlLA0KICAgSU4gIFZPSUQgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICpGaWxlQnVmZmVyLA0KICAgSU4gIFVJTlROICAgICAgICAgICAgICAgICAgICAgICAg ICAgIEZpbGVTaXplLA0KICAgSU4gIEJPT0xFQU4gICAgICAgICAgICAgICAgICAgICAgICAgIEJv b3RQb2xpY3kNCiAgICkNCiB7DQogICBFRklfU1RBVFVTICAgICAgICAgICAgICAgICAgICAgICAg ICAgU3RhdHVzOw0KICAgRUZJX0lNQUdFX0RPU19IRUFERVIgICAgICAgICAgICAgICAgICpEb3NI ZHI7DQogICBCT09MRUFOICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSXNWZXJpZmllZDsN CiAgIEVGSV9TSUdOQVRVUkVfTElTVCAgICAgICAgICAgICAgICAgICAqU2lnbmF0dXJlTGlzdDsN CiAgIFVJTlROICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTaWduYXR1cmVMaXN0U2l6 ZTsNCiAgIEVGSV9TSUdOQVRVUkVfREFUQSAgICAgICAgICAgICAgICAgICAqU2lnbmF0dXJlOw0K ICAgRUZJX0lNQUdFX0VYRUNVVElPTl9BQ1RJT04gICAgICAgICAgIEFjdGlvbjsNCiAgIFdJTl9D RVJUSUZJQ0FURSAgICAgICAgICAgICAgICAgICAgICAqV2luQ2VydGlmaWNhdGU7DQogICBVSU5U MzIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUG9saWN5Ow0KICAgVUlOVDggICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICpTZWN1cmVCb290Ow0KICAgUEVfQ09GRl9MT0FERVJf SU1BR0VfQ09OVEVYVCAgICAgICAgIEltYWdlQ29udGV4dDsNCiAgIFVJTlQzMiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBOdW1iZXJPZlJ2YUFuZFNpemVzOw0KICAgV0lOX0NFUlRJRklD QVRFX0VGSV9QS0NTICAgICAgICAgICAgICpQa2NzQ2VydERhdGE7DQogICBXSU5fQ0VSVElGSUNB VEVfVUVGSV9HVUlEICAgICAgICAgICAgKldpbkNlcnRVZWZpR3VpZDsNCiAgIFVJTlQ4ICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAqQXV0aERhdGE7DQogICBVSU5UTiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgQXV0aERhdGFTaXplOw0KICAgRUZJX0lNQUdFX0RBVEFfRElS RUNUT1JZICAgICAgICAgICAgICpTZWNEYXRhRGlyOw0KICAgVUlOVDMyICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIE9mZlNldDsNCiAgIENIQVIxNiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAqTmFtZVN0cjsNCiAgIFJFVFVSTl9TVEFUVVMgICAgICAgICAgICAgICAgICAgICAg ICBQZUNvZmZTdGF0dXM7DQogICBFRklfU1RBVFVTICAgICAgICAgICAgICAgICAgICAgICAgICAg SGFzaFN0YXR1czsNCiANCiAgIFNpZ25hdHVyZUxpc3QgICAgID0gTlVMTDsNCiAgIFNpZ25hdHVy ZUxpc3RTaXplID0gMDsNCiAgIFdpbkNlcnRpZmljYXRlICAgID0gTlVMTDsNCiAgIFNlY0RhdGFE aXIgICAgICAgID0gTlVMTDsNCiAgIFBrY3NDZXJ0RGF0YSAgICAgID0gTlVMTDsNCiAgIEFjdGlv biAgICAgICAgICAgID0gRUZJX0lNQUdFX0VYRUNVVElPTl9BVVRIX1VOVEVTVEVEOw0KICAgU3Rh dHVzICAgICAgICAgICAgPSBFRklfQUNDRVNTX0RFTklFRDsNCiAgIElzVmVyaWZpZWQgICAgICAg ID0gRkFMU0U7DQogDQogDQogICAvLw0KICAgLy8gQ2hlY2sgdGhlIGltYWdlIHR5cGUgYW5kIGdl dCBwb2xpY3kgc2V0dGluZy4NCiAgIC8vDQogICBzd2l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