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.web09.1484.1579201646001811597 for ; Thu, 16 Jan 2020 11:07:26 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VSFzZt/U; 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=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=LUWxuW3RW2u9MziP7+WKvjlR55YKzzFdVo7ulv8DMVY=; b=VSFzZt/UjZuR8NTK1h+i+Atj6PpZGkZLFJbizfhmFMvXD5eO2+0TqQ6oRyEC1bvwrwQLAZ MTd10UVfzpQn20k7WMMeOvL4GPtB97+njOeFReBvnT3fmThr9aX53BfeocKk336kaP7Xhj 2H7zp1GUZtVdlbf1tbGeyPqe0A18n0Y= 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-342-dskqzkfXN5Ko-_8bbFv60Q-1; Thu, 16 Jan 2020 14:07:23 -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 251FD107ACCA; Thu, 16 Jan 2020 19:07:22 +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 0595580890; Thu, 16 Jan 2020 19:07:20 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Chao Zhang , Jian J Wang , Jiewen Yao Subject: [PATCH 09/11] SecurityPkg/DxeImageVerificationHandler: fix retval for (FileBuffer==NULL) Date: Thu, 16 Jan 2020 20:07:03 +0100 Message-Id: <20200116190705.18816-10-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: dskqzkfXN5Ko-_8bbFv60Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: base64 IkZpbGVCdWZmZXIiIGlzIGEgbm9uLW9wdGlvbmFsIGlucHV0IChwb2ludGVyKSBwYXJhbWV0ZXIg dG8KRHhlSW1hZ2VWZXJpZmljYXRpb25IYW5kbGVyKCkuIE5vcm1hbGx5LCB3aGVuIGFuIGVkazIg ZnVuY3Rpb24gcmVjZWl2ZXMgYQpOVUxMIGFyZ3VtZW50IGZvciBzdWNoIGEgcGFyYW1ldGVyLCB3 ZSByZXR1cm4gRUZJX0lOVkFMSURfUEFSQU1FVEVSIG9yClJFVFVSTl9JTlZBTElEX1BBUkFNRVRF Ui4gSG93ZXZlciwgdGhvc2UgZG9uJ3QgY29uZm9ybSB0byB0aGUKU0VDVVJJVFkyX0ZJTEVfQVVU SEVOVElDQVRJT05fSEFORExFUiBwcm90b3R5cGUuCgpSZXR1cm4gRUZJX0FDQ0VTU19ERU5JRUQg d2hlbiAiRmlsZUJ1ZmZlciIgaXMgTlVMTDsgaXQgbWVhbnMgdGhhdCBubyBpbWFnZQpoYXMgYmVl biBsb2FkZWQuCgpUaGlzIHBhdGNoIGRvZXMgbm90IGNoYW5nZSB0aGUgY29udHJvbCBmbG93IGlu IHRoZSBmdW5jdGlvbiwgaXQgb25seQpjaGFuZ2VzIHRoZSAiU3RhdHVzIiBvdXRjb21lIGZyb20g QVBJLWluY29tcGF0aWJsZSBlc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FnZVZlcmlmaWNhdGlvbkxpYi5jCkBAIC0xNTU1LDM0MyArMTU1NSwzNDMgQEAgRUZJ QVBJCiBEeGVJbWFnZVZlcmlmaWNhdGlvbkhhbmRsZXIgKA0KICAgSU4gIFVJTlQzMiAgICAgICAg ICAgICAgICAgICAgICAgICAgIEF1dGhlbnRpY2F0aW9uU3RhdHVzLA0KICAgSU4gIENPTlNUIEVG SV9ERVZJQ0VfUEFUSF9QUk9UT0NPTCAgICpGaWxlLA0KICAgSU4gIFZPSUQgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICpGaWxlQnVmZmVyLA0KICAgSU4gIFVJTlROICAgICAgICAgICAgICAg ICAgICAgICAgICAgIEZpbGVTaXplLA0KICAgSU4gIEJPT0xFQU4gICAgICAgICAgICAgICAgICAg ICAgICAgIEJvb3RQb2xpY3kNCiAgICkNCiB7DQogICBFRklfSU1BR0VfRE9TX0hFQURFUiAgICAg ICAgICAgICAgICAgKkRvc0hkcjsNCiAgIEJPT0xFQU4gICAgICAgICAgICAgICAgICAgICAgICAg ICAgICBJc1ZlcmlmaWVkOw0KICAgRUZJX1NJR05BVFVSRV9MSVNUICAgICAgICAgICAgICAgICAg ICpTaWduYXR1cmVMaXN0Ow0KICAgVUlOVE4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IFNpZ25hdHVyZUxpc3RTaXplOw0KICAgRUZJX1NJR05BVFVSRV9EQVRBICAgICAgICAgICAgICAg ICAgICpTaWduYXR1cmU7DQogICBFRklfSU1BR0VfRVhFQ1VUSU9OX0FDVElPTiAgICAgICAgICAg QWN0aW9uOw0KICAgV0lOX0NFUlRJRklDQVRFICAgICAgICAgICAgICAgICAgICAgICpXaW5DZXJ0 aWZpY2F0ZTsNCiAgIFVJTlQzMiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBQb2xpY3k7 DQogICBVSU5UOCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKlNlY3VyZUJvb3Q7DQog ICBQRV9DT0ZGX0xPQURFUl9JTUFHRV9DT05URVhUICAgICAgICAgSW1hZ2VDb250ZXh0Ow0KICAg VUlOVDMyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE51bWJlck9mUnZhQW5kU2l6ZXM7 DQogICBXSU5fQ0VSVElGSUNBVEVfRUZJX1BLQ1MgICAgICAgICAgICAgKlBrY3NDZXJ0RGF0YTsN CiAgIFdJTl9DRVJUSUZJQ0FURV9VRUZJX0dVSUQgICAgICAgICAgICAqV2luQ2VydFVlZmlHdWlk Ow0KICAgVUlOVDggICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICpBdXRoRGF0YTsNCiAg IFVJTlROICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdXRoRGF0YVNpemU7DQogICBF RklfSU1BR0VfREFUQV9ESVJFQ1RPUlkgICAgICAgICAgICAgKlNlY0RhdGFEaXI7DQogICBVSU5U MzIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT2ZmU2V0Ow0KICAgQ0hBUjE2ICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICpOYW1lU3RyOw0KICAgUkVUVVJOX1NUQVRVUyAgICAg ICAgICAgICAgICAgICAgICAgIFBlQ29mZlN0YXR1czsNCiAgIEVGSV9TVEFUVVMgICAgICAgICAg ICAgICAgICAgICAgICAgICBIYXNoU3RhdHVzOw0KIA0KICAgU2lnbmF0dXJlTGlzdCAgICAgPSBO VUxMOw0KICAgU2lnbmF0dXJlTGlzdFNpemUgPSAwOw0KICAgV2luQ2VydGlmaWNhdGUgICAgPSBO VUxMOw0KICAgU2VjRGF0YURpciAgICAgICAgPSBOVUxMOw0KICAgUGtjc0NlcnREYXRhICAgICAg PSBOVUxMOw0KICAgQWN0aW9uICAgICAgICAgICAgPSBFRklfSU1BR0VfRVhFQ1VUSU9OX0FVVEhf VU5URVNURUQ7DQogICBJc1ZlcmlmaWVkICAgICAgICA9IEZBTFNFOw0KIA0KIA0KICAgLy8NCiAg IC8vIENoZWNrIHRo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