From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-qg0-x236.google.com ([2607:f8b0:400d:c04::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aDrNJ-0006sP-P0 for barebox@lists.infradead.org; Tue, 29 Dec 2015 10:19:32 +0000 Received: by mail-qg0-x236.google.com with SMTP id 6so84248118qgy.1 for ; Tue, 29 Dec 2015 02:19:08 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1426171199-2729-4-git-send-email-jlu@pengutronix.de> References: <1426171199-2729-1-git-send-email-jlu@pengutronix.de> <1426171199-2729-4-git-send-email-jlu@pengutronix.de> From: Yegor Yefremov Date: Tue, 29 Dec 2015 11:18:48 +0100 Message-ID: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: [RFC 3/4] FIT: add FIT image support To: Jan Luebbe Cc: barebox@lists.infradead.org T24gVGh1LCBNYXIgMTIsIDIwMTUgYXQgMzozOSBQTSwgSmFuIEx1ZWJiZSA8amx1QHBlbmd1dHJv bml4LmRlPiB3cm90ZToKPiBUaGUgRklUIGltYWdlIGZvcm1hdCB3YXMgZGVmaW5lZCBmb3IgVS1C b290IGFuZCBoYXMgYmVlbiBhZG9wdGVkIGJ5IHRoZQo+IGRlcHRoY2hhcmdlIHByb2plY3QgYXMg d2VsbC4gSXQgaXMgaW50ZW5kZWQgdG8gYmUgYSByZXBsYWNlbWVudCBmb3IgdGhlCj4gdWltYWdl IGZvcm1hdCBhbmQgaGFzIGJlZW4gZXh0ZW5kZWQgdG8gc3VwcG9ydCBzaWduaW5nIG9mIGtlcm5l bCwKPiBpbml0cmFtZnMgYW5kIGRldmljZXRyZWUgaW1hZ2VzLiBUaGlzIHBhdGNoIGFkZHMgc3Vw cG9ydCBmb3IgYm9vdGluZy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RyaW5ncyA9IGZkdDMyX3RvX2NwdShmZHQtPnNp emVfZHRfc3RyaW5ncyk7Cj4gKwo+ICsgICAgICAgaWYgKGhhc2hlZF9zdHJpbmdzX3N0YXJ0ID4g Zi5zaXplX2R0X3N0cmluZ3MgfHwKPiArICAgICAgICAgICBoYXNoZWRfc3RyaW5nc19zaXplID4g Zi5zaXplX2R0X3N0cmluZ3MgfHwKPiArICAgICAgICAgICBoYXNoZWRfc3RyaW5nc19zdGFydCAr IGhhc2hlZF9zdHJpbmdzX3NpemUgPiBmLnNpemVfZHRfc3RyaW5ncykgewo+ICsgICAgICAgICAg ICAgICBwcl9lcnIoIiVzOiBoYXNoZWQtc3RyaW5ncyB0b28gbGFyZ2VcbiIsIF9fZnVuY19fKTsK PiArICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7Cj4gKyAgICAgICB9Cj4gKwo+ICsgICAg ICAgZHRfc3RydWN0ID0gZi5vZmZfZHRfc3RydWN0Owo+ICsgICAgICAgZHRfc3RyaW5ncyA9ICh2 b2lkICopZmR0ICsgZi5vZmZfZHRfc3RyaW5nczsKPiArCj4gKyAgICAgICBlbmQgPSBwYXRoOwo+ ICsgICAgICAgKmVuZCA9ICdcMCc7Cj4gKwo+ICsgICAgICAgZG8gewo+ICsgICAgICAgICAgICAg ICBjb25zdCBzdHJ1Y3QgZmR0X3Byb3BlcnR5ICpmZHRfcHJvcDsKPiArICAgICAgICAgICAgICAg Y29uc3Qgc3RydWN0IGZkdF9ub2RlX2hlYWRlciAqZm5oOwo+ICsgICAgICAgICAgICAgICBjb25z dCBjaGFyICpuYW1lOwo+ICsgICAgICAgICAgICAgICBpbnQgaW5jbHVkZSA9IDA7Cj4gKyAgICAg ICAgICAgICAgIGludCBzdG9wX2F0ID0gMDsKPiArICAgICAgICAgICAgICAgaW50IG9mZnNldCA9 IGR0X3N0cnVjdDsKPiArICAgICAgICAgICAgICAgaW50IG1heGxlbiwgbGVuOwo+ICsKPiArICAg ICAgICAgICAgICAgdGFnID0gYmUzMl90b19jcHUoKih1aW50MzJfdCAqKShmaXQgKyBkdF9zdHJ1 Y3QpKTsKPiArCj4gKyAgICAgICAgICAgICAgIHN3aXRjaCAodGFnKSB7Cj4gKyAgICAgICAgICAg ICAgIGNhc2UgRkRUX0JFR0lOX05PREU6Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgZm5oID0g Zml0ICsgZHRfc3RydWN0Owo+ICsgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSBmbmgtPm5h bWU7Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgbWF4bGVuID0gKHVuc2lnbmVkIGxvbmcpZmR0 ICsgZi5vZmZfZHRfc3RydWN0ICsKPiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGYu c2l6ZV9kdF9zdHJ1Y3QgLSAodW5zaWduZWQgbG9uZyluYW1lOwo+ICsKPiArICAgICAgICAgICAg ICAgICAgICAgICBsZW4gPSBzdHJubGVuKG5hbWUsIG1heGxlbiArIDEpOwo+ICsgICAgICAgICAg ICAgICAgICAgICAgIGlmIChsZW4gPiBtYXhsZW4pCj4gKyAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICByZXR1cm4gLUVTUElQRTsKPiArCj4gKyAgICAgICAgICAgICAgICAgICAgICAgZHRf c3RydWN0ID0gZHRfc3RydWN0X2FkdmFuY2UoJmYsIGR0X3N0cnVjdCwKPiArICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZW9mKHN0cnVjdCBmZHRfbm9kZV9oZWFkZXIp ICsgbGVuICsgMSk7Cj4gKwo+ICsgICAgICAgICAgICAgICAgICAgICAgIGRlcHRoKys7Cj4gKyAg ICAgICAgICAgICAgICAgICAgICAgaWYgKGRlcHRoID09IEZEVF9NQVhfREVQVEgpCj4gKyAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVTUElQRTsKPiArICAgICAgICAgICAg ICAgICAgICAgICBpZiAoZW5kIC0gcGF0aCArIDIgKyBsZW4gPj0gRkRUX01BWF9QQVRIX0xFTikK PiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRVNQSVBFOwo+ICsgICAg ICAgICAgICAgICAgICAgICAgIGlmIChlbmQgIT0gcGF0aCArIDEpCj4gKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAqZW5kKysgPSAnLyc7Cj4gKyAgICAgICAgICAgICAgICAgICAgICAg c3RyY3B5KGVuZCwgbmFtZSk7Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgZW5kICs9IGxlbjsK PiArICAgICAgICAgICAgICAgICAgICAgICBzdGFja1tkZXB0aF0gPSB3YW50Owo+ICsgICAgICAg ICAgICAgICAgICAgICAgIGlmICh3YW50ID09IDEpCj4gKyAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICBzdG9wX2F0ID0gb2Zmc2V0Owo+ICsgICAgICAgICAgICAgICAgICAgICAgIGlmIChz dHJpbmdfbGlzdF9jb250YWlucyhpbmNfbm9kZXMsIHBhdGgpKQo+ICsgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgd2FudCA9IDI7Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgZWxzZSBp ZiAod2FudCkKPiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhbnQtLTsKPiArICAg ICAgICAgICAgICAgICAgICAgICBlbHNlCj4gKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBzdG9wX2F0ID0gb2Zmc2V0Owo+ICsgICAgICAgICAgICAgICAgICAgICAgIGluY2x1ZGUgPSB3 YW50Owo+ICsKPiArICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKPiArCj4gKyAgICAgICAg ICAgICAgIGNhc2UgRkRUX0VORF9OT0RFOgo+ICsgICAgICAgICAgICAgICAgICAgICAgIGR0X3N0 cnVjdCA9IGR0X3N0cnVjdF9hZHZhbmNlKCZmLCBkdF9zdHJ1Y3QsIEZEVF9UQUdTSVpFKTsKPiAr Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZSA9IHdhbnQ7Cj4gKyAgICAgICAgICAg ICAgICAgICAgICAgd2FudCA9IHN0YWNrW2RlcHRoLS1dOwo+ICsgICAgICAgICAgICAgICAgICAg ICAgIHdoaWxlIChlbmQgPiBwYXRoICYmICotLWVuZCAhPSAnLycpCj4gKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICA7Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgKmVuZCA9ICdcMCc7 Cj4gKwo+ICsgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwo+ICsKPiArICAgICAgICAgICAg ICAgY2FzZSBGRFRfUFJPUDoKPiArICAgICAgICAgICAgICAgICAgICAgICBmZHRfcHJvcCA9IGZp dCArIGR0X3N0cnVjdDsKPiArICAgICAgICAgICAgICAgICAgICAgICBsZW4gPSBmZHQzMl90b19j cHUoZmR0X3Byb3AtPmxlbik7Cj4gKwo+ICsgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSBk dF9zdHJpbmcoJmYsIGR0X3N0cmluZ3MsIGZkdDMyX3RvX2NwdShmZHRfcHJvcC0+bmFtZW9mZikp Owo+ICsgICAgICAgICAgICAgICAgICAgICAgIGlmICghbmFtZSkKPiArICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIHJldHVybiAtRVNQSVBFOwo+ICsKPiArICAgICAgICAgICAgICAgICAg ICAgICBkdF9zdHJ1Y3QgPSBkdF9zdHJ1Y3RfYWR2YW5jZSgmZiwgZHRfc3RydWN0LAo+ICsgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplb2Yoc3RydWN0IGZkdF9wcm9w ZXJ0eSkgKyBsZW4pOwo+ICsKPiArICAgICAgICAgICAgICAgICAgICAgICBpbmNsdWRlID0gd2Fu dCA+PSAyOwo+ICsgICAgICAgICAgICAgICAgICAgICAgIHN0b3BfYXQgPSBvZmZzZXQ7Cj4gKyAg ICAgICAgICAgICAgICAgICAgICAgaWYgKHN0cmluZ19saXN0X2NvbnRhaW5zKGV4Y19wcm9wcywg bmFtZSkpCj4gKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmNsdWRlID0gMDsKPiAr Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Cj4gKwo+ICsgICAgICAgICAgICAgICBj YXNlIEZEVF9OT1A6Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgZHRfc3RydWN0ID0gZHRfc3Ry dWN0X2FkdmFuY2UoJmYsIGR0X3N0cnVjdCwgRkRUX1RBR1NJWkUpOwo+ICsKPiArICAgICAgICAg ICAgICAgICAgICAgICBpbmNsdWRlID0gd2FudCA+PSAyOwo+ICsgICAgICAgICAgICAgICAgICAg ICAgIHN0b3BfYXQgPSBvZmZzZXQ7Cj4gKwo+ICsgICAgICAgICAgICAgICAgICAgICAgIGJyZWFr Owo+ICsKPiArICAgICAgICAgICAgICAgY2FzZSBGRFRfRU5EOgo+ICsgICAgICAgICAgICAgICAg ICAgICAgIGR0X3N0cnVjdCA9IGR0X3N0cnVjdF9hZHZhbmNlKCZmLCBkdF9zdHJ1Y3QsIEZEVF9U QUdTSVpFKTsKPiArCj4gKyAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZSA9IDE7Cj4gKwo+ ICsgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwo+ICsKPiArICAgICAgICAgICAgICAgZGVm YXVsdDoKPiArICAgICAgICAgICAgICAgICAgICAgICBwcl9lcnIoIiVzOiBVbmtub3duIHRhZyAw eCUwOFhcbiIsIF9fZnVuY19fLCB0YWcpOwo+ICsgICAgICAgICAgICAgICAgICAgICAgIHJldHVy biAtRUlOVkFMOwo+ICsgICAgICAgICAgICAgICB9Cj4gKwo+ICsgICAgICAgICAgICAgICBpZiAo IWR0X3N0cnVjdCkKPiArICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVTUElQRTsKPiAr Cj4gKyAgICAgICAgICA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0gLUVJTlZBTDsKPiAr ICAgICAgICAgICAgICAgZ290byBvdXQ7Cj4gKyAgICAgICB9Cj4gKyAgICAgICBpZiAoc3RyY21w KGFsZ29fbmFtZSwgInNoYTEscnNhMjA0OCIpID09IDApIHsKPiArICAgICAgICAgICAgICAgYWxn byA9IEhBU0hfQUxHT19TSEExOwo+ICsgICAgICAgfSBlbHNlIHsKPiArICAgICAgICAgICAgICAg cHJfZXJyKCJ1bmtub3duIGFsZ28gJXNcbiIsIGFsZ29fbmFtZSk7Cj4gKyAgICAgICAgICAgICAg IHJldCA9IC1FSU5WQUw7Cj4gKyAgICAgICAgICAgICAgIGdvdG8gb3V0Owo+ICsgICAgICAgfQo+ ICsgICAgICAgZGlnZXN0ID0gZGlnZXN0X2dldChhbGdvKTsKPiArICAgICAgIGlmICghZGlnZXN0 KSB7Cj4gKyAgICAgICAgICAgICAgIHByX2VycigidW5zdXBwb3J0ZWQgYWxnbyAlc1xuIiwgYWxn b19uYW1lKTsKPiArICAgICAgICAgICAgICAgcmV0ID0gLUVJTlZBTDsKPiArICAgICAgICAgICAg ICAgZ290byBvdXQ7Cj4gKyAgICAgICB9Cj4gKwo+ICsgICAgICAgc2lnX3ZhbHVlID0gb2ZfZ2V0 X3Byb3BlcnR5KHNpZ19ub2RlLCAidmFsdWUiLCAmc2lnX2xlbik7Cj4gKyAgICAgICBpZiAoIXNp Z192YWx1ZSkgewo+ICsgICAgICAgICAgICAgICBwcl9lcnIoInNpZ25hdHVyZSB2YWx1ZSBub3Qg Zm91bmRcbiIpOwo+ICsgICAgICAgICAgICAgICByZXQgPSAtRUlOVkFMOwo+ICsgICAgICAgICAg ICAgICBnb3RvIG91dDsKPiArICAgICAgIH0KPiArCj4gKyAgICAgICBpZiAob2ZfcHJvcGVydHlf cmVhZF9zdHJpbmcoc2lnX25vZGUsICJrZXktbmFtZS1oaW50IiwgJmtleV9uYW1lKSkgewo+ICsg ICAgICAgICAgICAgICBwcl9lcnIoImtleSBuYW1lIG5vdCBmb3VuZFxuIik7Cj4gKyAgICAgICAg ICAgICAgIHJldCA9IC1FSU5WQUw7Cj4gKyAgICAgICAgICAgICAgIGdvdG8gb3V0Owo+ICsgICAg ICAgfQo+ICsgICAgICAga2V5X3BhdGggPSBhc3ByaW50ZigiL3NpZ25hdHVyZS9rZXktJXMiLCBr ZXlfbmFtZSk7Cj4gKyAgICAgICBpZiAoIWtleV9uYW1lKSB7Cj4gKyAgICAgICAgICAgICAgIHJl dCA9IC1FTk9NRU07Cj4gKyAgICAgICAgICAgICAgIGdvdG8gb3V0Owo+ICsgICAgICAgfQo+ICsg ICAgICAga2V5X25vZGUgPSBvZl9maW5kX25vZGVfYnlfcGF0aChrZXlfcGF0aCk7Cj4gKyAgICAg ICBmcmVlKGtleV9wYXRoKTsKPiArICAgICAgIGlmICgha2V5X25vZGUpIHsKPiArICAgICAgICAg ICAgICAgcHJfaW5mbygiZmFpbGVkIHRvIGZpbmQga2V5IG5vZGVcbiIpOwo+ICsgICAgICAgICAg ICAgICByZXQgPSAtRU5PRU5UOwo+ICsgICAgICAgICAgICAgICBnb3RvIG91dDsKPiArICAgICAg IH0KPiArCj4gKyAgICAgICByZXQgPSByc2Ffb2ZfcmVhZF9rZXkoa2V5X25vZGUsICZrZXkpOwo+ ICsgICAgICAgaWYgKHJldCkgewo+ICsgICAgICAgICAgICAgICBwcl9pbmZvKCJmYWlsZWQgdG8g cmVhZCBrZXlcbiIpOwo+ICsgICAgICAgICAgICAgICByZXQgPSAtRU5PRU5UOwo+ICsgICAgICAg ICAgICAgICBnb3RvIG91dDsKPiArICAgICAgIH0KPiArCj4gKyAgICAgICBpZiAob2ZfcHJvcGVy dHlfcmVhZF91MzJfaW5kZXgoc2lnX25vZGUsICJoYXNoZWQtc3RyaW5ncyIsIDAsICZoYXNoZWRf c3RyaW5nc19zdGFydCkpIHsKPiArICAgICAgICAgICAgICAgcHJfZXJyKCIlczogaGFzaGVkLXN0 cmluZ3Mgc3RhcnQgbm90IGZvdW5kXG4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YywgaGFzaF9sZW4pKSB7 Cj4gKyAgICAgICAgICAgICAgIHByX2luZm8oImhhc2ggQkFEXG4iKTsKPiArICAgICAgICAgICAg ICAgcmV0dXJuIENIRUNLX0xFVkVMX05PTkU7Cj4gKyAgICAgICB9IGVsc2Ugewo+ICsgICAgICAg ICAgICAgICBwcl9pbmZvKCJoYXNoIE9LXG4iKTsKPiArICAgICAgICAgICAgICAgcmV0dXJuIENI RUNLX0xFVkVMX0hBU0g7Cj4gKyAgICAgICB9Cj4gK30KPiArCj4gK3N0YXRpYyBpbnQgZml0X29w ZW5faW1hZ2Uoc3RydWN0IGZpdF9oYW5kbGUgKmhhbmRsZSwgY29uc3QgY2hhciogdW5pdCkKPiAr ewo+ICsgICAgICAgc3RydWN0IGRldmljZV9ub2RlICppbWFnZSA9IE5VTEwsICpoYXNoOwo+ICsg ICAgICAgY29uc3QgY2hhciAqdHlwZSA9IE5VTEwsICpkZXNjOwo+ICsgICAgICAgY29uc3Qgdm9p ZCAqZGF0YTsKPiArICAgICAgIGludCBkYXRhX2xlbjsKPiArICAgICAgIGludCByZXQsIGxldmVs Owo+ICsKPiArICAgICAgIGltYWdlID0gb2ZfZ2V0X2NoaWxkX2J5X25hbWUoaGFuZGxlLT5yb290 LCAiaW1hZ2VzIik7Cj4gKyAgICAgICBpZiAoIWltYWdlKQo+ICsgICAgICAgICAgICAgICByZXR1 cm4gLUVOT0VOVDsKPiArCj4gKyAgICAgICBpbWFnZSA9IG9mX2dldF9jaGlsZF9ieV9uYW1lKGlt YWdlLCB1bml0KTsKPiArICAgICAgIGlmICghaW1hZ2UpCj4gKyAgICAgICAgICAgICAgIHJldHVy biAtRU5PRU5UOwo+ICsKPiArICAgICAgIGlmIChvZl9wcm9wZXJ0eV9yZWFkX3N0cmluZyhpbWFn ZSwgImRlc2NyaXB0aW9uIiwgJmRlc2MpKSB7Cj4gKyAgICAgICAgICAgICAgIHByX2luZm8oIkZJ VCBpbWFnZSAnJXMnIChubyBkZXNjcmlwdGlvbilcbiIsIHVuaXQpOwo+ICsgICAgICAgfSBlbHNl IHsKPiArICAgICAgICAgICAgICAgcHJfaW5mbygiRklUIGltYWdlICclcyc6ICclcydcbiIsIHVu aXQsIGRlc2MpOwo+ICsgICAgICAgfQo+ICsKPiArICAgICAgIG9mX3Byb3BlcnR5X3JlYWRfc3Ry aW5nKGltYWdlLCAidHlwZSIsICZ0eXBlKTsKPiArICAgICAgIGlmICghdHlwZSkKPiArICAgICAg ICAgICAgICAgcmV0dXJuIC1FSU5WQUw7Cj4gKwo+ICsgICAgICAgZGF0YSA9IG9mX2dldF9wcm9w ZXJ0eShpbWFnZSwgImRhdGEiLCAmZGF0YV9sZW4pOwo+ICsgICAgICAgaWYgKCFkYXRhKSB7Cj4g KyAgICAgICAgICAgICAgIHByX2VycigiZGF0YSBub3QgZm91bmRcbiIpOwo+ICsgICAgICAgICAg ICAgICByZXR1cm4gLUVJTlZBTDsKPiArICAgICAgIH0KPiArCj4gKyAgICAgICBsZXZlbCA9IENI RUNLX0xFVkVMX01BWDsKPiArICAgICAgIGZvcl9lYWNoX2NoaWxkX29mX25vZGUoaW1hZ2UsIGhh c2gpIHsKPiArICAgICAgICAgICAgICAgaWYgKGhhbmRsZS0+dmVyYm9zZSkKPiArICAgICAgICAg ICAgICAgICAgICAgICBvZl9wcmludF9ub2RlcyhoYXNoLCAwKTsKPiArICAgICAgICAgICAgICAg cmV0ID0gZml0X3ZlcmlmeV9oYXNoKGhhc2gsIGRhdGEsIGRhdGFfbGVuKTsKPiArICAgICAgICAg ICAgICAgaWYgKHJldCA8IDApCj4gKyAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJldDsK PiArICAgICAgICAgICAgICAgbGV2ZWwgPSBtaW4obGV2ZWwsIHJldCk7Cj4gKyAgICAgICB9Cj4g KyAgICAgICBpZiAobGV2ZWwgPT0gQ0hFQ0tfTEVWRUxfTUFYKSB7Cj4gKyAgICAgICAgICAgICAg IHJldHVybiAtRUlOVkFMOwo+ICsgICAgICAgfQo+ICsKPiArICAgICAgIGlmIChsZXZlbCA9PSBD SEVDS19MRVZFTF9IQVNIKSB7Cj4gKyAgICAgICAgICAgICAgIGlmIChzdHJjbXAodHlwZSwgImtl cm5lbCIpID09IDAgfHwKPiArICAgICAgICAgICAgICAgICAgICAgICBzdHJjbXAodHlwZSwgImtl cm5lbF9ub2xvYWQiKSA9PSAwKSB7Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlLT5r ZXJuZWwgPSBkYXRhOwo+ICsgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZS0+a2VybmVsX3Np emUgPSBkYXRhX2xlbjsKPiArICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdHJjbXAodHlwZSwg ImZsYXRfZHQiKSA9PSAwKSB7Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlLT5vZnRy ZWUgPSBkYXRhOwo+ICsgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZS0+b2Z0cmVlX3NpemUg PSBkYXRhX2xlbjsKPiArICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdHJjbXAodHlwZSwgInJh bWRpc2siKSA9PSAwKSB7Cj4gKyAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlLT5pbml0cmQg PSBkYXRhOwo+ICsgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZS0+aW5pdHJkX3NpemUgPSBk YXRhX2xlbjsKPiArICAgICAgICAgICAgICAgfSBlbHNlIHsKPiArICAgICAgICAgICAgICAgICAg ICAgICBwcl9pbmZvKCJ1bmtub3duIGltYWdlIHR5cGUgJXMsIGlnbm9yaW5nXG4iLCB0eXBlKTsK PiArICAgICAgICAgICAgICAgfQo+ICsgICAgICAgfQo+ICsKPiArICAgICAgIHJldHVybiBsZXZl bDsKPiArfQo+ICsKPiArc3RhdGljIGludCBmaXRfb3Blbl9jb25maWd1cmF0aW9uKHN0cnVjdCBm aXRfaGFuZGxlICpoYW5kbGUsIGludCBudW0pCj4gK3sKPiArICAgICAgIHN0cnVjdCBkZXZpY2Vf bm9kZSAqY29uZl9ub2RlID0gTlVMTCwgKnNpZ19ub2RlOwo+ICsgICAgICAgY2hhciB1bml0X25h bWVbMTBdOwo+ICsgICAgICAgY29uc3QgY2hhciAqdW5pdCwgKmRlc2M7Cj4gKyAgICAgICBpbnQg cmV0LCBsZXZlbDsKPiArCj4gKyAgICAgICBjb25mX25vZGUgPSBvZl9nZXRfY2hpbGRfYnlfbmFt ZShoYW5kbGUtPnJvb3QsICJjb25maWd1cmF0aW9ucyIpOwo+ICsgICAgICAgaWYgKCFjb25mX25v ZGUpCj4gKyAgICAgICAgICAgICAgIHJldHVybiAtRU5PRU5UOwo+ICsKPiArICAgICAgIGlmIChu dW0pIHsKPiArICAgICAgICAgICAgICAgc25wcmludGYodW5pdF9uYW1lLCBzaXplb2YodW5pdF9u YW1lKSwgImNvbmZAJWQiLCBudW0pOwoKd29ya3MgZm9yIG1lIHdpdGggdGhpcyBjaGFuZ2U6Cgog ICAgICAgICAgICAgICBzbnByaW50Zih1bml0X25hbWUsIHNpemVvZih1bml0X25hbWUpLCAiY29u ZiVkQDEiLCBudW0pOwoKPiArICAgICAgICAgICAgICAgdW5pdCA9IHVuaXRfbmFtZTsKPiArICAg ICAgIH0gZWxzZSBpZiAob2ZfcHJvcGVydHlfcmVhZF9zdHJpbmcoY29uZl9ub2RlLCAiZGVmYXVs dCIsICZ1bml0KSkgewo+ICsgICAgICAgICAgICAgICB1bml0ID0gImNvbmZAMSI7Cj4gKyAgICAg ICB9Cj4gKwo+ICsgICAgICAgY29uZl9ub2RlID0gb2ZfZ2V0X2NoaWxkX2J5X25hbWUoY29uZl9u b2RlLCB1bml0KTsKPiArICAgICAgIGlmICghY29uZl9ub2RlKSB7Cj4gKyAgICAgICAgICAgICAg IHByX2VycigiRklUIGNvbmZpZ3VyYXRpb24gJyVzJyBub3QgZm91bmRcbiIsIHVuaXQpOwo+ICsg ICAgICAgICAgICAgICByZXR1cm4gLUVOT0VOVDsKPiArICAgICAgIH0KPiArCj4gKyAgICAgICBp ZiAob2ZfcHJvcGVydHlfcmVhZF9zdHJpbmcoY29uZl9ub2RlLCAiZGVzY3JpcHRpb24iLCAmZGVz YykpIHsKPiArICAgICAgICAgICAgICAgcHJfaW5mbygiRklUIGNvbmZpZ3VyYXRpb24gJyVzJyAo bm8gZGVzY3JpcHRpb24pXG4iLCB1bml0KTsKPiArICAgICAgIH0gZWxzZSB7Cj4gKyAgICAgICAg ICAgICAgIHByX2luZm8oIkZJVCBjb25maWd1cmF0aW9uICclcyc6ICclcydcbiIsIHVuaXQsIGRl c2MpOwo+ICsgICAgICAgfQo+ICsKPiArICAgICAgIGxldmVsID0gQ0hFQ0tfTEVWRUxfTUFYOwo+ ICsgICAgICAgZm9yX2VhY2hfY2hpbGRfb2Zfbm9kZShjb25mX25vZGUsIHNpZ19ub2RlKSB7Cj4g KyAgICAgICAgICAgICAgIGlmIChoYW5kbGUtPnZlcmJvc2UpCj4gKyAgICAgICAgICAgICAgICAg ICAgICAgb2ZfcHJpbnRfbm9kZXMoc2lnX25vZGUsIDApOwo+ICsgICAgICAgICAgICAgICByZXQg PSBmaXRfdmVyaWZ5X3NpZ25hdHVyZShzaWdfbm9kZSwgaGFuZGxlLT5maXQpOwo+ICsgICAgICAg ICAgICAgICBpZiAocmV0IDwgMCkKPiArICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmV0 Owo+ICsgICAgICAgICAgICAgICBsZXZlbCA9IG1pbihsZXZlbCwgcmV0KTsKPiArICAgICAgIH0K PiArICAgICAgIGlmIChsZXZlbCA9PSBDSEVDS19MRVZFTF9NQVgpCj4gKyAgICAgICAgICAgICAg IHJldHVybiAtRUlOVkFMOwo+ICsKPiArICAgICAgIGlmIChsZXZlbCAhPSBDSEVDS19MRVZFTF9T SUcpCj4gKyAgICAgICAgICAgICAgIHJldHVybiAtRUlOVkFMOwo+ICsKPiArICAgICAgIGlmIChv Zl9wcm9wZXJ0eV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