From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web12.1437.1579201641616157700 for ; Thu, 16 Jan 2020 11:07:21 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=f6RAh4xO; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579201640; 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=4usOzu1S/mOjertk5AlwElxNfPzDi0z1Jcw/t04SRPQ=; b=f6RAh4xO9tyrLwLLmdJhkUGShtcQULeBKweikBrlBz2EAPINurGsaioxjZuZNLK5oxKQcT 2gjLm1WKG5jBbkGp1twoC/qXtVQXqhAOwDwtCfJwesW0n7Osm6mILIxcwUEx7Qrrxi+ntS vEpVX9sMsAvwSy5lvZwJsDuk5as/mJY= 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-266-hc1oEyhEMhySDEOkgCZjhg-1; Thu, 16 Jan 2020 14:07:17 -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 41E7B183B520; Thu, 16 Jan 2020 19:07:16 +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 24D5F80890; Thu, 16 Jan 2020 19:07:14 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Chao Zhang , Jian J Wang , Jiewen Yao Subject: [PATCH 05/11] SecurityPkg/DxeImageVerificationHandler: fix retval on memalloc failure Date: Thu, 16 Jan 2020 20:06:59 +0100 Message-Id: <20200116190705.18816-6-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: hc1oEyhEMhySDEOkgCZjhg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: base64 QSBTRUNVUklUWTJfRklMRV9BVVRIRU5USUNBVElPTl9IQU5ETEVSIGZ1bmN0aW9uIGlzIG5vdCBl eHBlY3RlZCB0byByZXR1cm4KRUZJX09VVF9PRl9SRVNPVVJDRVMuIFdlIHNob3VsZCBvbmx5IHJl dHVybiBFRklfU1VDQ0VTUywKRUZJX1NFQ1VSSVRZX1ZJT0xBVElPTiwgb3IgRUZJX0FDQ0VTU19E RU5JRUQuCgpJbiBjYXNlIHdlIHJ1biBvdXQgb2YgbWVtb3J5IHdoaWxlIHByZXBhcmluZyAiU2ln bmF0dXJlTGlzdCIgZm9yCkFkZEltYWdlRXhlSW5mbygpLCB3ZSBzaG91bGQgc2ltcGx5IHN0aWNr IHdpdGggdGhlIEVGSV9BQ0NFU1NfREVOSUVEIHZhbHVlCnRoYXQgaXMgYWxyZWFkeSBpbiAiU3Rh dHVzIiAtLSBmcm9tIGp1c3QgYmVmb3JlIHRoZSAiQWN0aW9uIiBjb25kaXRpb24gLS0sCmFuZCBu b3Qgc3VwcHJlc3MgaXQgd2l0aCBFRklfT1VUX09GX1JFU09VUkNFUy4KClRoaXMgcGF0Y2ggZG9l cyBub3QgY2hhbmdlIHRoZSBjb250cm9sIGZsb3cgaW4gdGhlIGZ1bmN0aW9uLCBpdCBvbmx5CmNo YW5nZXMgdGhlICJTdGF0dXMiIG91dGNvbWU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F0aW9uTGliL0R4ZUltYWdlVmVyaWZpY2F0aW9uTGliLmMKQEAgLTEzODQsMTcw ICsxMzg0LDE2OSBAQCBCT09MRUFOCiBJc0FsbG93ZWRCeURiICgNCiAgIElOIFVJTlQ4ICAgICAg ICAgICAgICAqQXV0aERhdGEsDQogICBJTiBVSU5UTiAgICAgICAgICAgICAgQXV0aERhdGFTaXpl DQogICApDQogew0KICAgRUZJX1NUQVRVUyAgICAgICAgICAgICAgICBTdGF0dXM7DQogICBCT09M RUFOICAgICAgICAgICAgICAgICAgIFZlcmlmeVN0YXR1czsNCiAgIEVGSV9TSUdOQVRVUkVfTElT VCAgICAgICAgKkNlcnRMaXN0Ow0KICAgRUZJX1NJR05BVFVSRV9EQVRBICAgICAgICAqQ2VydERh dGE7DQogICBVSU5UTiAgICAgICAgICAgICAgICAgICAgIERhdGFTaXplOw0KICAgVUlOVDggICAg ICAgICAgICAgICAgICAgICAqRGF0YTsNCiAgIFVJTlQ4ICAgICAgICAgICAgICAgICAgICAgKlJv b3RDZXJ0Ow0KICAgVUlOVE4gICAgICAgICAgICAgICAgICAgICBSb290Q2VydFNpemU7DQogICBV SU5UTiAgICAgICAgICAgICAgICAgICAgIEluZGV4Ow0KICAgVUlOVE4gICAgICAgICAgICAgICAg ICAgICBDZXJ0Q291bnQ7DQogICBVSU5UTiAgICAgICAgICAgICAgICAgICAgIERieERhdGFTaXpl Ow0KICAgVUlOVDggICAgICAgICAgICAgICAgICAgICAqRGJ4RGF0YTsNCiAgIEVGSV9USU1FICAg ICAgICAgICAgICAgICAgUmV2b2NhdGlvblRpbWU7DQogDQogICBEYXRhICAgICAgICAgICAgICA9 IE5VTEw7DQogICBDZXJ0TGlzdCAgICAgICAgICA9IE5VTEw7DQogICBDZXJ0RGF0YSAgICAgICAg ICA9IE5VTEw7DQogICBSb290Q2VydCAgICAgICAgICA9IE5VTEw7DQogICBEYnhEYXRhICAgICAg ICAgICA9IE5VTEw7DQogICBSb290Q2VydFNpemUgICAgICA9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AgICAgICAgICAgICAgICAgUm9vdENlcnQs DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgUm9vdENlcnRTaXplLA0KICAgICAgICAgICAg ICAgICAgICAgICAgICAgIG1JbWFnZURpZ2VzdCwNCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICBtSW1hZ2VEaWdlc3RTaXplDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgKTsNCiAgICAg ICAgICAgaWYgKFZlcmlmeVN0YXR1cykgew0KICAgICAgICAgICAgIC8vDQogICAgICAgICAgICAg Ly8gSGVyZSBXZSBzdGlsbCBuZWVkIHRvIGNoZWNrIGlmIHRoaXMgUm9vdENlcnQncyBIYXNoIGlz IHJldm9rZWQNCiAgICAgICAgICAgICAvLw0KICAgICAgICAgICAgIFN0YXR1cyAgID0gZ1JULT5H ZXRWYXJpYWJsZSAoRUZJX0lNQUdFX1NFQ1VSSVRZX0RBVEFCQVNFMSwgJmdFZmlJbWFnZVNlY3Vy aXR5RGF0YWJhc2VHdWlkLCBOVUxMLCAmRGJ4RGF0YVNpemUsIE5VTEwpOw0KICAgICAgICAgICAg IGlmIChTdGF0dXMgPT0gRUZJX0JVRkZFUl9UT09fU01BTEwpIHsNCiAgICAgICAgICAgICAgIGdv dG8gRG9uZTsNCiAgICAgICAgICAgICB9DQogICAgICAgICAgICAgRGJ4RGF0YSA9IChVSU5UOCAq KSBBbGxvY2F0ZVplcm9Qb29sIChEYnhEYXRhU2l6ZSk7DQogICAgICAgICAgICAgaWYgKERieERh dGEgPT0gTlVMTCkgew0KICAgICAgICAgICAgICAgZ290byBEb25lOw0KICAgICAgICAgICAgIH0N CiANCiAgICAgICAgICAgICBTdGF0dXMgPSBnUlQtPkdldFZhcmlhYmxlIChFRklfSU1BR0VfU0VD VVJJVFlfREFUQUJBU0UxLCAmZ0VmaUltYWdlU2VjdXJpdHlEYXRhYmFzZUd1aWQsIE5VTEwsICZE YnhEYXRhU2l6ZSwgKFZPSUQgKikgRGJ4RGF0YSk7DQogICAgICAgICAgICAgaWYgKEVGSV9FUlJP UiAoU3RhdHVzKSkgew0KICAgICAgICAgICAgICAgZ290byBEb25lOw0KICAgICAgICAgICAgIH0N CiANCiAgICAgICAgICAgICBpZiAoSXNDZXJ0SGFzaEZvdW5kSW5EYXRhYmFzZSAoUm9vdENlcnQs IFJvb3RDZXJ0U2l6ZSwgKEVGSV9TSUdOQVRVUkVfTElTVCAqKURieERhdGEsIERieERhdGFTaXpl LCAmUmV2b2NhdGlvblRpbWUpKSB7DQogICAgICAgICAgICAgICAvLw0KICAgICAgICAgICAgICAg Ly8gQ2hlY2sgdGhlIHRpbWVzdGFtcCBzaWduYXR1cmUgYW5kIHNpZ25pbmcgdGltZSB0byBkZXRl cm1pbmUgaWYgdGhlIFJvb3RDZXJ0IGNhbiBiZSB0cnVzdGVkLg0KICAgICAgICAgICAgICAgLy8N CiAgICAgICAgICAgICAgIFZlcmlmeVN0YXR1cyA9IFBhc3NUaW1lc3RhbXBDaGVjayAoQXV0aERh dGEsIEF1dGhEYXRhU2l6ZSwgJlJldm9jYXRpb25UaW1lKTsNCiAgICAgICAgICAgICAgIGlmICgh VmVyaWZ5U3RhdHVzKSB7DQogICAgICAgICAgICAgICAgIERFQlVHICgoREVCVUdfSU5GTywgIkR4 ZUltYWdlVmVyaWZpY2F0aW9uTGliOiBJbWFnZSBpcyBzaWduZWQgYW5kIHNpZ25hdHVyZSBpcyBh Y2NlcHRlZCBieSBEQiwgYnV0IGl0cyByb290IGNlcnQgZmFpbGVkIHRoZSB0aW1lc3RhbXAgY2hl Y2suXG4iKSk7DQogICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgfQ0KIA0KICAgICAgICAg ICAgIGdvdG8gRG9uZTsNCiAgICAgICAgICAgfQ0KIA0KICAgICAgICAgICBDZXJ0RGF0YSA9IChF RklfU0lHTkFUVVJFX0RBVEEgKikgKChVSU5UOCAqKSBDZXJ0RGF0YSArIENlcnRMaXN0LT5TaWdu YXR1cmVTaXplKTsNCiA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AgICAgICAg ICAgICAgICAgICAgIHRoYXQgdGhlIERYRSBGb3VuZGF0aW9uIG1heSB1c2UgdGhlIGZpbGUuDQog ICBAcmV0dmFsIEVGSV9TVUNDRVNTICAgICAgICAgICAgVGhlIGRldmljZSBwYXRoIHNwZWNpZmll ZCBieSBOVUxMIGRldmljZSBwYXRoIERldmljZVBhdGgNCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICBhbmQgbm9uLU5VTEwgRmlsZUJ1ZmZlciBkaWQgYXV0aGVudGljYXRlLCBhbmQg dGhlIHBsYXRmb3JtDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9saWN5IGRp Y3RhdGVzIHRoYXQgdGhlIERYRSBGb3VuZGF0aW9uIG1heSBleGVjdXRlIHRoZSBpbWFnZSBpbg0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbGVCdWZmZXIuDQotICBAcmV0dmFs IEVGSV9PVVRfUkVTT1VSQ0UgICAgICAgRmFpbCB0byBhbGxvY2F0ZSBtZW1vcnkuDQogICBAcmV0 dmFsIEVGSV9TRUNVUklUWV9WSU9MQVRJT04gVGhlIGZpbGUgc3BlY2lmaWVkIGJ5IEZpbGUgZGlk IG5vdCBhdXRoZW50aWNhdGUsIGFuZA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IHRoZSBwbGF0Zm9ybSBwb2xpY3kgZGljdGF0ZXMgdGhhdCBGaWxlIHNob3VsZCBiZSBwbGFjZWQN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbiB0aGUgdW50cnVzdGVkIHN0YXRl LiBUaGUgaW1hZ2UgaGFzIGJlZW4gYWRkZWQgdG8gdGhlIGZpbGUNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICBleGVjdXRpb24gdGFibGUuDQogICBAcmV0dmFsIEVGSV9BQ0NFU1Nf REVOSUVEICAgICAgVGhlIGZpbGUgc3BlY2lmaWVkIGJ5IEZpbGUgYW5kIEZpbGVCdWZmZXIgZGlk IG5vdA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1dGhlbnRpY2F0ZSwgYW5k IHRoZSBwbGF0Zm9ybSBwb2xpY3kgZGljdGF0ZXMgdGhhdCB0aGUgRFhFDQogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgRm91bmRhdGlvbiBtYW55IG5vdCB1c2UgRmlsZS4NCiANCiAq Ki8NCkBAIC0xNTU2LDM1MCArMTU1NSwzNDkgQEAgRUZJQVBJCiBEeGVJbWFnZVZlcmlmaWNhdGlv bkhhbmRsZXIgKA0KICAgSU4gIFVJTlQzMiAgICAgICAgICAgICAgICAgICAgICAgICAgIEF1dGhl bnRpY2F0aW9uU3RhdHVzLA0KICAgSU4gIENPTlNUIEVGSV9ERVZJQ0VfUEFUSF9QUk9UT0NPTCAg ICpGaWxlLA0KICAgSU4gIFZPSUQgICAgICAgICAgICAgICAgICAgICAgICAgICAgICpGaWxlQnVm ZmVyLA0KICAgSU4gIFVJTlROICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbGVTaXplLA0K ICAgSU4gIEJPT0xFQU4gICAgICAgICAgICAgICAgICAgICAgICAgIEJvb3RQb2xpY3kNCiAgICkN CiB7DQogICBFRklfU1RBVFVTICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RhdHVzOw0KICAg RUZJX0lNQUdFX0RPU19IRUFERVIgICAgICAgICAgICAgICAgICpEb3NIZHI7DQogICBCT09MRUFO ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSXNWZXJpZmllZDsNCiAgIEVGSV9TSUdOQVRV UkVfTElTVCAgICAgICAgICAgICAgICAgICAqU2lnbmF0dXJlTGlzdDsNCiAgIFVJTlROICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBTaWduYXR1cmVMaXN0U2l6ZTsNCiAgIEVGSV9TSUdO QVRVUkVfREFUQSAgICAgICAgICAgICAgICAgICAqU2lnbmF0dXJlOw0KICAgRUZJX0lNQUdFX0VY RUNVVElPTl9BQ1RJT04gICAgICAgICAgIEFjdGlvbjsNCiAgIFdJTl9DRVJUSUZJQ0FURSAgICAg ICAgICAgICAgICAgICAgICAqV2luQ2VydGlmaWNhdGU7DQogICBVSU5UMzIgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgUG9saWN5Ow0KICAgVUlOVDggICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICpTZWN1cmVCb290Ow0KICAgUEVfQ09GRl9MT0FERVJfSU1BR0VfQ09OVEVYVCAg ICAgICAgIEltYWdlQ29udGV4dDsNCiAgIFVJTlQzMiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICBOdW1iZXJPZlJ2YUFuZFNpemVzOw0KICAgV0lOX0NFUlRJRklDQVRFX0VGSV9QS0NTICAg ICAgICAgICAgICpQa2NzQ2VydERhdGE7DQogICBXSU5fQ0VSVElGSUNBVEVfVUVGSV9HVUlEICAg ICAgICAgICAgKldpbkNlcnRVZWZpR3VpZDsNCiAgIFVJTlQ4ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAqQXV0aERhdGE7DQogICBVSU5UTiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgQXV0aERhdGFTaXplOw0KICAgRUZJX0lNQUdFX0RBVEFfRElSRUNUT1JZICAgICAgICAg ICAgICpTZWNEYXRhRGlyOw0KICAgVUlOVDMyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IE9mZlNldDsNCiAgIENIQVIxNiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqTmFtZVN0 cjsNCiAgIFJFVFVSTl9TVEFUVVMgICAgICAgICAgICAgICAgICAgICAgICBQZUNvZmZTdGF0dXM7 DQogICBFRklfU1RBVFVTICAgICAgICAgICAgICAgICAgICAgICAgICAgSGFzaFN0YXR1czsNCiAN CiAgIFNpZ25hdHVyZUxpc3QgICAgID0gTlVMTDsNCiAgIFNpZ25hdHVyZUxpc3RTaXplID0gMDsN C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