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AgICAgICAgICAgICAgICAgICAgY29uc3QgU3RyaW5nMTYmIG9wUGFja2FnZU5hbWUsIGludCBjbGllbnRVaWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzE2ICZjbGllbnRQYWNrYWdlTmFtZSwgaW50IGNsaWVudFVpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLypvdXQqL3NwPElDYW1lcmE+JiBkZXZpY2UpCiAgICAgewogICAgICAgICBQYXJjZWwgZGF0YSwgcmVwbHk7CkBAIC0xOTUsMTIgKzE5OSwxNSBAQAogICAgICAgICBkYXRhLndyaXRlU3Ryb25nQmluZGVyKElJbnRlcmZhY2U6OmFzQmluZGVyKGNhbWVyYUNsaWVudCkpOwogICAgICAgICBkYXRhLndyaXRlSW50MzIoY2FtZXJhSWQpOwogICAgICAgICBkYXRhLndyaXRlSW50MzIoaGFsVmVyc2lvbik7Ci0gICAgICAgIGRhdGEud3JpdGVTdHJpbmcxNihvcFBhY2thZ2VOYW1lKTsKKyAgICAgICAgZGF0YS53cml0ZVN0cmluZzE2KGNsaWVudFBhY2thZ2VOYW1lKTsKICAgICAgICAgZGF0YS53cml0ZUludDMyKGNsaWVudFVpZCk7Ci0gICAgICAgIHJlbW90ZSgpLT50cmFuc2FjdChCbkNhbWVyYVNlcnZpY2U6OkNPTk5FQ1RfTEVHQUNZLCBkYXRhLCAmcmVwbHkpOworCisgICAgICAgIHN0YXR1c190IHN0YXR1czsKKyAgICAgICAgc3RhdHVzID0gcmVtb3RlKCktPnRyYW5zYWN0KEJuQ2FtZXJhU2VydmljZTo6Q09OTkVDVF9MRUdBQ1ksIGRhdGEsICZyZXBseSk7CisgICAgICAgIGlmIChzdGF0dXMgIT0gT0spIHJldHVybiBzdGF0dXM7CiAKICAgICAgICAgaWYgKHJlYWRFeGNlcHRpb25Db2RlKHJlcGx5KSkgcmV0dXJuIC1FUFJPVE87Ci0gICAgICAgIHN0YXR1c190IHN0YXR1cyA9IHJlcGx5LnJlYWRJbnQzMigpOworICAgICAgICBzdGF0dXMgPSByZXBseS5yZWFkSW50MzIoKTsKICAgICAgICAgaWYgKHJlcGx5LnJlYWRJbnQzMigpICE9IDApIHsKICAgICAgICAgICAgIGRldmljZSA9IGludGVyZmFjZV9jYXN0PElDYW1lcmE+KHJlcGx5LnJlYWRTdHJvbmdCaW5kZXIoKSk7CiAgICAgICAgIH0KQEAgLTIyNSw3ICsyMzIsNyBAQAogICAgIHZpcnR1YWwgc3RhdHVzX3QgY29ubmVjdERldmljZSgKICAgICAgICAgICAgIGNvbnN0IHNwPElDYW1lcmFEZXZpY2VDYWxsYmFja3M+JiBjYW1lcmFDYiwKICAgICAgICAgICAgIGludCBjYW1lcmFJZCwKLSAgICAgICAgICAgIGNvbnN0IFN0cmluZzE2JiBvcFBhY2thZ2VOYW1lLAorICAgICAgICAgICAgY29uc3QgU3RyaW5nMTYmIGNsaWVudFBhY2thZ2VOYW1lLAogICAgICAgICAgICAgaW50IGNsaWVudFVpZCwKICAgICAgICAgICAgIC8qb3V0Ki8KICAgICAgICAgICAgIHNwPElDYW1lcmFEZXZpY2VVc2VyPiYgZGV2aWNlKQpAQCAtMjM0LDEyICsyNDEsMTUgQEAKICAgICAgICAgZGF0YS53cml0ZUludGVyZmFjZVRva2VuKElDYW1lcmFTZXJ2aWNlOjpnZXRJbnRlcmZhY2VEZXNjcmlwdG9yKCkpOwogICAgICAgICBkYXRhLndyaXRlU3Ryb25nQmluZGVyKElJbnRlcmZhY2U6OmFzQmluZGVyKGNhbWVyYUNiKSk7CiAgICAgICAgIGRhdGEud3JpdGVJbnQzMihjYW1lcmFJZCk7Ci0gICAgICAgIGRhdGEud3JpdGVTdHJpbmcxNihvcFBhY2thZ2VOYW1lKTsKKyAgICAgICAgZGF0YS53cml0ZVN0cmluZzE2KGNsaWVudFBhY2thZ2VOYW1lKTsKICAgICAgICAgZGF0YS53cml0ZUludDMyKGNsaWVudFVpZCk7Ci0gICAgICAgIHJlbW90ZSgpLT50cmFuc2FjdChCbkNhbWVyYVNlcnZpY2U6OkNPTk5FQ1RfREVWSUNFLCBkYXRhLCAmcmVwbHkpOworCisgICAgICAgIHN0YXR1c190IHN0YXR1czsKKyAgICAgICAgc3RhdHVzID0gcmVtb3RlKCktPnRyYW5zYWN0KEJuQ2FtZXJhU2VydmljZTo6Q09OTkVDVF9ERVZJQ0UsIGRhdGEsICZyZXBseSk7CisgICAgICAgIGlmIChzdGF0dXMgIT0gT0spIHJldHVybiBzdGF0dXM7CiAKICAgICAgICAgaWYgKHJlYWRFeGNlcHRpb25Db2RlKHJlcGx5KSkgcmV0dXJuIC1FUFJPVE87Ci0gICAgICAgIHN0YXR1c190IHN0YXR1cyA9IHJlcGx5LnJlYWRJbnQzMigpOworICAgICAgICBzdGF0dXMgPSByZXBseS5yZWFkSW50MzIoKTsKICAgICAgICAgaWYgKHJlcGx5LnJlYWRJbnQzMigpICE9IDApIHsKICAgICAgICAgICAgIGRldmljZSA9IGludGVyZmFjZV9jYXN0PElDYW1lcmFEZXZpY2VVc2VyPihyZXBseS5yZWFkU3Ryb25nQmluZGVyKCkpOwogICAgICAgICB9CkBAIC0zMDMsMTAgKzMxMywxMCBAQAogICAgICAgICByZXR1cm4gcmVzOwogICAgIH0KIAotICAgIHZpcnR1YWwgdm9pZCBub3RpZnlTeXN0ZW1FdmVudChpbnQgZXZlbnRJZCwgaW50IGFyZzApIHsKKyAgICB2aXJ0dWFsIHZvaWQgbm90aWZ5U3lzdGVtRXZlbnQoaW50MzJfdCBldmVudElkLCBjb25zdCBpbnQzMl90KiBhcmdzLCBzaXplX3QgbGVuKSB7CiAgICAgICAgIFBhcmNlbCBkYXRhLCByZXBseTsKICAgICAgICAgZGF0YS53cml0ZUludDMyKGV2ZW50SWQpOwotICAgICAgICBkYXRhLndyaXRlSW50MzIoYXJnMCk7CisgICAgICAgIGRhdGEud3JpdGVJbnQzMkFycmF5KGxlbiwgYXJncyk7CiAgICAgICAgIHJlbW90ZSgpLT50cmFuc2FjdChCbkNhbWVyYVNlcnZpY2U6Ok5PVElGWV9TWVNURU1fRVZFTlQsIGRhdGEsICZyZXBseSwKICAgICAgICAgICAgICAgICBJQmluZGVyOjpGTEFHX09ORVdBWSk7CiAgICAgfQpAQCAtMzc0LDExICszODQsMTEgQEAKICAgICAgICAgICAgIHNwPElDYW1lcmFDbGllbnQ+IGNhbWVyYUNsaWVudCA9CiAgICAgICAgICAgICAgICAgICAgIGludGVyZmFjZV9jYXN0PElDYW1lcmFDbGllbnQ+KGRhdGEucmVhZFN0cm9uZ0JpbmRlcigpKTsKICAgICAgICAgICAgIGludDMyX3QgY2FtZXJhSWQgPSBkYXRhLnJlYWRJbnQzMigpOwotICAgICAgICAgICAgY29uc3QgU3RyaW5nMTYgb3BQYWNrYWdlTmFtZSA9IGRhdGEucmVhZFN0cmluZzE2KCk7CisgICAgICAgICAgICBjb25zdCBTdHJpbmcxNiBjbGllbnROYW1lID0gZGF0YS5yZWFkU3RyaW5nMTYoKTsKICAgICAgICAgICAgIGludDMyX3QgY2xpZW50VWlkID0gZGF0YS5yZWFkSW50MzIoKTsKICAgICAgICAgICAgIHNwPElDYW1lcmE+IGNhbWVyYTsKICAgICAgICAgICAgIHN0YXR1c190IHN0YXR1cyA9IGNvbm5lY3QoY2FtZXJhQ2xpZW50LCBjYW1lcmFJZCwKLSAgICAgICAgICAgICAgICAgICAgb3BQYWNrYWdlTmFtZSwgY2xpZW50VWlkLCAvKm91dCovY2FtZXJhKTsKKyAgICAgICAgICAgICAgICAgICAgY2xpZW50TmFtZSwgY2xpZW50VWlkLCAvKm91dCovY2FtZXJhKTsKICAgICAgICAgICAgIHJlcGx5LT53cml0ZU5vRXhjZXB0aW9uKCk7CiAgICAgICAgICAgICByZXBseS0+d3JpdGVJbnQzMihzdGF0dXMpOwogICAgICAgICAgICAgaWYgKGNhbWVyYSAhPSBOVUxMKSB7CkBAIC0zOTQsMTEgKzQwNCwxMSBAQAogICAgICAgICAgICAgc3A8SUNhbWVyYURldmljZUNhbGxiYWNrcz4gY2FtZXJhQ2xpZW50ID0KICAgICAgICAgICAgICAgICBpbnRlcmZhY2VfY2FzdDxJQ2FtZXJhRGV2aWNlQ2FsbGJhY2tzPihkYXRhLnJlYWRTdHJvbmdCaW5kZXIoKSk7CiAgICAgICAgICAgICBpbnQzMl90IGNhbWVyYUlkID0gZGF0YS5yZWFkSW50MzIoKTsKLSAgICAgICAgICAgIGNvbnN0IFN0cmluZzE2IG9wUGFja2FnZU5hbWUgPSBkYXRhLnJlYWRTdHJpbmcxNigpOworICAgICAgICAgICAgY29uc3QgU3RyaW5nMTYgY2xpZW50TmFtZSA9IGRhdGEucmVhZFN0cmluZzE2KCk7CiAgICAgICAgICAgICBpbnQzMl90IGNsaWVudFVpZCA9IGRhdGEucmVhZEludDMyKCk7CiAgICAgICAgICAgICBzcDxJQ2FtZXJhRGV2aWNlVXNlcj4gY2FtZXJhOwogICAgICAgICAgICAgc3RhdHVzX3Qgc3RhdHVzID0gY29ubmVjdERldmljZShjYW1lcmFDbGllbnQsIGNhbWVyYUlkLAotICAgICAgICAgICAgICAgICAgICBvcFBhY2thZ2VOYW1lLCBjbGllbnRVaWQsIC8qb3V0Ki9jYW1lcmEpOworICAgICAgICAgICAgICAgICAgICBjbGllbnROYW1lLCBjbGllbnRVaWQsIC8qb3V0Ki9jYW1lcmEpOwogICAgICAgICAgICAgcmVwbHktPndyaXRlTm9FeGNlcHRpb24oKTsKICAgICAgICAgICAgIHJlcGx5LT53cml0ZUludDMyKHN0YXR1cyk7CiAgICAgICAgICAgICBpZiAoY2FtZXJhICE9IE5VTEwpIHsKQEAgLTQ1NCwxMSArNDY0LDExIEBACiAgICAgICAgICAgICAgICAgICAgIGludGVyZmFjZV9jYXN0PElDYW1lcmFDbGllbnQ+KGRhdGEucmVhZFN0cm9uZ0JpbmRlcigpKTsKICAgICAgICAgICAgIGludDMyX3QgY2FtZXJhSWQgPSBkYXRhLnJlYWRJbnQzMigpOwogICAgICAgICAgICAgaW50MzJfdCBoYWxWZXJzaW9uID0gZGF0YS5yZWFkSW50MzIoKTsKLSAgICAgICAgICAgIGNvbnN0IFN0cmluZzE2IG9wUGFja2FnZU5hbWUgPSBkYXRhLnJlYWRTdHJpbmcxNigpOworICAgICAgICAgICAgY29uc3QgU3RyaW5nMTYgY2xpZW50TmFtZSA9IGRhdGEucmVhZFN0cmluZzE2KCk7CiAgICAgICAgICAgICBpbnQzMl90IGNsaWVudFVpZCA9IGRhdGEucmVhZEludDMyKCk7CiAgICAgICAgICAgICBzcDxJQ2FtZXJhPiBjYW1lcmE7CiAgICAgICAgICAgICBzdGF0dXNfdCBzdGF0dXMgPSBjb25uZWN0TGVnYWN5KGNhbWVyYUNsaWVudCwgY2FtZXJhSWQsIGhhbFZlcnNpb24sCi0gICAgICAgICAgICAgICAgICAgIG9wUGFja2FnZU5hbWUsIGNsaWVudFVpZCwgLypvdXQqL2NhbWVyYSk7CisgICAgICAgICAgICAgICAgICAgIGNsaWVudE5hbWUsIGNsaWVudFVpZCwgLypvdXQqL2NhbWVyYSk7CiAgICAgICAgICAgICByZXBseS0+d3JpdGVOb0V4Y2VwdGlvbigpOwogICAgICAgICAgICAgcmVwbHktPndyaXRlSW50MzIoc3RhdHVzKTsKICAgICAgICAgICAgIGlmIChjYW1lcmEgIT0gTlVMTCkgewpAQCAtNDgxLDkgKzQ5MSwyNyBAQAogICAgICAgICB9IGJyZWFrOwogICAgICAgICBjYXNlIE5PVElGWV9TWVNURU1fRVZFTlQ6IHsKICAgICAgICAgICAgIENIRUNLX0lOVEVSRkFDRShJQ2FtZXJhU2VydmljZSwgZGF0YSwgcmVwbHkpOwotICAgICAgICAgICAgaW50IGV2ZW50SWQgPSBkYXRhLnJlYWRJbnQzMigpOwotICAgICAgICAgICAgaW50IGFyZzAgPSBkYXRhLnJlYWRJbnQzMigpOwotICAgICAgICAgICAgbm90aWZ5U3lzdGVtRXZlbnQoZXZlbnRJZCwgYXJnMCk7CisgICAgICAgICAgICBpbnQzMl90IGV2ZW50SWQgPSBkYXRhLnJlYWRJbnQzMigpOworICAgICAgICAgICAgaW50MzJfdCBsZW4gPSBkYXRhLnJlYWRJbnQzMigpOworICAgICAgICAgICAgaWYgKGxlbiA8IDApIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFJlY2VpdmVkIHBvb3JseSBmb3JtYXR0ZWQgbGVuZ3RoIGluIGJpbmRlciByZXF1ZXN0OiBub3RpZnlTeXN0ZW1FdmVudC4iLAorICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gRkFJTEVEX1RSQU5TQUNUSU9OOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKGxlbiA+IDUxMikgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogTGVuZ3RoICUiIFBSSWkzMiAiIHRvbyBsb25nIGluIGJpbmRlciByZXF1ZXN0OiBub3RpZnlTeXN0ZW1FdmVudC4iLAorICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBsZW4pOworICAgICAgICAgICAgICAgIHJldHVybiBGQUlMRURfVFJBTlNBQ1RJT047CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpbnQzMl90IGV2ZW50c1tsZW5dOworICAgICAgICAgICAgbWVtc2V0KGV2ZW50cywgMCwgc2l6ZW9mKGludDMyX3QpICogbGVuKTsKKyAgICAgICAgICAgIHN0YXR1c190IHN0YXR1cyA9IGRhdGEucmVhZChldmVudHMsIHNpemVvZihpbnQzMl90KSAqIGxlbik7CisgICAgICAgICAgICBpZiAoc3RhdHVzICE9IE5PX0VSUk9SKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBSZWNlaXZlZCBwb29ybHkgZm9ybWF0dGVkIGJpbmRlciByZXF1ZXN0OiBub3RpZnlTeXN0ZW1FdmVudC4iLAorICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgICAgICBy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KCkKKyAgICB2aXJ0dWFsIHN0YXR1c190IGVuZENvbmZpZ3VyZShib29sIGlzQ29uc3RyYWluZWRIaWdoU3BlZWQpCiAgICAgewogICAgICAgICBBTE9HVigiZW5kQ29uZmlndXJlIik7CiAgICAgICAgIFBhcmNlbCBkYXRhLCByZXBseTsKICAgICAgICAgZGF0YS53cml0ZUludGVyZmFjZVRva2VuKElDYW1lcmFEZXZpY2VVc2VyOjpnZXRJbnRlcmZhY2VEZXNjcmlwdG9yKCkpOworICAgICAgICBkYXRhLndyaXRlSW50MzIoaXNDb25zdHJhaW5lZEhpZ2hTcGVlZCk7CisKICAgICAgICAgcmVtb3RlKCktPnRyYW5zYWN0KEVORF9DT05GSUdVUkUsIGRhdGEsICZyZXBseSk7CiAgICAgICAgIHJlcGx5LnJlYWRFeGNlcHRpb25Db2RlKCk7CiAgICAgICAgIHJldHVybiByZXBseS5yZWFkSW50MzIoKTsKQEAgLTU1Niw4ICs1NTgsOSBAQAogICAgICAgICB9IGJyZWFrOwogICAgICAgICBjYXNlIEVORF9DT05GSUdVUkU6IHsKICAgICAgICAgICAgIENIRUNLX0lOVEVSRkFDRShJQ2FtZXJhRGV2aWNlVXNlciwgZGF0YSwgcmVwbHkpOworICAgICAgICAgICAgYm9vbCBpc0NvbnN0cmFpbmVkSGlnaFNwZWVkID0gZGF0YS5yZWFkSW50MzIoKTsKICAgICAgICAgICAgIHJlcGx5LT53cml0ZU5vRXhjZXB0aW9uKCk7Ci0gICAgICAgICAgICByZXBseS0+d3JpdGVJbnQzMihlbmRDb25maWd1cmUoKSk7CisgICAgICAgICAgICByZXBseS0+d3JpdGVJbnQzMihlbmRDb25maWd1cmUoaXNDb25zdHJhaW5lZEhpZ2hTcGVlZCkpOwogICAgICAgICAgICAgcmV0dXJuIE5PX0VSUk9SOwogICAgICAgICB9IGJyZWFrOwogICAgICAgICBjYXNlIFBSRVBBUkU6IHsKZGlmZiAtLWdpdCBhL2NtZHMvc3RhZ2VmcmlnaHQvbXV4ZXIuY3BwIGIvY21kcy9zdGFnZWZyaWdodC9tdXhlci5jcHAKaW5kZXggMDAyOWFlYy4uMzZmYTNiNSAxMDA2NDQKLS0tIGEvY21kcy9zdGFnZWZyaWdodC9tdXhlci5jcHAKKysrIGIvY21kcy9zdGFnZWZyaWdodC9tdXhlci5jcHAKQEAgLTE0Miw4ICsxNDIsMTMgQEAKICAgICAgICAgQ0hFQ0tfRVEoZXJyLCAoc3RhdHVzX3QpT0spOwogCiAgICAgICAgIHNzaXplX3QgbmV3VHJhY2tJbmRleCA9IG11eGVyLT5hZGRUcmFjayhmb3JtYXQpOwotICAgICAgICBDSEVDS19HRShuZXdUcmFja0luZGV4LCAwKTsKLSAgICAgICAgdHJhY2tJbmRleE1hcC5hZGQoaSwgbmV3VHJhY2tJbmRleCk7CisgICAgICAgIGlmIChuZXdUcmFja0luZGV4IDwgMCkgeworICAgICAgICAgICAgZnByaW50ZihzdGRlcnIsICIlcyB0cmFjayAoJXp1KSB1bnN1cHBvcnRlZCBieSBtdXhlclxuIiwKKyAgICAgICAgICAgICAgICAgICAgaXNBdWRpbyA/ICJhdWRpbyIgOiAidmlkZW8iLAorICAgICAgICAgICAgICAgICAgICBpKTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIHRyYWNrSW5kZXhNYXAuYWRkKGksIG5ld1RyYWNrSW5kZXgpOworICAgICAgICB9CiAgICAgfQogCiAgICAgaW50NjRfdCBtdXhlclN0YXJ0VGltZVVzID0gQUxvb3Blcjo6R2V0Tm93VXMoKTsKQEAgLTE2Miw3ICsxNjcsMTIgQEAKICAgICAgICAgICAgIEFMT0dWKCJzYXcgaW5wdXQgZW9zLCBlcnIgJWQiLCBlcnIpOwogICAgICAgICAgICAgc2F3SW5wdXRFT1MgPSB0cnVlOwogICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0gZWxzZSBpZiAodHJhY2tJbmRleE1hcC5pbmRleE9mS2V5KHRyYWNrSW5kZXgpIDwgMCkgeworICAg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XJhQ2IsCiAgICAgICAgICAgICBpbnQgY2FtZXJhSWQsCi0gICAgICAgICAgICBjb25zdCBTdHJpbmcxNiYgb3BQYWNrYWdlTmFtZSwKKyAgICAgICAgICAgIGNvbnN0IFN0cmluZzE2JiBjbGllbnRQYWNrYWdlTmFtZSwKICAgICAgICAgICAgIGludCBjbGllbnRVaWQsCiAgICAgICAgICAgICAvKm91dCovCiAgICAgICAgICAgICBzcDxJQ2FtZXJhRGV2aWNlVXNlcj4mIGRldmljZSkgPSAwOwpAQCAtMTQxLDcgKzE0MSw3IEBACiAgICAgICovCiAgICAgdmlydHVhbCBzdGF0dXNfdCBjb25uZWN0TGVnYWN5KGNvbnN0IHNwPElDYW1lcmFDbGllbnQ+JiBjYW1lcmFDbGllbnQsCiAgICAgICAgICAgICBpbnQgY2FtZXJhSWQsIGludCBoYWxWZXJzaW9uLAotICAgICAgICAgICAgY29uc3QgU3RyaW5nMTYmIG9wUGFja2FnZU5hbWUsCisgICAgICAgICAgICBjb25zdCBTdHJpbmcxNiYgY2xpZW50UGFja2FnZU5hbWUsCiAgICAgICAgICAgICBpbnQgY2xpZW50VWlkLAogICAgICAgICAgICAgLypvdXQqLwogICAgICAgICAgICAgc3A8SUNhbWVyYT4mIGRldmljZSkgPSAwOwpAQCAtMTY0LDcgKzE2NCw3IEBACiAgICAgLyoqCiAgICAgICogTm90aWZ5IHRoZSBjYW1lcmEgc2VydmljZSBvZiBhIHN5c3RlbSBldmVudC4gIFNob3VsZCBvbmx5IGJlIGNhbGxlZCBmcm9tIHN5c3RlbV9zZXJ2ZXIuCiAgICAgICovCi0gICAgdmlydHVhbCB2b2lkIG5vdGlmeVN5c3RlbUV2ZW50KGludCBldmVudElkLCBpbnQgYXJnMCkgPSAwOworICAgIHZpcnR1YWwgdm9pZCBub3RpZnlTeXN0ZW1FdmVudChpbnQzMl90IGV2ZW50SWQsIGNvbnN0IGludDMyX3QqIGFyZ3MsIHNpemVfdCBsZW5ndGgpID0gMDsKIH07CiAK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PSBtRWZmZWN0LnByb21vdGUoKTsKKyAgICAgICAgICAgIGlmIChlZmZlY3QgIT0gMCkgeworICAgICAgICAgICAgICAgIGVmZmVjdC0+ZW5hYmxlU3RhdHVzQ2hhbmdlZChlbmFibGVkKTsKKyAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgICAgICB2aXJ0dWFsIHZvaWQgY29tbWFuZEV4ZWN1dGVkKHVpbnQzMl90IGNtZENvZGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3QgY21kU2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2b2lkICpwQ21kRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCByZXBseVNpemUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdm9pZCAqcFJlcGx5RGF0YSkgewotICAgICAgICAgICAgbUVmZmVjdC0+Y29tbWFuZEV4ZWN1dGVkKGNtZENvZGUsIGNtZFNpemUsIHBDbWREYXRhLCByZXBseVNpemUsIHBSZXBseURhdGEpOworICAgICAgICAgICAgc3A8QXVkaW9FZmZlY3Q+IGVmZmVjdCA9IG1FZmZlY3QucHJvbW90ZSgpOworICAgICAgICAgICAgaWYgKGVmZmVjdCAhPSAwKSB7CisgICAgICAgICAgICAgICAgZWZmZWN0LT5jb21tYW5kRXhlY3V0ZWQoCisgICAgICAgICAgICAgICAgICAgIGNtZENvZGUsIGNtZFNpemUsIHBDbWREYXRhLCByZXBseVNpemUsIHBSZXBseURhdGEpOworICAgICAgICAgICAgfQogICAgICAgICB9CiAKICAgICAgICAgLy8gSUJpbmRlcjo6RGVhdGhSZWNpcGllbnQKLSAgICAgICAgdmlydHVhbCB2b2lkIGJpbmRlckRpZWQoY29uc3Qgd3A8SUJpbmRlcj4mIHdobykge21FZmZlY3QtPmJpbmRlckRpZWQoKTt9CisgICAgICAgIHZpcnR1YWwgdm9pZCBiaW5kZ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Rpb0RldmljZUNhbGxiYWNrKCkge30KKworICAgICAgICB2aXJ0dWFsIHZvaWQgb25BdWRpb0RldmljZVVwZGF0ZShhdWRpb19pb19oYW5kbGVfdCBhdWRpb0lvLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90IGRldmljZUlkKSA9IDA7CisgICAgfTsKKworICAgIHN0YXRpYyBzdGF0dXNfdCBhZGRBdWRpb0RldmljZUNhbGxiYWNrKGNvbnN0IHNwPEF1ZGlvRGV2aWNlQ2FsbGJhY2s+JiBjYWxsYmFjaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19pb19oYW5kbGVfdCBhdWRpb0lvKTsKKyAgICBzdGF0aWMgc3RhdHVzX3QgcmVtb3ZlQXVkaW9EZXZpY2VDYWxsYmFjayhjb25zdCBzcDxBdWRpb0RldmljZUNhbGxiYWNrPiYgY2FsbGJhY2ssCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3QgYXVkaW9Jbyk7CisKKyAgICBzdGF0aWMgYXVkaW9fcG9ydF9oYW5kbGVfdCBnZXREZXZpY2VJZEZvcklvKGF1ZGlvX2lvX2hhbmRsZV90IGF1ZGlvSW8pOwogCiBwcml2YXRlOgogCkBAIC0zNTksMTAgKzM4MCwyMCBAQAogICAgICAgICAvLyB2YWx1ZXMgZm9yIG91dHB1dC9pbnB1dCBwYXJhbWV0ZXJzIHVwLXRvLWRhdGUgaW4gY2xpZW50IHByb2Nlc3MKICAgICAgICAgdmlydHVhbCB2b2lkIGlvQ29uZmlnQ2hhbmdlZChhdWRpb19pb19jb25maWdfZXZlbnQgZXZlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3A8QXVkaW9Jb0Rlc2NyaXB0b3I+JiBpb0Rlc2MpOworCisKKyAgICAgICAgc3RhdHVzX3QgYWRkQXVkaW9EZXZpY2VDYWxsYmFjayhjb25zdCBzcDxBdWRpb0RldmljZUNhbGxiYWNrPiYgY2FsbGJhY2ssCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2lvX2hhbmRsZV90IGF1ZGlvSW8pOworICAgICAgICBzdGF0dXNfdCByZW1vdmVBdWRpb0RldmljZUNhbGxiYWNrKGNvbnN0IHNwPEF1ZGlvRGV2aWNlQ2FsbGJhY2s+JiBjYWxsYmFjaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19pb19oYW5kbGVfdCBhdWRpb0lvKTsKKworICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90IGdldERldmljZUlkRm9ySW8oYXVkaW9faW9faGFuZGxlX3QgYXVkaW9Jbyk7CisKICAgICBwcml2YXRlOgogICAgICAgICBNdXRleCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTG9jazsKLSAgICAgICAgRGVmYXVsdEtleWVkVmVjdG9yPGF1ZGlvX2lvX2hhbmRsZV90LCBzcDxBdWRpb0lvRGVzY3JpcHRvcj4gPiBtSW9EZXNjcmlwdG9yczsKLQorICAgICAgICBEZWZhdWx0S2V5ZWRWZWN0b3I8YXVkaW9faW9faGFuZGxlX3QsIHNwPEF1ZGlvSW9EZXNjcmlwdG9yPiA+ICAgbUlvRGVzY3JpcHRvcnM7CisgICAgICAgIERlZmF1bHRLZXllZFZlY3RvcjxhdWRpb19pb19oYW5kbGVfdCwgVmVjdG9yIDwgc3A8QXVkaW9EZXZpY2VDYWxsYmFjaz4gPiA+CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQXVkaW9EZXZpY2VDYWxsYmFja3M7CiAgICAgICAgIC8vIGNhY2hlZCB2YWx1ZXMgZm9yIHJlY29yZGluZyBnZXRJbnB1dEJ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gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gZG9lcyBub3Qgd2FudCB0byB3cml0ZSBtb3JlIGRhdGEsIHRoZSBoYW5kbGVyIG11c3QKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGlnbm9yZSB0aGUgZXZlbnQgYnkgc2V0dGluZyBmcmFtZUNvdW50IHRvIHplcm8uCi0gICAgICAgIEVWRU5UX1VOREVSUlVOID0gMSwgICAgICAgICAvLyBCdWZmZXIgdW5kZXJydW4gb2NjdXJyZWQuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBUaGlzIG1pZ2h0IG9jY3VyLCBmb3IgZXhhbXBsZSwgaWYgdGhlIGFwcGxpY2F0aW9uIGlzCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyB3YWl0aW5nIGZvciBzb3VyY2UgZGF0YSBvciBpcyBhdCB0aGUgZW5kIG9mIHN0cmVhbS4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBGb3IgZGF0YSBmaWxsaW5nLCBpdCBpcyBwcmVmZXJyZWQgdGhhdCB0aGUgY2FsbGJhY2sKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGRvZXMgbm90IGJsb2NrIGFuZCBpbnN0ZWFkIHJldHVybnMgYSBzaG9ydCBjb3VudCBvbgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gdGhlIGFtb3VudCBvZiBkYXRhIGFjdHVhbGx5IGRlbGl2ZXJlZAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gKG9yIDAsIGlmIG5vIGRhdGEgaXMgY3VycmVudGx5IGF2YWlsYWJsZSkuCisgICAgICAgIEVWRU5UX1VOREVSUlVOID0gMSwgICAgICAgICAvLyBCdWZmZXIgdW5kZXJydW4gb2NjdXJyZWQuIFRoaXMgd2lsbCBub3Qgb2NjdXIgZm9yCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBzdGF0aWMgdHJhY2tzLgogICAgICAgICBFVkVOVF9MT09QX0VORCA9IDIsICAgICAgICAgLy8gU2FtcGxlIGxvb3AgZW5kIHdhcyByZWFjaGVkOyBwbGF5YmFjayByZXN0YXJ0ZWQgZnJvbQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gbG9vcCBzdGFydCBpZiBsb29wIGNvdW50IHdhcyBub3QgMC4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGxvb3Agc3RhcnQgaWYgbG9vcCBjb3VudCB3YXMgbm90IDAgZm9yIGEgc3RhdGljIHRyYWNrLgogICAgICAgICBFVkVOVF9NQVJLRVIgPSAzLCAgICAgICAgICAgLy8gUGxheWJhY2sgaGVhZCBpcyBhdCB0aGUgc3BlY2lmaWVkIG1hcmtlciBwb3NpdGlvbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gKFNlZSBzZXRNYXJrZXJQb3NpdGlvbigpKS4KICAgICAgICAgRVZFTlRfTkVXX1BPUyA9IDQsICAgICAgICAgIC8vIFBsYXliYWNrIGhlYWQgaXMgYXQgYSBuZXcgcG9zaXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIChTZWUgc2V0UG9zaXRpb25VcGRhdGVQZXJpb2QoKSkuCi0gICAgICAgIEVWRU5UX0JVRkZFUl9FTkQgPSA1LCAgICAgICAvLyBQbGF5YmFjayBoZWFkIGlzIGF0IHRoZSBlbmQgb2YgdGhlIGJ1ZmZlci4KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIE5vdCBjdXJyZW50bHkgdXNlZCBieSBhbmRyb2lkLm1lZGlhLkF1ZGlvVHJhY2suCisgICAgICAgIEVWRU5UX0JVRkZFUl9FTkQgPSA1LCAgICAgICAvLyBQbGF5YmFjayBoYXMgY29tcGxldGVkIGZvciBhIHN0YXRpYyB0cmFjay4KICAgICAgICAgRVZFTlRfTkVXX0lBVURJT1RSQUNLID0gNiwgIC8vIElBdWRpb1RyYWNrIHdhcyByZS1jcmVhdGVkLCBlaXRoZXIgZHVlIHRvIHJlLXJvdXRpbmcgYW5kCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyB2b2x1bnRhcnkgaW52YWxpZGF0aW9uIGJ5IG1lZGlhc2VydmVyLCBvciBtZWRpYXNlcnZlciBjcmFzaC4KICAgICAgICAgRVZFTlRfU1RSRUFNX0VORCA9IDcsICAgICAgIC8vIFNlbnQgYWZ0ZXIgYWxsIHRoZSBidWZmZXJzIHF1ZXVlZCBpbiBBRiBhbmQgSFcgYXJlIHBsYXllZAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYmFjayAoYWZ0ZXIgc3RvcCBpcyBjYWxsZWQpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBiYWNrIChhZnRlciBzdG9wIGlzIGNhbGxlZCkgZm9yIGFuIG9mZmxvYWRlZCB0cmFjay4KKyNpZiAwICAgLy8gRklYTUUgbm90IHlldCBpbXBsZW1lbnRlZAogICAgICAgICBFVkVOVF9ORVdfVElNRVNUQU1QID0gOCwgICAgLy8gRGVsaXZlcmVkIHBlcmlvZGljYWxseSBhbmQgd2hlbiB0aGVyZSdzIGEgc2lnbmlmaWNhbnQgY2hhbmdlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpbiB0aGUgbWFwcGluZyBmcm9tIGZyYW1lIHBvc2l0aW9uIHRvIHByZXNlbnRhdGlvbiB0aW1lLgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gU2VlIEF1ZGlvVGltZXN0YW1wIGZvciB0aGUgaW5mb3JtYXRpb24gaW5jbHVkZWQgd2l0aCBldmVudC4KKyNlbmRpZgogICA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EBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19vZmZsb2FkX2luZm9fdCAqb2ZmbG9hZEluZm8gPSBOVUxMLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IHVpZCA9IC0xLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGlkX3QgcGlkID0gLTEsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QqIHBBdHRyaWJ1dGVzID0gTlVMTCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QqIHBBdHRyaWJ1dGVzID0gTlVMTCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgZG9Ob3RSZWNvbm5lY3QgPSBmYWxzZSk7CiAKICAgICAvKiBDcmVhdGVzIGFuIGF1ZGlvIHRyYWNrIGFuZCByZWdpc3RlcnMgaXQgd2l0aCBBdWRpb0ZsaW5nZXIuCiAgICAgICogV2l0aCB0aGlzIGNvbnN0cnVjdG9yLCB0aGUgdHJhY2sgaXMgY29uZmlndXJlZCBmb3Igc3RhdGljIGJ1ZmZlciBtb2RlLgpAQCAtMjI4LDcgKzI0Myw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19vZmZsb2FkX2luZm9fdCAqb2ZmbG9hZEluZm8gPSBOVUxMLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IHVpZCA9IC0xLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGlkX3QgcGlkID0gLTEsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QqIHBBdHRyaWJ1dGVzID0gTlVMTCk7CisgICAgICAgICAgIC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R1cEdsaXRjaFJlcG9ydGVkOyAvLyByZWR1Y2UgbG9nIHNwYW0KICAgICBib29sICAgICAgICAgICAgICAgICAgICBtUmV0cm9ncmFkZU1vdGlvblJlcG9ydGVkOyAvLyByZWR1Y2UgbG9nIHNwYW0KICAgICBBdWRpb1RpbWVzdGFtcCAgICAgICAgICBtUHJldmlvdXNUaW1lc3RhbXA7ICAgICAvLyB1c2VkIHRvIGRldGVjdCByZXRyb2dyYWRlIG1vdGlvbgogCkBAIC04NDYsNiArOTAyLDggQEAKICAgICAgICAgLy8gY29uc3QgYWZ0ZXIgc2V0KCksIGV4Y2VwdCBmb3IgYml0cyBBVURJT19PVVRQVVRfRkxBR19GQVNUIGFuZCBBVURJT19PVVRQVVRfRkxBR19PRkZMT0FELgogICAgICAgICAvLyBtTG9jayBtdXN0IGJlIGhlbGQgdG8gcmVhZCBvciB3cml0ZSB0aG9zZSBiaXRzIHJlbGlhYmx5LgogCisgICAgYm9vbCAgICAgICAgICAgICAgICAgICAgbURvTm90UmVjb25uZWN0OworCiAgICAgaW50ICAgICAgICAgICAgICAgICAgICAgbVNlc3Npb25JZDsKICAgICBpbnQgICAgICAgICAgICAgICAgICAgICBtQXV4RWZmZWN0SWQ7CiAKQEAgLTg4NSw2ICs5NDMsOCBAQAogICAgIHVpbnQzMl90ICAgICAgICAgICAgICAgIG1TZXF1ZW5jZTsgICAgICAgICAgICAgIC8vIGluY3JlbWVudGVkIGZvciBlYWNoIG5ldyBJQXVkaW9UcmFjayBhdHRlbXB0CiAgICAgaW50ICAgICAgICAgICAgICAgICAgICAgbUNsaWVudFVpZDsKICAgICBwaWRfdCAgICAgICAgICAgICAgICAgICBtQ2xpZW50UGlkOworCisgICAgc3A8QXVkaW9TeXN0ZW06OkF1ZGlvRGV2aWNlQ2FsbGJhY2s+IG1EZXZpY2VDYWxsYmFjazsKIH07CiAKIGNsYXNzIFRpbWVkQXVkaW9UcmFjayA6IHB1YmxpYyBBdWRpb1RyYWNrCmRpZmYgLS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nZT4gJm1zZyk7CiAgICAgdmlydHVhbCB2b2lkIGluaXRpYXRlQ3JlYXRlSW5wdXRTdXJmYWNlKCk7Ci0gICAgdmlydHVhbCB2b2lkIGluaXRpYXRlVXNlUGVyc2lzdGVudElucHV0U3VyZmFjZSgKLSAgICAgICAgICAgIGNvbnN0IHNwPFBlcnNpc3RlbnRTdXJmYWNlPiAmc3VyZmFjZSk7CisgICAgdmlydHVhbCB2b2lkIGluaXRpYXRlU2V0SW5wdXRTdXJmYWNlKGNvbnN0IHNwPFBlcnNpc3RlbnRTdXJmYWNlPiAmc3VyZmFjZSk7CiAgICAgdmlydHVhbCB2b2lkIGluaXRpYXRlU3RhcnQoKTsKICAgICB2aXJ0dWFsIHZvaWQgaW5pdGlhdGVTaHV0ZG93bihib29sIGtlZXBDb21wb25lbnRBbGxvY2F0ZWQgPSBmYWxzZSk7CiAKQEAgLTEwOSw2ICsxMTAsNyBAQAogICAgIGVudW0gewogICAgICAgICBrV2hhdFNldHVwICAgICAgICAgICAgICAgICAgID0gJ3NldHUnLAogICAgICAgICBrV2hhdE9NWE1lc3NhZ2UgICAgICAgICAgICAgID0gJ29teCAnLAorICAgICAgICBrV2hhdE9NWE1lc3NhZ2VMaXN0ICAgICAgICAgID0gJ29teEwnLAogICAgICAgICBrV2hhdElucHV0QnVmZmVyRmlsbGVkICAgICAgID0gJ2lucEYnLAogICAgICAgICBrV2hhdE91dHB1dEJ1ZmZlckRyYWluZWQgICAgID0gJ291dEQnLAogICAgICAgICBrV2hhdFNodXRkb3duICAgICAgICAgICAgICAgID0gJ3NodXQnLApAQCAtMTE5LDEyICsxMjEsMTIgQEAKICAgICAgICAga1doYXRDb25maWd1cmVDb21wb25lbnQgICAgICA9ICdjb25mJywKICAgICAgICAga1doYXRTZXRTdXJmYWNlICAgICAgICAgICAgICA9ICdzZXRTJywKICAgICAgICAga1doYXRDcmVhdGVJbnB1dFN1cmZhY2UgICAgICA9ICdjaXNmJywKLSAgICAgICAga1doYXRVc2VQZXJzaXN0ZW50SW5wdXRTdXJmYWNlID0gJ3Bpc2YnLAorICAgICAgICBrV2hhdFNldElucHV0U3VyZmFjZSAgICAgICAgID0gJ3Npc2YnLAogICAgICAgICBrV2hhdFNpZ25hbEVuZE9mSW5wdXRTdHJlYW0gID0gJ2VvaXMnLAogICAgICAgICBrV2hhdFN0YXJ0ICAgICAgICAgICAgICAgICAgID0gJ3N0YXInLAogICAgICAgICBrV2hhdFJlcXVlc3RJRFJGcmFtZSAgICAgICAgID0gJ3JpZHInLAogICAgICAgICBrV2hhdFNldFBhcmFtZXRlcnMgICAgICAgICAgID0gJ3NldFAnLAotICAgICAgICBrV2hhdFN1Ym1pdE91dHB1dE1ldGFEYXRhQnVmZmVySWZFT1MgPSAnc3VibScsCisgICAgICAgIGtXaGF0U3VibWl0T3V0cHV0TWV0YWRhdGFCdWZmZXJJZkVPUyA9ICdzdWJtJywKICAgICAgICAga1doYXRPTVhEaWVkICAgICAgICAgICAgICAgICA9ICdPTVhkJywKICAgICAgICAga1doYXRSZWxlYXNlQ29kZWNJbnN0YW5jZSAgICA9ICdyZWxDJywKICAgICB9OwpAQCAtMTQ3LDE2ICsxNDksMzkgQEAKICAgICAgICAgICAgIE9XTkVEX0JZX1VQU1RSRUFNLAogICAgICAgICAgICAgT1dORURfQllfRE9XTlNUUkVBTSwKICAgICAgICAgICAgIE9XTkVEX0JZX05BVElWRV9XSU5ET1csCisgICAgICAgICAgICBVTlJFQ09HTklaRUQsICAgICAgICAgICAgLy8gbm90IGEgdHJhY2tlZCBidWZmZXIKICAgICAgICAgfTsKIAorICAgICAgICBzdGF0aWMgaW5saW5lIFN0YXR1cyBnZXRTYWZlU3RhdHVzKEJ1ZmZlckluZm8gKmluZm8pIHsKKyAgICAgICAgICAgIHJldHVybiBpbmZvID09IE5VTEwgPyBVTlJFQ09HTklaRUQgOiBpbmZvLT5tU3RhdHVzOworICAgICAgICB9CisKICAgICAgICAgSU9NWDo6YnVmZmVyX2lkIG1CdWZmZXJ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gZm9yIGEgZnJhbWUgcmVuZGVyZWQgb24gYSB0dW5uZWxlZCBzdXJmYWNlCisgICAgICAgIEluZm8oaW50NjRfdCBtZWRpYVRpbWVVcywgbnNlY3NfdCByZW5kZXJUaW1lTnMpCisgICAgICAgICAgICA6IG1NZWRpYVRpbWVVcyhtZWRpYVRpbWVVcyksCisgICAgICAgICAgICAgIG1SZW5kZXJUaW1lTnMocmVuZGVyVGltZU5zKSwKKyAgICAgICAgICAgICAgbUluZGV4KC0xKSwKKyAgICAgICAgICAgICAgbUdyYXBoaWNCdWZmZXIoTlVMTCksCisgICAgICAgICAgICAgIG1GZW5jZShOVUxMKSB7CisgICAgICAgIH0KKworICAgIHByaXZhdGU6CisgICAgICAgIGludDY0X3QgbU1lZGlhVGltZVVzOworICAgICAgICBuc2Vjc190IG1SZW5kZXJUaW1lTnM7CisgICAgICAgIHNzaXplX3QgbUluZGV4OyAgICAgICAgIC8vIHRvIGJlIHVzZWQgYnkgY2xpZW50CisgICAgICAgIHNwPEdyYXBoaWNCdWZmZXI+IG1HcmFwaGljQnVmZmVyOworICAgICAgICBzcDxGZW5jZT4gbUZlbmNlOworCisgICAgICAgIGZyaWVuZCBjbGFzcyBGcmFtZVJlbmRlclRyYWNrZXI7CisgICAgfTsKKworICAgIEZyYW1lUmVuZGVyVHJhY2tlcigpOworCisgICAgdm9pZCBzZXRDb21wb25lbnROYW1lKGNvbnN0IEFTdHJpbmcgJmNvbXBvbmVudE5hbWUpOworCisgICAgLy8gY2xlYXJzIGFsbCB0cmFja2VkIGZyYW1lcywgYW5kIHJlc2V0cyBsYXN0IHJlbmRlciB0aW1lCisgICAgdm9pZCBjbGVhcihuc2Vjc190IGxhc3RSZW5kZXJUaW1lTnMpOworCisgICAgLy8gY2FsbGVkIHdoZW4gfGdyYXBoaWNCdWZmZXJ8IGNvcnJlc3BvbmRpbmcgdG8gfG1lZGlhVGltZVVzfCBpcworICAgIC8vIHF1ZXVlZCB0byB0aGUgb3V0cHV0IHN1cm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FnZXJDbGllbnQ7CisKK3ByaXZhdGU6CiAgICAgZW51bSBTdGF0ZSB7CiAgICAgICAgIFVOSU5JVElBTElaRUQsCiAgICAgICAgIElOSVRJQUxJWklORywKQEAgLTE4OCw3ICsyMDAsNyBAQAogICAgICAgICBrV2hhdENvbmZpZ3VyZSAgICAgICAgICAgICAgICAgICAgICA9ICdjb25mJywKICAgICAgICAga1doYXRTZXRTdXJmYWNlICAgICAgICAgICAgICAgICAgICAgPSAnc1N1cicsCiAgICAgICAgIGtXaGF0Q3JlYXRlSW5wdXRTdXJmYWNlICAgICAgICAgICAgID0gJ2Npc2YnLAotICAgICAgICBrV2hhdFVzZVBlcnNpc3RlbnRJbnB1dFN1cmZhY2UgICAgICA9ICdwaXNmJywKKyAgICAgICAga1doYXRTZXRJbnB1dFN1cmZhY2UgICAgICAgICAgICAgICAgPSAnc2lzZicsCiAgICAgICAgIGtXaGF0U3RhcnQgICAgICAgICAgICAgICAgICAgICAgICAgID0gJ3N0cnQnLAogICAgICAgICBrV2hhdFN0b3AgICAgICAgICAgICAgICAgICAgICAgICAgICA9ICdzdG9wJywKICAgICAgICAga1doYXRSZWxlYXNlICAgICAgICAgICAgICAgICAgICAgICAgPSAncmVsZScsCkBAIC0yMDksNiArMjIxLDcgQEAKICAgICAgICAga1doYXRHZXROYW1lICAgICAgICAgICAgICAgICAgICAgICAgPSAnZ2V0TicsCiAgICAgICAgIGtXaGF0U2V0UGFyYW1ldGVycyAgICAgICAgICAgICAgICAgID0gJ3NldFAnLAogICAgICAgICBrV2hhdFNldENhbGxiYWNrICAgICAgICAgICAgICAgICAgICA9ICdzZXRDJywKKyAgICAgICAga1doYXRTZXROb3RpZmljYXRpb24gICAgICAgICAgICAgICAgPSAnc2V0TicsCiAgICAgfTsKIAogICAgIGVudW0gewpAQCAtMjI0LDYgKzIzNyw3IEBACiAgICAgICAgIGtGbGFnR2F0aGVyQ29kZWNTcGVjaWZpY0RhdGEgICAgPSA1MTIsCiAgICAgICAgIGtG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fRVJST1I6ICAgICAgICAgcmV0dXJuICJVTktOT1dOX0VSUk9SIjsKKyAgICAgICAgY2FzZSBOT19NRU1PUlk6ICAgICAgICAgICAgIHJldHVybiAiTk9fTUVNT1JZIjsKKyAgICAgICAgY2FzZSBJTlZBTElEX09QRVJBVElPTjogICAgIHJldHVybiAiSU5WQUxJRF9PUEVSQVRJT04iOworICAgICAgICBjYXNlIEJBRF9WQUxVRTogICAgICAgICAgICAgcmV0dXJuICJCQURfVkFMVUUiOworICAgICAgICBjYXNlIEJBRF9UWVBFOiAgICAgICAgICAgICAgcmV0dXJuICJCQURfVFlQRSI7CisgICAgICAgIGNhc2UgTkFNRV9OT1RfRk9VTkQ6ICAgICAgICByZXR1cm4gIk5BTUVfTk9UX0ZPVU5EIjsKKyAgICAgICAgY2FzZSBQRVJNSVNTSU9OX0RFTklFRDogICAgIHJldHVybiAiUEVSTUlTU0lPTl9ERU5JRUQiOworICAgICAgICBjYXNlIE5PX0lOSVQ6ICAgICAgICAgICAgICAgcmV0dXJuICJOT19JTklUIjsKKyAgICAgICAgY2FzZSBBTFJFQURZX0VYSVNUUzogICAgICAgIHJldHVybiAiQUxSRUFEWV9FWElTVFMiOworICAgICAgICBjYXNlIERFQURfT0JKRUNUOiAgICAgICAgICAgcmV0dXJuICJERUFEX09CSkVDVCI7CisgICAgICAgIGNhc2UgRkFJTEVEX1RSQU5TQUNUSU9OOiAgICByZXR1cm4gIkZBSUxFRF9UUkFOU0FDVElPTiI7CisgICAgICAgIGNhc2UgQkFEX0lOREVYOiAgICAgICAgICAgICByZXR1cm4gIkJBRF9JTkRFWCI7CisgICAgICAgIGNhc2UgTk9UX0VOT1VHSF9EQVRBOiAgICAgICByZXR1cm4gIk5PVF9FTk9VR0hfREFUQSI7CisgICAgICAgIGNhc2UgV09VTERfQkxPQ0s6ICAgICAgICAgICByZXR1cm4gIldPVUxEX0JMT0NLIjsKKyAgICAgICAgY2FzZSBUSU1FRF9PVVQ6ICAgICAgICAgICAgIHJld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cm9zcyA9IDA7CisgICAgZmxvYXQgZW5lcmd5QmFzc0Jvb3N0ID0gMDsKKyAgICBmbG9hdCBjcm9zc0NvcnJlY3Rpb24gPSAwOwogCiAgICAgLy9FUSBjb250cmlidXRpb24KICAgICBpZiAocENvbnRleHQtPnBCdW5kbGVkQ29udGV4dC0+YkVxdWFsaXplckVuYWJsZWQgPT0gTFZNX1RSVUUpIHsKICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBGSVZFQkFORF9OVU1CQU5EUzsgaSsrKSB7Ci0gICAgICAgICAgICBmbG9hdCBiYW5kRW5lcmd5ID0gKHBDb250ZXh0LT5wQnVuZGxlZENvbnRleHQtPmJhbmRHYWluZEJbaV0gKgotICAgICAgICAgICAgICAgICAgICBMaW1pdExldmVsX2JhbmRFbmVyZ3lDb250cmlidXRpb25baV0pLzE1LjA7CisgICAgICAgICAgICBmbG9hdCBiYW5kRmFjdG9yID0gcENvbnRleHQtPnBCdW5kbGVkQ29udGV4dC0+YmFuZEdhaW5kQltpXS8xNS4wOworICAgICAgICAgICAgZmxvYXQgYmFuZENvZWZmaWNpZW50ID0gTGltaXRMZXZlbF9iYW5kRW5lcmd5Q29lZmZpY2llbnRbaV07CisgICAgICAgICAgICBmbG9hdCBiYW5kRW5lcmd5ID0gYmFuZEZhY3RvciAqIGJhbmRDb2VmZmljaWVudCAqIGJhbmRDb2VmZmljaWVudDsKICAgICAgICAgICAgIGlmIChiYW5kRW5lcmd5ID4gMCkKICAgICAgICAgICAgICAgICBlbmVyZ3lDb250cmlidXRpb24gKz0gYmFuZEVuZXJneTsKICAgICAgICAgfQorCisgICAgICAgIC8vY3Jvc3MgRVEgY29lZmZpY2llbnRzCisgICAgICAgIGZsb2F0IGJhbmRGYWN0b3JTdW0gPSAwOworICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IEZJVkVCQU5EX05VTUJBTkRTLTE7IGkrKykgeworICAgICAgICAgICAgZmxvYXQgYmFuZEZhY3RvcjEgPSBwQ29udGV4dC0+cEJ1bmRsZWRDb250ZXh0LT5iYW5kR2FpbmRCW2ldLzE1LjA7CisgICAgICAgICAgICBmbG9hdCBiYW5kRmFjdG9yMiA9IHBDb250ZXh0LT5wQnVuZGxlZENvbnRleHQtPmJhbmRHYWluZEJbaSsxXS8xNS4wOworCisgICAgICAgICAgICBpZiAoYmFuZEZhY3RvcjEgPiAwICYmIGJhbmRGYWN0b3IyID4gMCkgeworICAgICAgICAgICAgICAgIGZsb2F0IGNyb3NzRW5lcmd5ID0gYmFuZEZhY3RvcjEgKiBiYW5kRmFjdG9yMiAqCisgICAgICAgICAgICAgICAgICAgICAgICBMaW1pdExldmVsX2JhbmRFbmVyZ3lDcm9zc0NvZWZmaWNpZW50W2ldOworICAgICAgICAgICAgICAgIGJhbmRGYWN0b3JTdW0gKz0gYmFuZEZhY3RvcjEgKiBiYW5kRmFjdG9yMjsKKworICAgICAgICAgICAgICAgIGlmIChjcm9zc0VuZXJneSA+IDApCisgICAgICAgICAgICAgICAgICAgIGVuZXJneUNyb3NzICs9IGNyb3NzRW5lcmd5OworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIGJhbmRGYWN0b3JTdW0gLT0gMS4wOworICAgICAgICBpZiAoYmFuZEZhY3RvclN1bSA+IDApCisgICAgICAgICAgICBjcm9zc0NvcnJlY3Rpb24gPSBiYW5kRmFjdG9yU3VtICogMC43OwogICAgIH0KIAogICAgIC8vQmFzc0Jvb3N0IGNvbnRyaWJ1dGlvbgogICAgIGlmIChwQ29udGV4dC0+cEJ1bmRsZWRDb250ZXh0LT5iQmFzc0VuYWJsZWQgPT0gTFZNX1RSVUUpIHsKLSAgICAgICAgZmxvYXQgYmFuZEVuZXJneSA9IChwQ29udGV4dC0+cEJ1bmRsZWRDb250ZXh0LT5CYXNzU3RyZW5ndGhTYXZlZCAqCi0gICAgICAgICAgICAgICAgTGltaXRMZXZlbF9iYXNzQm9vc3RFbmVyZ3lDb250cmlidXRpb24pLzEwMDAuMDsKLSAgICAgICAgaWYgKGJhbmRFbmVyZ3kgPiAwKQotICAgICAgICAgICAgZW5lcmd5Q29udHJpYnV0aW9uICs9IGJhbmRFbmVyZ3k7CisgICAgICAgIGZsb2F0IGJvb3N0RmFjdG9yID0gKHBDb250ZXh0LT5wQnVuZGxlZENvbnRleHQtPkJhc3NTdHJlbmd0aFNhdmVkKS8xMDAwLjA7CisgICAgICAgIGZsb2F0IGJvb3N0Q29lZmZpY2llbnQgPSBMaW1pdExldmVsX2Jhc3NCb29zdEVuZXJneUNvZWZmaWNpZW50OworCisgICAgICAgIGVuZXJneUNvbnRyaWJ1dGlvbiArPSBib29zdEZhY3RvciAqIGJvb3N0Q29lZmZpY2llbnQgKiBib29zdENvZWZmaWNpZW50OworCisgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgRklWRUJBTkRfTlVNQkFORFM7IGkrKykgeworICAgICAgICAgICAgZmxvYXQgYmFuZEZhY3RvciA9IHBDb250ZXh0LT5wQnVuZGxlZENvbnRleHQtPmJhbmRHYWluZEJbaV0vMTUuMDsKKyAgICAgICAgICAgIGZsb2F0IGJhbmRDcm9zc0NvZWZmaWNpZW50ID0gTGltaXRMZXZlbF9iYXNzQm9vc3RFbmVyZ3lDcm9zc0NvZWZmaWNpZW50W2ldOworICAgICAgICAgICAgZmxvYXQgYmFuZEVuZXJneSA9IGJvb3N0RmFjdG9yICogYmFuZEZhY3RvciAqCisgICAgICAgICAgICAgICAgICAgIGJhbmRDcm9zc0NvZWZmaWNpZW50OworICAgICAgICAgICAgaWYgKGJhbmRFbmVyZ3kgPiAwKQorICAgICAgICAgICAgICAgIGVuZXJneUJhc3NCb29zdCArPSBiYW5kRW5lcmd5OworICAgICAgICB9CiAgICAgfQogCiAgICAgLy9WaXJ0dWFsaXplciBjb250cmlidXRpb24KICAgICBpZiAocENvbnRleHQtPnBCdW5kbGVkQ29udGV4dC0+YlZpcnR1YWxpemVyRW5hYmxlZCA9PSBMVk1fVFJVRSkgewotICAgICAgICAgIC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wotICAgIGNhc2UgQVVESU9fT1VUUFVUX0NMT1NFRDoKLSAgICBjYXNlIEFVRElPX0lOUFVUX0NMT1NFRDogewotICAgICAgICBpZiAoZ2V0SW9EZXNjcmlwdG9yKGlvRGVzYy0+bUlvSGFuZGxlKSA9PSAwKSB7Ci0gICAgICAgICAgICBBTE9HVygiaW9Db25maWdDaGFuZ2VkKCkgY2xvc2luZyB1bmtub3duICVzICVkIiwKKyAgICB7CisgICAgICAgIE11dGV4OjpBdXRvbG9jayBfbChtTG9jayk7CisKKyAgICAgICAgc3dpdGNoIChldmVudCkgeworICAgICAgICBjYXNlIEFVRElPX09VVFBVVF9PUEVORUQ6CisgICAgICAgIGNhc2UgQVVESU9fSU5QVVRfT1BFTkVEOiB7CisgICAgICAgICAgICBpZiAoZ2V0SW9EZXNjcmlwdG9yKGlvRGVzYy0+bUlvSGFuZGxlKSAhPSAwKSB7CisgICAgICAgICAgICAgICAgQUxPR1YoImlvQ29uZmlnQ2hhbmdlZCgpIG9wZW5pbmcgYWxyZWFkeSBleGlzdGluZyBvdXRwdXQhICVkIiwgaW9EZXNjLT5tSW9IYW5kbGUpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorICAgICAgICAgICAgbUlvRGVzY3JpcHRvcnMuYWRkKGlvRGVzYy0+bUlvSGFuZGxlLCBpb0Rlc2MpOworCisgICAgICAgICAgICBpZiAoaW9EZXNjLT5nZXREZXZpY2VJZCgpICE9IEFVRElPX1BPUlRfSEFORExFX05PTkUpIHsKKyAgICAgICAgICAgICAgICBkZXZpY2VJZCA9IGlvRGVzYy0+Z2V0RGV2aWNlSWQoKTsKKyAgICAgICAgICAgICAgICBzc2l6ZV90IGlvSW5kZXggPSBtQXVkaW9EZXZpY2VDYWxsYmFja3MuaW5kZXhPZktleShpb0Rlc2MtPm1Jb0hhbmRsZSk7CisgICAgICAgICAgICAgICAgaWYgKGlvSW5kZXggPj0gMCkgeworICAgICAgICAgICAgICAgICAgICBjYWxsYmFja3MgPSBtQXVkaW9EZXZpY2VDYWxsYmFja3MudmFsdWVBdChpb0luZGV4KTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgICAgICBBTE9HVigiaW9Db25maWdDaGFuZ2VkKCkgbmV3ICVzIG9wZW5lZCAlZCBzYW1wbGluZ1JhdGUgJXUsIGZvcm1hdCAlI3ggY2hhbm5lbCBtYXNrICUjeCAiCisgICAgICAgICAgICAgICAgICAgICJmcmFtZUNvdW50ICV6dSBkZXZpY2VJZCAlZCIsIGV2ZW50ID09IEFVRElPX09VVFBVVF9PUEVORUQgPyAib3V0cHV0IiA6ICJpbnB1dCIsCisgICAgICAgICAgICAgICAgICAgIGlvRGVzYy0+bUlvSGFuZGxlLCBpb0Rlc2MtPm1TYW1wbGluZ1JhdGUsIGlvRGVzYy0+bUZvcm1hdCwgaW9EZXNjLT5tQ2hhbm5lbE1hc2ssCisgICAgICAgICAgICAgICAgICAgIGlvRGVzYy0+bUZyYW1lQ291bnQsIGlvRGVzYy0+Z2V0RGV2aWNlSWQoKSk7CisgICAgICAgICAgICB9IGJyZWFrOworICAgICAgICBjYXNlIEFVRElPX09VVFBVVF9DTE9TRUQ6CisgICAgICAgIGNhc2UgQVVESU9fSU5QVVRfQ0xPU0VEOiB7CisgICAgICAgICAgICBpZiAoZ2V0SW9EZXNjcmlwdG9yKGlvRGVzYy0+bUlvSGFuZGxlKSA9PSAwKSB7CisgICAgICAgICAgICAgICAgQUxPR1coImlvQ29uZmlnQ2hhbmdlZCgpIGNsb3NpbmcgdW5rbm93biAlcyAlZCIsCisgICAgICAgICAgICAgICAgICAgICAgZXZlbnQgPT0gQVVESU9fT1VUUFVUX0NMT1NFRCA/ICJvdXRwdXQiIDogImlucHV0IiwgaW9EZXNjLT5tSW9IYW5kbGUpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorICAgICAgICAgICAgQUxPR1YoImlvQ29uZmlnQ2hhbmdlZCgpICVzICVkI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GREZXNjLT5nZXREZXZpY2VJZCgpOworICAgICAgICAgICAgbUlvRGVzY3JpcHRvcnMucmVwbGFjZVZhbHVlRm9yKGlvRGVzYy0+bUlvSGFuZGxlLCBpb0Rlc2MpOworCisgICAgICAgICAgICBpZiAoZGV2aWNlSWQgIT0gaW9EZXNjLT5nZXREZXZpY2VJZCgpKSB7CisgICAgICAgICAgICAgICAgZGV2aWNlSWQgPSBpb0Rlc2MtPmdldERldmljZUlkKCk7CisgICAgICAgICAgICAgICAgc3NpemVfdCBpb0luZGV4ID0gbUF1ZGlvRGV2aWNlQ2FsbGJhY2tzLmluZGV4T2ZLZXkoaW9EZXNjLT5tSW9IYW5kbGUpOworICAgICAgICAgICAgICAgIGlmIChpb0luZGV4ID49IDApIHsKKyAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2tzID0gbUF1ZGlvRGV2aWNlQ2FsbGJhY2tzLnZhbHVlQXQoaW9JbmRleCk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICAgICAgQUxPR1YoImlvQ29uZmlnQ2hhbmdlZCgpIG5ldyBjb25maWcgZm9yICVzICVkIHNhbXBsaW5nUmF0ZSAldSwgZm9ybWF0ICUjeCAiCisgICAgICAgICAgICAgICAgICAgICJjaGFubmVsIG1hc2sgJSN4IGZyYW1lQ291bnQgJXp1IGRldmljZUlkICVkIiwKKyAgICAgICAgICAgICAgICAgICAgZXZlbnQgPT0gQVVESU9fT1VUUFVUX0NPTkZJR19DSEFOR0VEID8gIm91dHB1dCIgOiAiaW5wdXQiLAorICAgICAgICAgICAgICAgICAgICBpb0Rlc2MtPm1Jb0hhbmRsZSwgaW9EZXNjLT5tU2FtcGxpbmdSYXRlLCBpb0Rlc2MtPm1Gb3JtYXQsCisgICAgICAgICAgICAgICAgICAgIGlvRGVzYy0+bUNoYW5uZWxNYXNrLCBpb0Rlc2MtPm1GcmFtZUNvdW50LCBpb0Rlc2MtPmdldERldmljZUlkKCkpOworCiAgICAgICAgIH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2ZmbG9hZGVkKCkpIHsKKyAgICAgICAgaWYgKG1SZXRyeU9uUGFydGlhbEJ1ZmZlciAmJiBhdWRpb19pc19saW5lYXJfcGNtKG1Gb3JtYXQpKSB7CiAgICAgICAgICAgICBtUmV0cnlPblBhcnRpYWxCdWZmZXIgPSBmYWxzZTsKICAgICAgICAgICAgIGlmIChhdmFpbCA8IG1SZW1haW5pbmdGcmFtZXMpIHsKLSAgICAgICAgICAgICAgICBpbnQ2NF90IG15bnMgPSAoKGRvdWJsZSkobVJlbWFpbmluZ0ZyYW1lcyAtIGF2YWlsKSAqIDExMDAwMDAwMDApCi0gICAgICAgICAgICAgICAgICAgICAgICAvICgoZG91YmxlKXNhbXBsZVJhdGUgKiBzcGVlZCk7Ci0gICAgICAgICAgICAgICAgaWYgKG5zIDwgMCB8fCBteW5zIDwgbnMpIHsKKyAgICAgICAgICAgICAgICBpZiAobnMgPiAwKSB7IC8vIGFjY291bnQgZm9yIG9idGFpbiB0aW1lCisgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5zZWNzX3QgdGltZU5vdyA9IHN5c3RlbVRpbWUoKTsKKyAgICAgICAgICAgICAgICAgICAgbnMgPSBtYXgoKG5zZWNzX3QpMCwgbnMgLSAodGltZU5vdyAtIHRpbWVBZnRlckNhbGxiYWNrcykpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBuc2Vjc190IG15bnMgPSBmcmFtZXNUb05hbm9zZWNvbmRzKG1SZW1haW5pbmdGcmFtZXMgLSBhdmFpbCwgc2FtcGxlUmF0ZSwgc3BlZWQpOworICAgICAgICAgICAgICAgIGlmIChucyA8IDAgLyogTlNfV0hFTkVWRVIgKi8gfHwgbXlucyA8IG5zKSB7CiAgICAgICAgICAgICAgICAgICAgIG5zID0gbXluczsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgcmV0dXJuIG5zOwpAQCAtMTkzNCw3ICsxOTkxLDQyIEBACiAgICAgICAgICAgICAvLyBLZWVw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AgICAgICAgIC8vIHRvIGNvbXBsZXRlbHkgZmx1c2ggb3Igc3RvcCB0aGUgcHJldmlvdXMgcGxheWluZyB0cmFjay4KLSAgICAgICAgICAgICAgICAgICAgQUxPR1coImluY29tcGxldGUgZmx1c2ggb3Igc3RvcDoiCisgICAgICAgICAgICAgICAgICAgIEFMT0dXX0lGKCFtVGltZXN0YW1wU3RhcnR1cEdsaXRjaFJlcG9ydGVkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICJnZXRUaW1lc3RhbXAgc3RhcnR1cCBnbGl0Y2ggZGV0ZWN0ZWQiCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIiBkZWx0YVRpbWVVcyglbGxkKSBkZWx0YVBvc2l0aW9uVXMoJWxsZCkgdHNtUG9zaXRpb24oJXUpIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAobG9uZyBsb25nKWRlbHRhVGltZVVzLCAobG9uZyBsb25nKWRlbHRhUG9zaXRpb25CeVVzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWVzdGFtcC5tUG9zaXRpb24pOworICAgICAgICAgICAgICAgICAgICBtVGltZXN0YW1wU3RhcnR1cEdsaXRjaFJlcG9ydGVkID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKHByZXZpb3VzVGltZXN0YW1wVmFsaWQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAmJiBtUHJldmlvdXNUaW1lc3RhbXAubVBvc2l0aW9uID09IDAgLyogc2hvdWxkIGJlIHRydWUgaWYgdmFsaWQgKi8pIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHRpbWVzdGFtcCA9IG1QcmV2aW91c1RpbWVzdGFtcDsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1QcmV2aW91c1RpbWVzdGFtcFZhbGlkID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBOT19FUlJPUjsKKyAgICAgICAgICAgICAgICAgICAgfQogICAgICA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ZiAobGVuID4gMCkgewotICAgICAgICAgICAgbWVtY3B5KGJ1ZmZlciwgbU1lbW9yeS0+cG9pbnRlcigpLCBsZW4pOworICAgICAgICBpZiAobGVuID4gc2l6ZSkgeworICAgICAgICAgICAgQUxPR0UoInJlcXVlc3RlZCAlenUsIGdvdCAlenUiLCBzaXplLCBsZW4pOworICAgICAgICAgICAgcmV0dXJuIEVSUk9SX09VVF9PRl9SQU5HRTsKICAgICAgICAgfQorICAgICAgICBpZiAobGVuID4gbU1lbW9yeS0+c2l6ZSgpKSB7CisgICAgICAgICAgICBBTE9HRSgiZ290ICV6dSwgYnV0IG1lbW9yeSBoYXMgJXp1IiwgbGVuLCBtTWVtb3J5LT5zaXplKCkpOworICAgICAgICAgICAgcmV0dXJuIEVSUk9SX09VVF9PRl9SQU5HRTsKKyAgICAgICAgfQorCisgICAgICAgIG1lbWNweShidWZmZXIsIG1NZW1vcnktPnBvaW50ZXIoKSwgbGVuKTsKIAogICAgICAgICByZXR1cm4gbGVuOwogICAgIH0KZGlmZiAtLWdpdCBhL21lZGlhL2xpYm1lZGlhL0lNZWRpYUhUVFBTZXJ2aWNlLmNwcCBiL21lZGlhL2xpYm1lZGlhL0lNZWRpYUhUVFBTZXJ2aWNlLmNwcAppbmRleCBmMzBkMGYzLi4wYzE2YTJiIDEwMDY0NAotLS0gYS9tZWRpYS9saWJtZWRpYS9JTWVkaWFIVFRQU2VydmljZS5jcHAKKysrIGIvbWVkaWEvbGlibWVkaWEvSU1lZGlhSFRUUFNlcnZpY2UuY3BwCkBAIC00NCw2ICs0NCw3IEBACiAgICAgICAgIHN0YXR1c190IGVyciA9IHJlcGx5LnJlYWRJbnQzMigpOwogCiAgICAgICAgIGlmIChlcnIgIT0gT0spIHsKKyAgICAgICAgICAgIEFMT0dFKCJVbmFibGUgdG8gbWFrZSBIVFRQIGNvbm5lY3Rpb24gKGVyciA9ICVkKSIsIGVycik7CiAgICAgICAgICAgICByZXR1cm4gTlVMTDsKICAgICAgICAgfQ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mNlRmQgPj0gMCkgeworICAgICAgICAgICAgZGF0YS53cml0ZUZpbGVEZXNjcmlwdG9yKGZlbmNlRmQsIHRydWUgLyogdGFrZU93bmVyc2hpcCAqLyk7CisgICAgICAgIH0KICAgICAgICAgcmVtb3RlKCktPnRyYW5zYWN0KEZJTExfQlVGRkVSLCBkYXRhLCAmcmVwbHkpOwogCiAgICAgICAgIHJldHVybiByZXBseS5yZWFkSW50MzIoKTsKQEAgLTUwNiw3ICs1MjksNyBAQAogICAgICAgICAgICAgbm9kZV9pZCBub2RlLAogICAgICAgICAgICAgYnVmZmVyX2lkIGJ1ZmZlciwKICAgICAgICAgICAgIE9NWF9VMzIgcmFuZ2Vfb2Zmc2V0LCBPTVhfVTMyIHJhbmdlX2xlbmd0aCwKLSAgICAgICAgICAgIE9NWF9VMzIgZmxhZ3MsIE9NWF9USUNLUyB0aW1lc3RhbXApIHsKKyAgICAgICAgICAgIE9NWF9VMzIgZmxhZ3MsIE9NWF9USUNLUyB0aW1lc3RhbXAsIGludCBmZW5jZUZkKSB7CiAgICAgICAgIFBhcmNlbCBkYXRhLCByZXBseTsKICAgICAgICAgZGF0YS53cml0ZUludGVyZmFjZVRva2VuKElPTVg6OmdldEludGVyZmFjZURlc2NyaXB0b3IoKSk7CiAgICAgICAgIGRhdGEud3JpdGVJbnQzMigoaW50MzJfdClub2RlKTsKQEAgLTUxNSw2ICs1MzgsMTAgQEAKICAgICAgICAgZGF0YS53cml0ZUludDMyKHJhbmdlX2xlbmd0aCk7CiAgICAgICAgIGRhdGEud3JpdGVJbnQzMihmbGFncyk7CiAgICAgICAgIGRhdGEud3JpdGVJbnQ2NCh0aW1lc3RhbXApOworICAgICAgICBkYXRhLndyaXRlSW50MzIoZmVuY2VGZCA+PSAwKTsKKyAgICAgICAgaWYgKGZlbmNlRmQgPj0gMCkgeworICAgICAgICAgICAgZGF0YS53cml0ZUZpbGVEZXNjcmlwdG9yKGZlbmNlRmQsIHRydWUgLyogdGFrZU93bmVyc2hpcCAqLyk7CisgICAgICAgIH0KICAgICAgICAgcmVtb3RlKCktPnRyYW5zYWN0KEVNUFRZX0JVRkZFUiwgZGF0YSwgJnJlcGx5KTsKIAogICAgICAgICByZXR1cm4gcmVwbHkucmVhZEludDMyKCk7CkBAIC03NTgsOSArNzg1LDEwIEBACiAgICAgICAgICAgICBPTVhfVTMyIHBvcnRfaW5kZXggPSBkYXRhLnJlYWRJbnQzMigpOwogICAgICAgICAgICAgc3A8SU1lbW9yeT4gcGFyYW1zID0KICAgICAgICAgICAgICAgICBpbnRlcmZhY2VfY2FzdDxJTWVtb3J5PihkYXRhLnJlYWRTdHJvbmdCaW5kZXIoKSk7CisgICAgICAgICAgICBPTVhfVTMyIGFsbG90dGVkU2l6ZSA9IGRhdGEucmVhZEludDMyKCk7CiAKICAgICAgICAgICAgIGJ1ZmZlcl9pZCBidWZmZXI7Ci0gICAgICAgICAgICBzdGF0dXNfdCBlcnIgPSB1c2VCdWZmZXIobm9kZSwgcG9ydF9pbmRleCwgcGFyYW1zLCAmYnVmZmVyKTsKKyAgICAgICAgICAgIHN0YXR1c190IGVyciA9IHVzZUJ1ZmZlcihub2RlLCBwb3J0X2luZGV4LCBwYXJhbXMsICZidWZmZXIsIGFsbG90dGVkU2l6ZSk7CiAgICAgICAgICAgICByZXBseS0+d3JpdGVJbnQzMihlcnIpOwogCiAgICAgICAgICAgICBpZiAoZXJyID09IE9LKSB7CkBAIC04MTYsOSArODQ0LDEwIEBACiAgICAgICAgICAgICBPTVhfVTMyIHBvcnRfaW5kZXggPSBkYXRhLnJlYWRJbnQzMigpOwogCiAgICAgICAgICAgICBzcDxJR3JhcGhpY0J1ZmZlclByb2R1Y2VyPiBidWZmZXJQcm9kdWNlcjsKLSAgICAgICAgICAgIHN0YXR1c190IGVyciA9IGNyZWF0ZUlucHV0U3VyZmFjZShub2RlLCBwb3J0X2luZGV4LAotICAgICAgICAgICAgICAgICAgICAmYnVmZmVyUHJvZHVjZXIpOworICAgICAgICAgICAgTWV0YWRhdGFCdWZmZXJUeXBlIHR5cGU7CisgICAgICAgICAgICBzdGF0dXNfdCBlcnIgPSBjcmVhdGVJbnB1dFN1cmZhY2Uobm9kZSwgcG9ydF9pbmRleCwgJmJ1ZmZlclByb2R1Y2VyLCAmdHlwZSk7CiAKKyAgICAgICAgICAgIHJlcGx5LT53cml0ZUludDMyKHR5cGUpOwogICAgICAgICAgICAgcmVwbHktPndyaXRlSW50MzIoZXJyKTsKIAogICAgICAgICAgICAgaWYgKGVyciA9PSBPSykgewpAQCAtODQ3LDcgKzg3Niw3IEBACiAgICAgICAgICAgICByZXR1cm4gTk9fRVJST1I7CiAgICAgICAgIH0KIAotICAgICAgICBjYXNlIFVTRV9QRVJTSVNURU5UX0lOUFVUX1NVUkZBQ0U6CisgICAgICAgIGNhc2UgU0VUX0lOUFVUX1NVUkZBQ0U6CiAgICAgICAgIHsKICAgICAgICAgICAgIENIRUNLX09NWF9JTlRFUkZBQ0UoSU9NWCwgZGF0YSwgcmVwbHkpOwogCkBAIC04NTcsOSArODg2LDEwIEBACiAgICAgICAgICAgICBzcDxJR3JhcGhpY0J1ZmZlckNvbnN1bWVyPiBidWZmZXJDb25zdW1lciA9CiAgICAgICAgICAgICAgICAgICAgIGludGVyZmFjZV9jYXN0PElHcmFwaGljQnVmZmVyQ29uc3VtZXI+KGRhdGEucmVhZFN0cm9uZ0JpbmRlcigpKTsKIAotICAgICAgICAgICAgc3RhdHVzX3QgZXJyID0gdXNlUGVyc2lzdGVudElucHV0U3VyZmFjZSgKLSAgICAgICAgICAgICAgICAgICAgbm9kZSwgcG9ydF9pbmRleCwgYnVmZmVyQ29uc3VtZXIpOworICAgICAgICAgICAgTWV0YWRhdGFCdWZmZXJUeXBlIHR5cGU7CisgICAgICAgICAgICBzdGF0dXNfdCBlcnIgPSBzZXRJbnB1dFN1cmZhY2Uobm9kZSwgcG9ydF9pbmRleCwgYnVmZmVyQ29uc3VtZXIsICZ0eXBlKTsKIAorICAgICAgICAgICAgcmVwbHktPndyaXRlSW50MzIodHlwZSk7CiAgICAgICAgICAgICByZXBseS0+d3JpdGVJbnQzMihlcnIpOwogICAgICAgICAgICAgcmV0dXJuIE5PX0VSUk9SOwogICAgICAgICB9CkBAIC04ODQsNyArOTE0LDkgQEAKICAgICAgICAgICAgIE9NWF9VMzIgcG9ydF9pbmRleCA9IGRhdGEucmVhZEludDMyKCk7CiAgICAgICAgICAgICBPTVhfQk9PTCBlbmFibGUgPSAoT01YX0JPT0wpZGF0YS5yZWFkSW50MzIoKTsKIAotICAgICAgICAgICAgc3RhdHVzX3QgZXJyID0gc3RvcmVNZXRhRGF0YUluQnVmZmVycyhub2RlLCBwb3J0X2luZGV4LCBlbmFibGUpOworICAgICAgICAgICAgTWV0YWRhdGFCdWZmZXJUeXBlIHR5cGU7CisgICAgICAgICAgICBzdGF0dXNfdCBlcnIgPSBzdG9yZU1ldGFEYXRhSW5CdWZmZXJzKG5vZGUsIHBvcnRfaW5kZXgsIGVuYWJsZSwgJnR5cGUpOworICAgICAgICAgICAgcmVwbHktPndyaXRlSW50MzIodHlwZSk7CiAgICAgICAgICAgICByZXBseS0+d3JpdGVJbnQzMihlcnIpOwogCiAgICAgICAgICAgICByZXR1cm4gTk9fRVJST1I7CkBAIC05NTUsMTAgKzk4NywxMSBAQAogICAgICAgICAgICAgT01YX1UzMiBwb3J0X2luZGV4ID0gZGF0YS5yZWFkSW50MzIoKTsKICAgICAgICAgICAgIHNwPElNZW1vcnk+IHBhcmFtcyA9CiAgICAgICAgICAgICAgICAgaW50ZXJmYWNlX2Nhc3Q8SU1lbW9yeT4oZGF0YS5yZWFkU3Ryb25nQmluZGVyKCkpOworICAgICAgICAgICAgT01YX1UzMiBhbGxvdHRlZFNpemUgPSBkYXRhLnJlYWRJbnQzMigpOwogCiAgICAgICAgICAgICBidWZmZXJfaWQgYnVmZmVyOwogICAgICAgICAgICAgc3RhdHVzX3QgZXJyID0gYWxsb2NhdGVCdWZmZXJXaXRoQmFja3VwKAotICAgICAgICAgICAgICAgICAgICBub2RlLCBwb3J0X2luZGV4LCBwYXJhbXMsICZidWZmZXIpOworICAgICAgICAgICAgICAgICAgICBub2RlLCBwb3J0X2luZGV4LCBwYXJhbXMsICZidWZmZXIsIGFsbG90dGVkU2l6ZSk7CiAKICAgICAgICAgICAgIHJlcGx5LT53cml0ZUludDMyKGVycik7CiAKQEAgLTk4Nyw3ICsxMDIwLDkgQEAKIAogICAgICAgICAgICAgbm9kZV9pZCBub2RlID0gKG5vZGVfaWQpZGF0YS5yZWFkSW50MzIoKTsKICAgICAgICAgICAgIGJ1ZmZlcl9pZCBidWZmZXIgPSAoYnVmZmVyX2lkKWRhdGEucmVhZEludDMyKCk7Ci0gICAgICAgICAgICByZXBseS0+d3JpdGVJbnQzMihmaWxsQnVmZmVyKG5vZGUsIGJ1ZmZlcikpOworICAgICAgICAgICAgYm9vbCBoYXZlRmVuY2UgPSBkYXRhLnJlYWRJbnQzMigpOworICAgICAgICAgICAgaW50IGZlbmNlRmQgPSBoYXZlRmVuY2UgPyA6OmR1cChkYXRhLnJlYWRGaWxlRGVzY3JpcHRvcigpKSA6IC0xOworICAgICAgICAgICAgcmVwbHktPndyaXRlSW50MzIoZmlsbEJ1ZmZlcihub2RlLCBidWZmZXIsIGZlbmNlRmQpKTsKIAogICAgICAgICAgICAgcmV0dXJuIE5PX0VSUk9SOwogICAgICAgICB9CkBAIC0xMDAyLDExICsxMDM3LDEwIEBACiAgICAgICAgICAgICBPTVhfVTMyIHJhbmdlX2xlbmd0aCA9IGRhdGEucmVhZEludDMyKCk7CiAgICAgICAgICAgICBPTVhfVTMyIGZsYWdzID0gZGF0YS5yZWFkSW50MzIoKTsKICAgICAgICAgICAgIE9NWF9USUNLUyB0aW1lc3RhbXAgPSBkYXRhLnJlYWRJbnQ2NCgpOwotCi0gICAgICAgICAgICByZXBseS0+d3JpdGVJbnQzMigKLSAgICAgICAgICAgICAgICAgICAgZW1wdHlCdWZmZXIoCi0gICAgICAgICAgICAgICAgIC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IHJlbW90ZSgpLT50cmFuc2FjdChPQlNFUlZFUl9PTl9NU0csIGRhdGEsICZyZXBseSwgSUJpbmRlcjo6RkxBR19PTkVXQVkpOworICAgICAgICBzdGQ6Omxpc3Q8b214X21lc3NhZ2U+Ojpjb25zdF9pdGVyYXRvciBpdCA9IG1lc3NhZ2VzLmNiZWdpbigpOworICAgICAgICBib29sIGZpcnN0ID0gdHJ1ZTsKKyAgICAgICAgd2hpbGUgKGl0ICE9IG1lc3NhZ2VzLmNlbmQoKSkgeworICAgICAgICAgICAgY29uc3Qgb214X21lc3NhZ2UgJm1zZyA9ICppdCsrOworICAgICAgICAgICAgaWYgKGZpcnN0KSB7CisgICAgICAgICAgICAgICAgZGF0YS53cml0ZUludGVyZmFjZVRva2VuKElPTVhPYnNlcnZlcjo6Z2V0SW50ZXJmYWNlRGVzY3JpcHRvcigpKTsKKyAgICAgICAgICAgICAgICBkYXRhLndyaXRlSW50MzIobXNnLm5vZGUpOworICAgICAgICAgICAgICAgIGZpcnN0ID0gZmFsc2U7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBkYXRhLndyaXRlSW50MzIobXNnLmZlbmNlRmQgPj0gMCk7CisgICAgICAgICAgICBpZiAobXNnLmZlbmNlRmQgPj0gMCkgeworICAgICAgICAgICAgICAgIGRhdGEud3JpdGVGaWxlRGVzY3JpcHRvcihtc2cuZmVuY2VGZCwgdHJ1ZSAvKiB0YWtlT3duZXJzaGlwICovKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGRhdGEud3JpdGVJbnQzMihtc2cudHlwZSk7CisgICAgICAgICAgICBkYXRhLndyaXRlKCZtc2cudSwgc2l6ZW9mKG1zZy51KSk7CisgICAgICAgICAgICBBTE9HVigib25NZXNzYWdlIHdyaXRpbmcgbWVzc2FnZSAlZCwgc2l6ZSAlenUiLCBtc2cudHlwZSwgc2l6ZW9mKG1zZykpOworICAgICAgICB9CisgICAgICAgIGlmICghZmlyc3QpIHsKKyAgICAgICAgICAgIGRhdGEud3JpdGVJbnQzMigtMSk7IC8vIG1hcmsgZW5kCisgICAgICAgICAgICByZW1vdGUoKS0+dHJhbnNhY3QoT0JTRVJWRVJfT05fTVNHLCBkYXRhLCAmcmVwbHksIElCaW5kZXI6OkZMQUdfT05FV0FZKTsKKyAgICAgICAgfQogICAgIH0KIH07CiAKQEAgLTEwNjIsMTYgKzExMTEsMjggQEAKICAgICAgICAgY2FzZSBPQlNFUlZFUl9PTl9NU0c6CiAgICAgICAgIHsKICAgICAgICAgICAgIENIRUNLX09NWF9JTlRFUkZBQ0UoSU9NWE9ic2VydmVyLCBkYXRhLCByZXBseSk7CisgICAgICAgICAgICBJT01YOjpub2RlX2lkIG5vZGUgPSBkYXRhLnJlYWRJbnQzMigpOworICAgICAgICAgICAgc3RkOjpsaXN0PG9teF9tZXNzYWdlPiBtZXNzYWdlczsKKyAgICAgICAgICAgIHN0YXR1c190IGVyciA9IEZBSUxFRF9UUkFOU0FDVElPTjsgLy8gbXVzdCByZWNlaXZlIGF0IGxlYXN0IG9uZSBtZXNzYWdlCisgICAgICAgICAgICBkbyB7CisgICAgICAgICAgICAgICAgaW50IGhhdmVGZW5jZSA9IGRhdGEucmVhZEludDMyKCk7CisgICAgICAgICAgICAgICAgaWYgKGhhdmVGZW5jZSA8IDApIHsgLy8gd2UgdXNlIC0xIHRvIG1hcmsgZW5kIG9mIG1lc3NhZ2VzCisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBvbXhfbWVzc2FnZSBtc2c7CisgICAgICAgICAgICAgICAgbXNnLm5vZGUgPSBub2RlOworICAgICAgICAgICAgICAgIG1zZy5mZW5jZUZkID0gaGF2ZUZlbmNlID8gOjpkdXAoZGF0YS5yZWFkRmlsZURlc2NyaXB0b3IoKSkgOiAtMTsKKyAgICAgICAgICAgICAgICBtc2cudHlwZSA9ICh0eXBlb2YobXNnLnR5cGUpKWRhdGEucmVhZEludDMyKCk7CisgICAgICAgICAgICAgICAgZXJyID0gZGF0YS5yZWFkKCZtc2cudSwgc2l6ZW9mKG1zZy51KSk7CisgICAgICAgICAgICAgICAgQUxPR1YoIm9uVHJhbnNhY3QgcmVhZGluZyBtZXNzYWdlICVkLCBzaXplICV6dSIsIG1zZy50eXBlLCBzaXplb2YobXNnKSk7CisgICAgICAgICAgICAgICAgbWVzc2FnZXMucHVzaF9iYWNrKG1zZyk7CisgICAgICAgICAgICB9IHdoaWxlIChlcnIgPT0gT0spOwogCi0gICAgICAgICAgICBvbXhfbWVzc2FnZSBtc2c7Ci0gICAgICAgICAgICBkYXRhLnJlYWQoJm1zZywgc2l6ZW9mKG1zZykpOworICAgICAgICAgICAgaWYgKGVyciA9PSBPSykgeworICAgICAgICAgICAgICAgIG9uTWVzc2FnZXMobWVzc2FnZXMpOworICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBBTE9HVigib25UcmFuc2FjdCByZWFkaW5nIG1lc3NhZ2UgJWQsIHNpemUgJXp1IiwgbXNnLnR5cGUsIHNpemVvZihtc2cpKTsKLQotICAgICAgICAgICAgLy8gWFhYIENvdWxkIHVzZSByZWFkSW5wbGFjZSBtYXliZT8KLSAgICAgICAgICAgIG9uTWVzc2FnZShtc2cpOwotCi0gICAgICAgICAgICByZXR1cm4gTk9fRVJST1I7CisgICAgICAgICAgICByZXR1cm4gZXJyOwogICAgICAgICB9CiAKICAgICAgICAgZGVmYXVsdDoKZGlmZiAtLWdpdCBhL21lZGlhL2xpYm1lZGlhL0lSZXNvdXJjZU1hbmFnZXJTZXJ2aWNlLmNwcCBiL21lZGlhL2xpYm1lZGlhL0lSZXNvdXJjZU1hbmFnZXJTZXJ2aWNlLmNwcAppbmRleCA3YWU5NDZkLi42OTAyZTk5IDEwMDY0NAotLS0gYS9tZWRpYS9saWJtZWRpYS9JUmVzb3VyY2VNYW5hZ2VyU2VydmljZS5jcHAKKysrIGIvbWVkaWEvbGlibWVkaWEvSVJlc291cmNlTWFuYWdlclNlcnZp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ibWVkaWFwbGF5ZXJzZXJ2aWNlL0RybS5jcHAgYi9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvRHJtLmNwcAppbmRleCBkNTU0ODJkLi5hN2Y2ZjhiIDEwMDY0NAotLS0gYS9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvRHJtLmNwcAorKysgYi9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvRHJtLmNwcApAQCAtMzU4LDcgKzM1OCwxOCBAQAogICAgIHN0YXR1c190IGVyciA9IG1QbHVnaW4tPm9wZW5TZXNzaW9uKHNlc3Npb25JZCk7CiAgICAgaWYgKGVyciA9PSBFUlJPUl9EUk1fUkVTT1VSQ0VfQlVTWSkgewogICAgICAgICBib29sIHJldHJ5ID0gZmFsc2U7CisgICAgICAgIG1Mb2NrLnVubG9jaygpOworICAgICAgICAvLyByZWNsYWltU2Vzc2lvbiBtYXkgY2FsbCBiYWNrIHRvIGNsb3NlU2Vzc2lvbiwgc2luY2UgbUxvY2sgaXMgc2hhcmVkIGJldHdlZW4gRHJtCisgICAgICAgIC8vIGluc3RhbmNlcywgd2Ugc2hvdWxkIHVubG9jayBoZXJlIHRvIGF2b2lkIGRlYWRsb2NrLgogICAgICAgICByZXRyeSA9IERybVNlc3Npb25NYW5hZ2VyOjpJbnN0YW5jZSgpLT5yZWNsYWltU2Vzc2lvbihnZXRDYWxsaW5nUGlkKCkpOworICAgICAgICBtTG9jay5sb2NrKCk7CisgICAgICAgIGlmIChtSW5pdENoZWNrICE9IE9LKSB7CisgICAgICAgICAgICByZXR1cm4gbUluaXRDaGVjazsKKyAgICAgICAgfQorCisgICAgICAgIGlmIChtUGx1Z2luID09IE5VTEwpIHsKKyAgICAgICAgICAgIHJldHVybiAtRUlOVkFMOworICAgICAgICB9CiAgICAgICAgIGlmIChyZXRyeSkgewogICAgICAgICAgICAgZXJyID0gbVBsdWdpbi0+b3BlblNlc3Npb24oc2Vzc2lvbklkKTsKICAgICAgICAgfQ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cmV1c2UgPSBmYWxzZTsKICAgICBib29sIGJvdGhPZmZsb2FkZWQgPSBmYWxzZTsKQEAgLTE2MDUsNyArMTYwOCw4IEBACiAgICAgICAgICAgICAgICAgICAgIG9mZmxvYWRJbmZvLAogICAgICAgICAgICAgICAgICAgICBtVWlkLAogICAgICAgICAgICAgICAgICAgICBtUGlkLAotICAgICAgICAgICAgICAgICAgICBtQXR0cmlidXRlcyk7CisgICAgICAgICAgICAgICAgICAgIG1BdHRyaWJ1dGVzLAorICAgICAgICAgICAgICAgICAgICBkb05vdFJlY29ubmVjdCk7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICB0ID0gbmV3IEF1ZGlvVHJhY2soCiAgICAgICAgICAgICAgICAgICAgIG1TdHJlYW1UeXBlLApAQCAtMTYyMiwxMiArMTYyNiwxNCBAQAogICAgICAgICAgICAgICAgICAgICBOVUxMLCAvLyBvZmZsb2FkIGluZm8KICAgICAgICAgICAgICAgICAgICAgbVVpZCwKICAgICAgICAgICAgICAgICAgICAgbVBpZCwKLSAgICAgICAgICAgICAgICAgICAgbUF0dHJpYnV0ZXMpOworICAgICAgICAgICAgICAgICAgICBtQXR0cmlidXRlcywKKyAgICAgICAgICAgICAgICAgICAgZG9Ob3RSZWNvbm5lY3QpOwogICAgICAgICB9CiAKICAgICAgICAgaWYgKCh0ID09IDApIHx8ICh0LT5pbml0Q2hlY2soKSAhPSBOT19FUlJPUikpIHsKICAgICAgICAgICAgIEFMT0dFKCJVbmFibGUgdG8gY3JlYXRlIGF1ZGlvIHRyYWNrIik7CiAgICAgICAgICAgICBkZWxldGUgbmV3Y2JkOworICAgICAgICAgICAgLy8gdCBnb2VzIG91dCBvZiBzY29wZSwgc28gcmVmZXJlbmNlIGNvdW50IGRyb3BzIHRvIHplcm8KICAgICAgICAgICAgIHJldHVybiBOT19JTklUOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgLy8gc3VjY2Vzc2Z1bCBBdWRpb1RyYWNrIGluaXRp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5cGUgdHlwZSA9IChmb3JtYXRDaGFuZ2UgJiYgc2Vla2luZykKLSAgICAgICAgICAgICAgICAgICAgICAgID8gQVRTUGFyc2VyOjpESVNDT05USU5VSVRZX0ZPUk1BVENIQU5HRQotICAgICAgICAgICAgICAgICAgICAgICAgOiBBVFNQYXJzZXI6OkRJU0NPTlRJTlVJVFlfTk9ORTsKLSAgICAgICAgICAgICAgICB0cmFjay0+bVBhY2tldHMtPnF1ZXVlRGlzY29udGludWl0eSggdHlwZSwgTlVMTCwgdHJ1ZSAvKiBkaXNjYXJkICovKTsKLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHF1ZXVlRGlzY29udGludWl0eUlmTmVlZGVkKHNlZWtpbmcsIGZvcm1hdENoYW5nZSwgdHJhY2tUeXBlLCB0cmFjayk7CiAKICAgICAgICAgICAgIHNwPEFCdWZmZXI+IGJ1ZmZlciA9IG1lZGlhQnVmZmVyVG9BQnVmZmVyKAogICAgICAgICAgICAgICAgICAgICBtYnVmLCB0cmFja1R5cGUsIHNlZWtUaW1lVXMsIGFjdHVhbFRpbWVVcyk7CkBAIC0xNTM4LDEwICsxNTMyLDI2IEBACiAgICAgICAgICAgICAgICAgICAgIGZhbHNlIC8qIGRpc2NhcmQgKi8pOwogI2VuZGlmCiAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBxdWV1ZURpc2NvbnRpbnVpdHlJZk5lZWRlZChzZWVraW5nLCBmb3JtYXRDaGFuZ2UsIHRyYWNrVHlwZSwgdHJhY2spOwogICAgICAgICAgICAgdHJhY2stPm1QYWNrZXRzLT5zaWduYWxFT1MoZXJyKTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAgICAgfQogfQogCit2b2lkIE51UGxheWVyOjpHZW5lcmljU291cmNlOjpxdWV1ZURpc2NvbnRpbnVpdHlJZk5lZWRlZCgKKyAgICAgICAgYm9vbCBzZWVraW5nLCBib29sIGZvcm1hdENoYW5nZSwgbWVkaWFfdHJhY2tfdHl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ci0gICAgQ0hFQ0soZm9ybWF0LT5maW5kU3RyaW5nKCJtaW1lIiwgJm1pbWUpKTsKKyAgICBpZiAoIWZvcm1hdC0+ZmluZFN0cmluZygibWltZSIsICZtaW1lKSkgeworICAgICAgICAvLyBKYXZhIE1lZGlhUGxheWVyIG9ubHkgdXNlcyBtaW1ldHlwZSBmb3Igc3VidGl0bGUgYW5kIHRpbWVkdGV4dCB0cmFja3MuCisgICAgICAgIC8vIElmIHdlIGNhbid0IGZpbmQgdGhlIG1pbWV0eXBlIGhlcmUgaXQgbWVhbnMgdGhhdCB3ZSB3b3VsZG4ndCBiZSBuZWVkaW5nCisgICAgICAgIC8vIHRoZSBtaW1ldHlwZSBvbiB0aGUgSmF2YSBlbmQuIFdlIHN0aWxsIHdyaXRlIGEgcGxhY2Vob2xkZXIgbWltZSB0byBrZWVwIHRoZQorICAgICAgICAvLyAoZGUpc2VyaWFsaXphdGlvbiBsb2dpYyBzaW1wbGUuCisgICAgICAgIGlmICh0cmFja1R5cGUgPT0gTUVESUFfVFJBQ0tfVFlQRV9BVURJTykgeworICAgICAgICAgICAgbWltZSA9ICJhdWRpby8iOworICAgICAgICB9IGVsc2UgaWYgKHRyYWNrVHlwZSA9PSBNRURJQV9UUkFDS19UWVBFX1ZJREVPKSB7CisgICAgICAgICAgICBtaW1lID0gInZpZGVvLyI7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBUUkVTUEFTUygpOworICAgICAgICB9CisgICAgfQogCiAgICAgQVN0cmluZyBsYW5nOwogICAgIENIRUNLKGZvcm1hdC0+ZmluZFN0cmluZygibGFuZ3VhZ2UiLCAmbGFuZykpOwpAQCAtNjM2LDcgKzY0Nyw3IEBACiAgICAgICAgICAgICAgICAgICAgIGludDY0X3QgY3VycmVudFBvc2l0aW9uVXMgPSAwOwogICAgICAgICAgICAgICAgICAgICBpZiAoZ2V0Q3VycmVudFBvc2l0aW9uKCZjdXJyZW50UG9zaXRpb25VcykgPT0gT0spIHsKICAgICAgICAgICAgICAgICAgICAgICAgIG1EZWZlcnJlZEFjdGlvbnMucHVzaF9iYWNrKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgU2Vla0FjdGlvbihjdXJyZW50UG9zaXRpb25VcywgZmFsc2UgLyogbmVlZE5vdGlmeSAqLykpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgU2Vla0FjdGlvbihjdXJyZW50UG9zaXRpb25VcykpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQogCkBAIC02NzEsNyArNjgyLDEwIEBACiAgICAgICAgIHsKICAgICAgICAgICAgIEFMT0dWKCJrV2hhdFN0YXJ0Iik7CiAgICAgICAgICAgICBpZiAobVN0YXJ0ZWQpIHsKLSAgICAgICAgICAgICAgICBvblJlc3VtZSgpOworICAgICAgICAgICAgICAgIC8vIGRvIG5vdCByZXN1bWUgeWV0IGlmIHRoZSBzb3VyY2UgaXMgc3RpbGwgYnVmZmVyaW5nCisgICAgICAgICAgICAgICAgaWYgKCFtUGF1c2VkRm9yQnVmZmVyaW5nKSB7CisgICAgICAgICAgICAgICAgICAgIG9uUmVzdW1lKCk7CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBvblN0YXJ0KCk7CiAgICAgICAgICAgICB9CkBAIC04MjAsNyArODM0LDcgQEAKICAgICAgICAgICAgICAgICBhdWRpb19zdHJlYW1fdHlwZV90IHN0cmVhbVR5cGUgPSBtQXVkaW9TaW5rLT5nZXRBdWRpb1N0cmVhbVR5cGUoKTsKICAgICAgICAgICAgICAgICBjb25zdCBib29sIGhhc1ZpZGVvID0gKHZpZGVvRm9ybWF0ICE9IE5VTEwpOwogICAgICAgICAgICAgICAgIGNvbnN0IGJvb2wgY2FuT2ZmbG9hZCA9IGNhbk9mZmxvYWRTdHJlYW0oCi0gICAgICAgICAgICAgICAgICAgICAgICBhdWRpb01ldGEsIGhhc1ZpZGVvLCB0cnVlIC8qIGlzX3N0cmVhbWluZyAqLywgc3RyZWFtVHlwZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb01ldGEsIGhhc1ZpZGVvLCBtU291cmNlLT5pc1N0cmVhbWluZygpLCBzdHJlYW1UeXBlKTsKICAgICAgICAgICAgICAgICBpZiAoY2FuT2ZmbG9hZCkgewogICAgICAgICAgICAgICAgICAgICBpZiAoIW1PZmZsb2FkQXVkaW8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgIG1SZW5kZXJlci0+c2lnbmFsRW5hYmxlT2ZmbG9hZEF1ZGlvKCk7CkBAIC0xMDY5LDEyICsxMDgzLDEyIEBACiAgICAgICAgICAgICB9IGVsc2UgaWYgKHdoYXQgPT0gUmVuZGVyZXI6OmtXaGF0TWVkaWFSZW5kZXJpbmdTdGFydCkgewogICAgICAgICAgICAgICAgIEFMT0dWKCJtZWRpYSByZW5kZXJpbmcgc3RhcnRlZCIpOwogICAgICAgICAgICAgICAgIG5vdGlmeUxpc3RlbmVyKE1FRElBX1NUQVJURUQsIDAsIDApOwotICAgICAgICAgICAgfSBlbHNlIGlmICh3aGF0ID09IFJlbmRlcmVyOjprV2hhdEF1ZGlvT2ZmbG9hZFRlYXJEb3duKSB7Ci0gICAgICAgICAgICAgICAgQUxPR1YoIlRlYXIgZG93biBhdWRpbyBvZmZsb2FkLCBmYWxsIGJhY2sgdG8gcy93IHBhdGggaWYgZHVlIHRvIGVycm9yLiIpOworICAgICAgICAgICAgfSBlbHNlIGlmICh3aGF0ID09IFJlbmRlcmVyOjprV2hhdEF1ZGlvVGVhckRvd24pIHsKICAgICAgICAgICAgICAgICBpbnQ2NF90IHBvc2l0aW9uVXM7CiAgICAgICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50NjQoInBvc2l0aW9uVXMiLCAmcG9zaXRpb25VcykpOwogICAgICAgICAgICAgICAgIGludDMyX3QgcmVhc29uOwogICAgICAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZEludDMyKCJyZWFzb24iLCAmcmVhc29uKSk7CisgICAgICAgICAgICAgICAgQUxPR1YoIlRlYXIgZG93biBhdWRpbyB3aXRoIHJlYXNvbiAlZC4iLCByZWFzb24pOwogICAgICAgICAgICAgICAgIGNsb3NlQXVkaW9TaW5rKCk7CiAgICAgICAgICAgICAgICAgbUF1ZGlvRGVjb2Rlci5jbGVhcigpOwogICAgICAgICAgICAgICAgICsrbUF1ZGlvRGVjb2RlckdlbmVyYXRpb247CkBAIC0xMDg1LDEwICsxMDk5LDIzIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmFsc2UgLyogYXVkaW8gKi8sIGZhbHNlIC8qIG5vdGlmeUNvbXBsZXRlICovKTsKICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBwZXJmb3JtU2Vlayhwb3NpdGlvblVzLCBmYWxzZSAvKiBuZWVkTm90aWZ5ICovKTsKKyAgICAgICAgICAgICAgICBwZXJmb3JtU2Vlayhwb3NpdGlvblVzKTsKKwogICAgICAgICAgICAgICAgIGlmIChyZWFzb24gPT0gUmVuZGVyZXI6OmtEdWVUb0Vycm9yKSB7Ci0gICAgICAgICAgICAgICAgICAgIG1SZW5kZXJlci0+c2lnbmFsRGlzYWJsZU9mZmxvYWRBdWRpbygpOwotICAgICAgICAgICAgICAgICAgICBtT2ZmbG9hZEF1ZGlvID0gZmFsc2U7CisgICAgICAgICAgICAgICAgICAgIHNwPE1ldGFEYXRhPiBhdWRpb01ldGEgPSBtU291cmNlLT5nZXRGb3JtYXRNZXRhKHRydWUgLyogYXVkaW8gKi8pOworICAgICAgICAgICAgICAgICAgICBzcDxBTWVzc2FnZT4gdmlkZW9Gb3JtYXQgPSBtU291cmNlLT5nZXRGb3JtYXQoZmFsc2UgLyogYXVkaW8gKi8pOworICAgICAgICAgICAgICAgICAgICBhdWRpb19zdHJlYW1fdHlwZV90IHN0cmVhbVR5cGUgPSBtQXVkaW9TaW5rLT5nZXRBdWRpb1N0cmVhbVR5cGUoKTsKKyAgICAgICAgICAgICAgICAgICAgY29uc3QgYm9vbCBoYXNWaWRlbyA9ICh2aWRlb0Zvcm1hdCAhPSBOVUxMKTsKKyAgICAgICAgICAgICAgICAgICAgY29uc3QgYm9vbCBjYW5PZmZsb2FkID0gY2FuT2ZmbG9hZFN0cmVhbSgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb01ldGEsIGhhc1ZpZGVvLCBtU291cmNlLT5pc1N0cmVhbWluZygpLCBzdHJlYW1UeXBlKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGNhbk9mZmxvYWQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1SZW5kZXJlci0+c2lnbmFsRW5hYmxlT2ZmbG9hZEF1ZGlvKCk7CisgICAgICAgICAgICAgICAgICAgICAgICBzcDxBTWVzc2FnZT4gZm9ybWF0ID0gbVNvdXJjZS0+Z2V0Rm9ybWF0KHRydWUgLyphdWRpbyovKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHRyeU9wZW5BdWRpb1NpbmtGb3JPZmZsb2FkKGZvcm1hdCwgaGFzVmlkZW8pOworICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgbVJlbmRlcmVyLT5zaWduYWxEaXNhYmxlT2ZmbG9hZEF1ZGlvKCk7CisgICAgICAgICAgICAgICAgICAgICAgICBtT2ZmbG9hZEF1ZGlvID0gZmFsc2U7CisgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgaW5zdGFudGlhdGVEZWNvZGVyKHRydWUgLyogYXVkaW8gKi8sICZtQXVkaW9EZWNvZGVyKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC0xMTI2LDEyICsxMTUzLDI4IEBACiAgICAgICAgICAgICBBTE9HVigia1doYXRTZWVrIHNlZWtUaW1lVXM9JWxsZCB1cywgbmVlZE5vdGlmeT0lZCIsCiAgICAgICAgICAgICAgICAgICAgIChsb25nIGxvbmcpc2Vla1RpbWVVcywgbmVlZE5vdGlmeSk7CiAKKyAgICAgICAgICAgIGlmICghbVN0YXJ0ZWQpIHsKKyAgICAgICAgICAgICAgICAvLyBTZWVrIGJlZm9yZSB0aGUgcGxheWVyIGlzIHN0YXJ0ZWQuIEluIG9yZGVyIHRvIHByZXZpZXcgdmlkZW8sCisgICAgICAgICAgICAgICAgLy8gbmVlZCB0byBzdGFydCB0aGUgcGxheWVyIGFuZCBwYXVzZSBpdC4gVGhpcyBicmFuY2ggaXMgY2FsbGVkCisgICAgICAgICAgICAgICAgLy8gb25seSBvbmNlIGlmIG5lZWRlZC4gQWZ0ZXIgdGhlIHBsYXllciBpcyBzdGFydGVkLCBhbnkgc2VlaworICAgICAgICAgICAgICAgIC8vIG9wZXJhdGlvbiB3aWxsIGdvIHRocm91Z2ggbm9ybWFsIHBhdGguCisgICAgICAgICAgICAgICAgLy8gQWxsIGNhc2VzLCBpbmNsdWRpbmcgYXVkaW8tb25seSwgYXJlIGhhbmRsZWQgaW4gdGhlIHNhbWUgd2F5CisgICAgICAgICAgICAgICAgLy8gZm9yIHRoZSBzYWtlIG9mIHNpbXBsaWNpdHkuCisgICAgICAgICAgICAgICAgb25TdGFydChzZWVrVGltZVVzKTsKKyAgICAgICAgICAgICAgICBvblBhdXNlKCk7CisgICAgICAgICAgICAgICAgbVBhdXNlZEJ5Q2xpZW50ID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICBpZiAobmVlZE5vdGlmeSkgeworICAgICAgICAgICAgICAgICAgICBub3RpZnlEcml2ZXJTZWVrQ29tcGxldGUoKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisKICAgICAgICAgICAgIG1EZWZlcnJlZEFjdGlvbnMucHVzaF9iYWNrKAogICAgICAgICAgICAgICAgICAgICBuZXcgRmx1c2hEZWNvZGVyQWN0aW9uKEZMVVNIX0NNRF9GTFVT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gbW9kZQpAQCAtMTg4MiwxMSArMTkyNiwxNSBAQAogdm9pZCBOdVBsYXllcjo6ZmluaXNoUmVzdW1lKCkgewogICAgIGlmIChtUmVzdW1lUGVuZGluZykgewogICAgICAgICBtUmVzdW1lUGVuZGluZyA9IGZhbHNlOwotICAgICAgICBpZiAobURyaXZlciAhPSBOVUxMKSB7Ci0gICAgICAgICAgICBzcDxOdVBsYXllckRyaXZlcj4gZHJpdmVyID0gbURyaXZlci5wcm9tb3RlKCk7Ci0gICAgICAgICAgICBpZiAoZHJpdmVyICE9IE5VTEwpIHsKLSAgICAgICAgICAgICAgICBkcml2ZXItPm5vdGlmeVNlZWtDb21wbGV0ZSgpOwotICAgICAgICAgICAgfQorICAgICAgICBub3RpZnlEcml2ZXJTZWVrQ29tcGxldGUoKTsKKyAgICB9Cit9CisKK3ZvaWQgTnVQbGF5ZXI6Om5vdGlmeURyaXZlclNlZWtDb21wbGV0ZSgpIHsKKyAgICBpZiAobURyaXZlciAhPSBOVUxMKSB7CisgICAgICAgIHNwPE51UGxheWVyRHJpdmVyPiBkcml2ZXIgPSBtRHJpdmVyLnByb21vdGUoKTsKKyAgICAgICAgaWYgKGRyaXZlciAhPSBOVUxMKSB7CisgICAgICAgICAgICBkcml2ZXItPm5vdGlmeVNlZWtDb21wbGV0ZSgpOwogICAgICAgICB9CiAgICAgfQogfQpAQCAtMTk5NSw5ICsyMDQzLDEwIEBACiAgICAgICAgIGNhc2UgU291cmNlOjprV2hhdFBhdXNlT25CdWZmZXJpbmdTdGFydDoKICAgICAgICAgewogICAgICAgICAgICAgLy8gaWdub3JlIGlmIG5vdCBwbGF5aW5nCi0gICAgICAgICAgICBpZiAobVN0YXJ0ZWQgJiYgIW1QYXVzZWRCeUNsaWVudCkgeworICAgICAgICAgICAgaWYgKG1TdGFydGVkKSB7CiAgICAgICAgICAgICAgICAgQUxPR0koImJ1ZmZlciBsb3csIHBhdXNpbmcuLi4iKTsKIAorICAgICAgICAgICAgICAgIG1QYXVzZWRGb3JCdWZmZXJpbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgIG9uUGF1c2UoKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIC8vIGZhbGwtdGhydQpAQCAtMjAxMiwxMCArMjA2MSwxNSBAQAogICAgICAgICBjYXNlIFNvdXJjZTo6a1doYXRSZXN1bWVPbkJ1ZmZlcmluZ0VuZDoKICAgICAgICAgewogICAgICAgICAgICAgLy8gaWdub3JlIGlmIG5vdCBwbGF5aW5nCi0gICAgICAgICAgICBpZiAobVN0YXJ0ZWQgJiYgIW1QYXVzZWRCeUNsaWVudCkgeworICAgICAgICAgICAgaWYgKG1TdGFydGVkKSB7CiAgICAgICAgICAgICAgICAgQUxPR0koImJ1ZmZlciByZWFkeSwgcmVzdW1pbmcuLi4iKTsKIAotICAgICAgICAgICAgICAgIG9uUmVzdW1lKCk7CisgICAgICAgICAgICAgICAgbVBhdXNlZEZvckJ1ZmZlcmluZyA9IGZhbHNlOworCisgICAgICAgICAgICAgICAgLy8gZG8gbm90IHJlc3VtZSB5ZXQgaWYgY2xpZW50IGRpZG4ndCB1bnBhdXNlCisgICAgICAgICAgICAgICAgaWYgKCFtUGF1c2VkQnlDbGllbnQpIHsKKyAgICAgICAgICAgICAgICAgICAgb25SZXN1bWUoKTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICAvLyBmYWxsLXRocnUKICAgICAgICAgfQpkaWZmIC0tZ2l0IGEvbWVkaWEvbGlibWVkaWFwbGF5ZXJzZXJ2aWNlL251cGxheWVyL051UGxheWVyLmggYi9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvbnVwbGF5ZXIvTnVQbGF5ZXIuaAppbmRleCA2YjdkNzFlLi5kN2FhODMwIDEwMDY0NAotLS0gYS9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvbnVwbGF5ZXIvTnVQbGF5ZXIuaAorKysgYi9tZWRpYS9saWJtZWRpYXBsYXll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obVNvdXJjZS0+Z2V0Rm9ybWF0KGZhbHNlIC8qIGF1ZGlvICovKSAhPSBOVUxMKTsKLSAgICAgICAgaWYgKCFoYXNWaWRlbyAmJgotICAgICAgICAgICAgICAgIG1Tb3VyY2UtPmdldER1cmF0aW9uKCZkdXJhdGlvblVzKSA9PSBPSyAmJgotICAgICAgICAgICAgICAgIGR1cmF0aW9uVXMgPiBBVURJT19TSU5LX01JTl9ERUVQX0JVRkZFUl9EVVJBVElPTl9VUykgeworICAgICAgICBpZiAoZ2V0QXVkaW9EZWVwQnVmZmVyU2V0dGluZygpIC8vIG92ZXJyaWRlIHJlZ2FyZGxlc3Mgb2Ygc291cmNlIGR1cmF0aW9uCisgICAgICAgICAgICAgICAgfHwgKCFoYXNWaWRlbworICAgICAgICAgICAgICAgICAgICAgICAgJiYgbVNvdXJjZS0+Z2V0RHVyYXRpb24oJmR1cmF0aW9uVXMpID09IE9LCisgICAgICAgICAgICAgICAgICAgICAgICAmJiBkdXJhdGlvblVzID4gQVVESU9fU0lOS19NSU5fREVFUF9CVUZGRVJfRFVSQVRJT05fVVMpKSB7CiAgICAgICAgICAgICBmbGFncyA9IEFVRElPX09VVFBVVF9GTEFHX0RFRVBfQlVGRkVSOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgZmxhZ3MgPSBBVURJT19PVVRQVVRfRkxBR19OT05FOwpkaWZmIC0tZ2l0IGEvbWVkaWEvbGlibWVkaWFwbGF5ZXJzZXJ2aWNlL251cGxheWVyL051UGxheWVyRHJpdmVyLmNwcCBiL21lZGlhL2xpYm1lZGlhcGxheWVyc2VydmljZS9udXBsYXllci9OdVBsYXllckRyaXZlci5jcHAKaW5kZXggMjMxZjJlMS4uODRhZTI1ZSAxMDA2NDQKLS0tIGEvbWVkaWEvbGlibWVkaWFwbGF5ZXJzZXJ2aWNlL251cGxheWVyL051UGxheWVyRHJpdmVyLmNwcAorKysgYi9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvbnVwbG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9RdWV1ZToKICAgICAgICAgeworICAgICAgICAgICAgbURyYWluQXVkaW9RdWV1ZVBlbmRpbmcgPSBmYWxzZTsKKwogICAgICAgICAgICAgaW50MzJfdCBnZW5lcmF0aW9uOwogICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50MzIoImRyYWluR2VuZXJhdGlvbiIsICZnZW5lcmF0aW9uKSk7CiAgICAgICAgICAgICBpZiAoZ2VuZXJhdGlvbiAhPSBnZXREcmFpbkdlbmVyYXRpb24odHJ1ZSAvKiBhdWRpbyAqLykpIHsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgbURyYWluQXVkaW9RdWV1ZVBlbmRpbmcgPSBmYWxzZTsKLQogICAgICAgICAgICAgaWYgKG9uRHJhaW5BdWRpb1F1ZXVlKCkpIHsKICAgICAgICAgICAgICAgICB1aW50MzJfdCBudW1GcmFtZXNQbGF5ZWQ7CiAgICAgICAgICAgICAgICAgQ0hFQ0tfRVEobUF1ZGlvU2luay0+Z2V0UG9zaXRpb24oJm51bUZyYW1lc1BsYXllZCksCkBAIC01NjYsOSArNTk3LDkgQEAKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAKLSAgICAgICAgY2FzZSBrV2hhdEF1ZGlvT2ZmbG9hZFRlYXJEb3duOgorICAgICAgICBjYXNlIGtXaGF0QXVkaW9UZWFyRG93bjoKICAgICAgICAgewotICAgICAgICAgICAgb25BdWRpb09mZmxvYWRUZWFyRG93bihrRHVlVG9FcnJvcik7CisgICAgICAgICAgICBvbkF1ZGlvVGVhckRvd24oa0R1ZVRvRXJyb3IpOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KIApAQCAtNTgwLDcgKzYxMSw3IEBACiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBBTE9HVigiQXVkaW8gT2ZmbG9hZCB0ZWFyIGRvd24gZHVlIHRvIHBhdXNlI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Migid2hhdCIsIGtXaGF0QXVkaW9PZmZsb2FkVGVhckRvd24pOworICAgIG5vdGlmeS0+c2V0SW50MzIoIndoYXQiLCBrV2hhdEF1ZGlvVGVhckRvd24pOwogICAgIG5vdGlmeS0+c2V0SW50NjQoInBvc2l0aW9uVXMiLCBjdXJyZW50UG9zaXRpb25Vcyk7CiAgICAgbm90aWZ5LT5zZXRJbnQzMigicmVhc29uIiwgcmVhc29uKTsKICAgICBub3RpZnktPnBvc3QoKTsKQEAgLTE1ODksMTIgKzE2NDksMTMgQEAKICAgICAgICAgICAgIG9mZmxvYWRGbGFncyAmPSB+QVVESU9fT1VUUFVUX0ZMQUdfREVFUF9CVUZGRVI7CiAgICAgICAgICAgICBhdWRpb1NpbmtDaGFuZ2VkID0gdHJ1ZTsKICAgICAgICAgICAgIG1BdWRpb1NpbmstPmNsb3NlKCk7CisKICAgICAgICAgICAgIGVyciA9IG1BdWRpb1NpbmstPm9wZW4oCiAgICAgICAgICAgICAgICAgICAgIHNhbXBsZVJhdGUsCiAgICAgICAgICAgICAgICAgICAgIG51bUNoYW5uZWxzLAogICAgICAgICAgICAgICAgICAgICAoYXVkaW9fY2hhbm5lbF9tYXNrX3QpY2hhbm5lbE1hc2ssCiAgICAgICAgICAgICAgICAgICAgIGF1ZGlvRm9ybWF0LAotICAgICAgICAgICAgICAgICAgICA4IC8qIGJ1ZmZlckNvdW50ICovLAorICAgICAgICAgICAgICAgICAgICAwIC8qIGJ1ZmZlckNvdW50IC0gdW51c2VkICovLAogICAgICAgICAgICAgICAgICAgICAmTnVQbGF5ZXI6OlJlbmRlcmVyOjpBdWRpb1NpbmtDYWxsYmFjaywKICAgICAgICAgICAgICAgICAgICAgdGhpcywKICAgICAgICAgICAgICAgICAgICAgKGF1ZGlvX291dHB1dF9mbGFnc190KW9mZmxvYWRGbGFncywKQEAgLTE2MTIsNyArMTY3Myw5IEBACiAgICAgICAgICAgICAgICAgLy8gYmVmb3JlIHJlYWNoaW5nIHRoZSBoYXJkd2FyZS4KICAgICAgICAgICAgICAgICAvLyBUT0RPCiAgICAgICAgICAgICAgICAgbUN1cnJlbnRPZmZsb2FkSW5mbyA9IG9mZmxvYWRJbmZvOwotICAgICAgICAgICAgICAgIGVyciA9IG1BdWRpb1NpbmstPnN0YXJ0KCk7CisgICAgICAgICAgICAgICAgaWYgKCFtUGF1c2VkKSB7IC8vIGZvciBwcmV2aWV3IG1vZGUsIGRvbid0IHN0YXJ0IGlmIHBhdXNlZAorICAgICAgICAgICAgICAgICAgICBlcnIgPSBtQXVkaW9TaW5rLT5zdGFydCgpOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBBTE9HVl9JRihlcnIgPT0gT0ssICJvcGVuQXVkaW9TaW5rOiBvZmZsb2FkIHN1Y2NlZWRlZCIpOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgewpAQCAtMTYyMSw2ICsxNjg0LDkgQEAKICAgICAgICAgICAgICAgICBvbkRpc2FibGVPZmZsb2FkQXVkaW8oKTsKICAgICAgICAgICAgICAgICBtQ3VycmVudE9mZmxvYWRJbmZvID0gQVVESU9fSU5GT19JTklUSUFMSVpFUjsKICAgICAgICAgICAgICAgICBBTE9HVigib3BlbkF1ZGlvU2luazogb2ZmbG9hZCBmYWlsZWQiKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgbVVzZUF1ZGlvQ2FsbGJhY2sgPSB0cnVlOyAgLy8gb2ZmbG9hZCBtb2RlIHRyYW5zZmVycyBkYXRhIHRocm91Z2ggY2FsbGJhY2sKKyAgICAgICAgICAgICAgICArK21BdWRpb0RyYWluR2VuZXJhdGlvbjsgIC8vIGRpc2NhcmQgcGVuZGluZyBrV2hhdERyYWluQXVkaW9RdWV1ZSBtZXNzYWdlLgogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQpAQCAtMTY0NSwxNSArMTcxMSwzMCBAQAogICAgICAgICBhdWRpb1NpbmtDaGFu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YW5uZWxzLAogICAgICAgICAgICAgICAgICAgICAoYXVkaW9fY2hhbm5lbF9tYXNrX3QpY2hhbm5lbE1hc2ssCiAgICAgICAgICAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9QQ01fMTZfQklULAotICAgICAgICAgICAgICAgICAgICA4IC8qIGJ1ZmZlckNvdW50ICovLAorICAgICAgICAgICAgICAgICAgICAwIC8qIGJ1ZmZlckNvdW50IC0gdW51c2VkICovLAorICAgICAgICAgICAgICAgICAgICBtVXNlQXVkaW9DYWxsYmFjayA/ICZOdVBsYXllcjo6UmVuZGVyZXI6OkF1ZGlvU2lua0NhbGxiYWNrIDogTlVMTCwKKyAgICAgICAgICAgICAgICAgICAgbVVzZUF1ZGlvQ2FsbGJhY2sgPyB0aGlzIDogTlVMTCwKKyAgICAgICAgICAgICAgICAgICAgKGF1ZGlvX291dHB1dF9mbGFnc190KXBjbUZsYWdzLAogICAgICAgICAgICAgICAgICAgICBOVUxMLAotICAgICAgICAgICAgICAgICAgICBOVUxMLAotICAgICAgICAgICAgICAgICAgICAoYXVkaW9fb3V0cHV0X2ZsYWdzX3QpcGNtRmxhZ3MpOworICAgICAgICAgICAgICAgICAgICB0cnVlIC8qIGRvTm90UmVjb25uZWN0ICovLAorICAgICAgICAgICAgICAgICAgICBmcmFtZUNvdW50KTsKICAgICAgICAgaWYgKGVyciA9PSBPSykgewogICAgICAgICAgICAgZXJyID0gbUF1ZGlvU2luay0+c2V0UGxheWJhY2tSYXRlKG1QbGF5YmFja1NldHRpbmdzKTsKICAgICAgICAgfQpAQCAtMTY2MywxNCArMTc0NCwxNCBAQAogICAgICAgICAgICAgcmV0dXJuIGVycjsKICAgICAgICAgfQogICAgICAgICBtQ3VycmVudFBjbUluZm8gPSBpbmZvOwotICAgICAgICBtQXVkaW9TaW5rLT5zdGFydCgpOworICAgICAgICBpZiAoIW1QYXVzZWQpIHsgLy8gZm9yIHByZXZpZXcgbW9kZSwgZG9uJ3Qgc3RhcnQgaWYgcGF1c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09mZmxvYWRUZWFyRG93biA9ICdhT1REJywKKyAgICAgICAga1doYXRFT1MgICAgICAgICAgICAgICAgICAgICAgPSAnZW9zICcsCisgICAgICAgIGtXaGF0Rmx1c2hDb21wbGV0ZSAgICAgICAgICAgID0gJ2ZsdUMnLAorICAgICAgICBrV2hhdFBvc2l0aW9uICAgICAgICAgICAgICAgICA9ICdwb3NpJywKKyAgICAgICAga1doYXRWaWRlb1JlbmRlcmluZ1N0YXJ0ICAgICAgPSAndmRyZCcsCisgICAgICAgIGtXaGF0TWVkaWFSZW5kZXJpbmdTdGFydCAgICAgID0gJ21kcmQnLAorICAgICAgICBrV2hhdEF1ZGlvVGVhckRvd24gICAgICAgICAgICA9ICdhZFREJywKICAgICAgICAga1doYXRBdWRpb09mZmxvYWRQYXVzZVRpbWVvdXQgPSAnYU9QVCcsCiAgICAgfTsKIAotICAgIGVudW0gQXVkaW9PZmZsb2FkVGVhckRvd25SZWFzb24geworICAgIGVudW0gQXVkaW9UZWFyRG93blJlYXNvbiB7CiAgICAgICAgIGtEdWVUb0Vycm9yID0gMCwKICAgICAgICAga0R1ZVRvVGltZW91dCwKICAgICB9OwpAQCAtMTc5LDcgKzE3OSw3IEBACiAgICAgaW50NjRfdCBtTGFzdFBvc2l0aW9uVXBkYXRlVXM7CiAKICAgICBpbnQzMl90IG1BdWRpb09mZmxvYWRQYXVzZVRpbWVvdXRHZW5lcmF0aW9uOwotICAgIGJvb2wgbUF1ZGlvT2ZmbG9hZFRvcm5Eb3duOworICAgIGJvb2wgbUF1ZGlvVG9ybkRvd247CiAgICAgYXVkaW9fb2ZmbG9hZF9pbmZvX3QgbUN1cnJlbnRPZmZsb2FkSW5mbzsKIAogICAgIHN0cnVjdCBQY21JbmZvIHsKQEAgLTE5NCw2ICsxOTQsNyBAQAogCiAgICAgaW50MzJfdCBtVG90YWxCdWZmZXJzUXVldWVkOwogICAgIGludDMyX3QgbUxhc3RBdWRpb0J1ZmZlckRyYWluZWQ7CisgICAgYm9vbC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QogCiAgICAgLy8gZnJvbSBJT01YT2JzZXJ2ZXIKLSAgICB2aXJ0dWFsIHZvaWQgb25NZXNzYWdlKGNvbnN0IG9teF9tZXNzYWdlICZvbXhfbXNnKSB7Ci0gICAgICAgIHNwPEFNZXNzYWdlPiBtc2cgPSBtTm90aWZ5LT5kdXAoKTsKLQotICAgICAgICBtc2ctPnNldEludDMyKCJ0eXBlIiwgb214X21zZy50eXBlKTsKLSAgICAgICAgbXNnLT5zZXRJbnQzMigibm9kZSIsIG9teF9tc2cubm9kZSk7Ci0KLSAgICAgICAgc3dpdGNoIChvbXhfbXNnLnR5cGUpIHsKLSAgICAgICAgICAgIGNhc2Ugb214X21lc3NhZ2U6OkVWRU5UOgotICAgICAgICAgICAgewotICAgICAgICAgICAgICAgIG1zZy0+c2V0SW50MzIoImV2ZW50Iiwgb214X21zZy51LmV2ZW50X2RhdGEuZXZlbnQpOwotICAgICAgICAgICAgICAgIG1zZy0+c2V0SW50MzIoImRhdGExIiwgb214X21zZy51LmV2ZW50X2RhdGEuZGF0YTEpOwotICAgICAgICAgICAgICAgIG1zZy0+c2V0SW50MzIoImRhdGEyIiwgb214X21zZy51LmV2ZW50X2RhdGEuZGF0YTIpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBjYXNlIG9teF9tZXNzYWdlOjpFTVBUWV9CVUZGRVJfRE9ORToKLSAgICAgICAgICAgIHsKLSAgICAgICAgICAgICAgICBtc2ctPnNldEludDMyKCJidWZmZXIiLCBvbXhfbXNnLnUuYnVmZmVyX2RhdGEuYnVmZmVyKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgY2FzZSBvbXhfbWVzc2FnZTo6RklMTF9CVUZGRVJfRE9ORToKLSAgICAgICAgICAgIHsKLSAgICAgICAgICAgICAgICBtc2ctPnNldEludDMyKAotICAgICAgICAgICAgICAgICAgICAgICAgImJ1ZmZlciIsIG9teF9tc2cudS5leHRlbmRlZF9idWZmZXJfZGF0YS5idWZmZXIpOwotICAgICAgICAgICAgICAgIG1zZy0+c2V0SW50MzIoCi0gICAgICAgICAgICAgICAgICAgICAgICAicmFuZ2Vfb2Zmc2V0IiwKLSAgICAgICAgICAgICAgICAgICAgICAgIG9teF9tc2cudS5leHRlbmRlZF9idWZmZXJfZGF0YS5yYW5nZV9vZmZzZXQpOwotICAgICAgICAgICAgICAgIG1zZy0+c2V0SW50MzIoCi0gICAgICAgICAgICAgICAgICAgICAgICAicmFuZ2VfbGVuZ3RoIiwKLSAgICAgICAgICAgICAgICAgICAgICAgIG9teF9tc2cudS5leHRlbmRlZF9idWZmZXJfZGF0YS5yYW5nZV9sZW5ndGgpOwotICAgICAgICAgICAgICAgIG1zZy0+c2V0SW50MzIoCi0gICAgICAgICAgICAgICAgICAgICAgICAiZmxhZ3MiLAotICAgICAgICAgICAgICAgICAgICAgICAgb214X21zZy51LmV4dGVuZGVkX2J1ZmZlcl9kYXRhLmZsYWdzKTsKLSAgICAgICAgICAgICAgICBtc2ctPnNldEludDY0KAotICAgICAgICAgICAgICAgICAgICAgICAgInRpbWVzdGFtcCIsCi0gICAgICAgICAgICAgICAgICAgICAgICBvbXhfbXNnLnUuZXh0ZW5kZWRfYnVmZmVyX2RhdGEudGltZXN0YW1wKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgICAgICBUUkVTUEFTUygpOwotICAgICAgICAgICAgICAgIGJyZWFrOworICAgIHZpcnR1YWwgdm9pZCBvbk1lc3NhZ2VzKGNvbnN0IHN0ZDo6bGlzdDxvbXhfbWVzc2FnZT4gJm1lc3NhZ2VzKSB7CisgICAgICAgIGlmIChtZXNzYWdlcy5lbXB0eSgpKSB7CisgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KIAotICAgICAgICBtc2ctPnBvc3QoKTsKKyAgICAgICAgc3A8QU1lc3NhZ2U+IG5vdGlmeSA9IG1Ob3RpZnktPmR1cCgpOworICAgICAgICBib29sIGZpcnN0ID0gdHJ1ZTsKKyAgICAgICAgc3A8TWVzc2FnZUxpc3Q+IG1zZ0xpc3QgPSBuZXcgTWVzc2FnZUxpc3QoKTsKKyAgICAgICAgZm9yIChzdGQ6Omxpc3Q8b214X21lc3NhZ2U+Ojpjb25zdF9pdGVyYXRvciBpdCA9IG1lc3NhZ2VzLmNiZWdpbigpOworICAgICAgICAgICAgICBpdCAhPSBtZXNzYWdlcy5jZW5kKCk7ICsraXQpIHsKKyAgICAgICAgICAgIGNvbnN0IG9teF9tZXNzYWdlICZvbXhfbXNnID0gKml0OworICAgICAgICAgICAgaWYgKGZpcnN0KSB7CisgICAgICAgICAgICAgICAgbm90aWZ5LT5zZXRJbnQzMigibm9kZSIsIG9teF9tc2cubm9kZSk7CisgICAgICAgICAgICAgICAgZmlyc3QgPSBmYWxzZTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgc3A8QU1lc3NhZ2U+IG1zZyA9IG5ldyBBTWVzc2FnZTsKKyAgICAgICAgICAgIG1zZy0+c2V0SW50MzIoInR5cGUiLCBvbXhfbXNnLnR5cGUpOworICAgICAgICAgICAgc3dpdGNoIChvbXhfbXNnLnR5cGUpIHsKKyAgICAgICAgICAgICAgICBjYXNlIG9teF9tZXNzYWdlOjpFVkVOVDoKKyAgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICAgIG1zZy0+c2V0SW50MzIoImV2ZW50Iiwgb214X21zZy51LmV2ZW50X2RhdGEuZXZlbnQpOworICAgICAgICAgICAgICAgICAgICBtc2ctPnNldEludDMyKCJkYXRhMSIsIG9teF9tc2cudS5ldmVudF9kYXRhLmRhdGExKTsKKyAgICAgICAgICAgICAgICAgICAgbXNnLT5zZXRJbnQzMigiZGF0YTIiLCBvbXhfbXNnLnUuZXZlbnRfZGF0YS5kYXRhMik7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIGNhc2Ugb214X21lc3NhZ2U6OkVNUFRZX0JVRkZFUl9ET05FOgorICAgICAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAgICAgbXNnLT5zZXRJbnQzMigiYnVmZmVyIiwgb214X21zZy51LmJ1ZmZlcl9kYXRhLmJ1ZmZlcik7CisgICAgICAgICAgICAgICAgICAgIG1zZy0+c2V0SW50MzIoImZlbmNlX2ZkIiwgb214X21zZy5mZW5jZUZkKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgY2FzZSBvbXhfbWVzc2FnZTo6RklMTF9CVUZGRVJfRE9ORToKKyAgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICAgIG1zZy0+c2V0SW50MzIoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgImJ1ZmZlciIsIG9teF9tc2cudS5leHRlbmRlZF9idWZmZXJfZGF0YS5idWZmZXIpOworICAgICAgICAgICAgICAgICAgICBtc2ctPnNldEludDMyKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICJyYW5nZV9vZmZzZXQiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9teF9tc2cudS5leHRlbmRlZF9idWZmZXJfZGF0YS5yYW5nZV9vZmZzZXQpOworICAgICAgICAgICAgICAgICAgICBtc2ctPnNldEludDMyKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICJyYW5nZV9sZW5ndGgiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9teF9tc2cudS5leHRlbmRlZF9idWZmZXJfZGF0YS5yYW5nZV9sZW5ndGgpOworICAgICAgICAgICAgICAgICAgICBtc2ctPnNldEludDMyKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICJmbGFncyIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgb214X21zZy51LmV4dGVuZGVkX2J1ZmZlcl9kYXRhLmZsYWdzKTsKKyAgICAgICAgICAgICAgICAgICAgbXNnLT5zZXRJbnQ2NCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAidGltZXN0YW1wIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbXhfbXNnLnUuZXh0ZW5kZWRfYnVmZmVyX2RhdGEudGltZXN0YW1wKTsKKyAgICAgICAgICAgICAgICAgICAgbXNnLT5zZXRJbnQzMigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZmVuY2VfZmQiLCBvbXhfbXNnLmZlbmNlRmQpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBjYXNlIG9teF9tZXNzYWdlOjpGUkFNRV9SRU5ERVJFRDoKKyAgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICAgIG1zZy0+c2V0SW50NjQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIm1lZGlhX3RpbWVfdXMiLCBvbXhfbXNnLnUucmVuZGVyX2RhdGEudGltZXN0YW1wKTsKKyAgICAgICAgICAgICAgICAgICAgbXNnLT5zZXRJbnQ2NCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAic3lzdGVtX25hbm8iLCBvbXhfbXNnLnUucmVuZGVyX2RhdGEubmFub1RpbWUpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICBBTE9HRSgiVW5yZWNvZ25pemVkIG1lc3NhZ2UgdHlwZTogJWQiLCBvbXhfbXNnLnR5cGUpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIG1zZ0xpc3QtPmdldExpc3QoKS5wdXNoX2JhY2sobXNnKTsKKyAgICAgICAgfQorICAgICAgICBub3RpZnktPnNldE9iamVjdCgibWVzc2FnZXMiLCBtc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lwZSksCiAgICAgICAgICAgICAgICAgICAgIHBvcnRJbmRleCA9PSBrUG9ydEluZGV4SW5wdXQgPyAiaW5wdXQiIDogIm91dHB1dCIpOwogCi0gICAgICAgICAgICBzaXplX3QgdG90YWxTaXplID0gZGVmLm5CdWZmZXJDb3VudEFjdHVhbCAqIGRlZi5uQnVmZmVyU2l6ZTsKKyAgICAgICAgICAgIHNpemVfdCB0b3RhbFNpemUgPSBkZWYubkJ1ZmZlckNvdW50QWN0dWFsICogYnVmU2l6ZTsKICAgICAgICAgICAgIG1EZWFsZXJbcG9ydEluZGV4XSA9IG5ldyBNZW1vcnlEZWFsZXIodG90YWxTaXplLCAiQUNvZGVjIik7CiAKLSAgICAgICAgICAgIGZvciAoT01YX1UzMiBpID0gMDsgaSA8IGRlZi5uQnVmZmVyQ291bnRBY3R1YWw7ICsraSkgewotICAgICAgICAgICAgICAgIHNwPElNZW1vcnk+IG1lbSA9IG1EZWFsZXJbcG9ydEluZGV4XS0+YWxsb2NhdGUoZGVmLm5CdWZmZXJTaXplKTsKLSAgICAgICAgICAgICAgICBDSEVDSyhtZW0uZ2V0KCkgIT0gTlVMTCk7CisgICAgICAgICAgICBmb3IgKE9NWF9VMzIgaSA9IDA7IGkgPCBkZWYubkJ1ZmZlckNvdW50QWN0dWFsICYmIGVyciA9PSBPSzsgKytpKSB7CisgICAgICAgICAgICAgICAgc3A8SU1lbW9yeT4gbWVtID0gbURlYWxlcltwb3J0SW5kZXhdLT5hbGxvY2F0ZShidWZTaXplKTsKKyAgICAgICAgICAgICAgICBpZiAobWVtID09IE5VTEwgfHwgbWVtLT5wb2ludGVyKCkgPT0gTlVMTCkgeworICAgICAgICAgICAgICAgICAgICByZXR1cm4gTk9fTUVNT1JZOworICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgIEJ1ZmZlckluZm8gaW5mbzsKICAgICAgICAgICAgICAgICBpbmZvLm1TdGF0dXMgPSBCdWZmZXJJbmZvOjpPV05FRF9CWV9VUzsKKyAgICAgICAgICAgICAgICBpbmZvLm1GZW5jZUZkID0gLTE7CisgICAgICAgICAgICAgICAgaW5mby5tUmVuZGVySW5mbyA9IE5VTEw7CiAKICAgICAgICAgICAgICAgICB1aW50MzJfdCByZXF1aXJlc0FsbG9jYXRlQnVmZmVyQml0ID0KICAgICAgICAgICAgICAgICAgICAgKHBvcnRJbmRleCA9PSBrUG9ydEluZGV4SW5wdXQpCkBAIC02OTcsMjcgKzgxNywyNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgOiBPTVhDb2RlYzo6a1JlcXVpcmVzQWxsb2NhdGVCdWZmZXJPbk91dHB1dFBvcnRzOwogCiAgICAgICAgICAgICAgICAgaWYgKChwb3J0SW5kZXggPT0ga1BvcnRJbmRleElucHV0ICYmIChtRmxhZ3MgJiBrRmxhZ0lzU2VjdXJlKSkKLSAgICAgICAgICAgICAgICAgICAgICAgIHx8IG1Vc2VNZXRhZGF0YU9uRW5jb2Rlck91dHB1dCkgeworICAgICAgICAgICAgICAgICAgICAgICAgfHwgKHBvcnRJbmRleCA9PSBrUG9ydEluZGV4T3V0cHV0ICYmIHVzaW5nTWV0YWRhdGFPbkVuY29kZXJPdXRwdXQoKSkpIHsKICAgICAgICAgICAgICAgICAgICAgbWVtLmNsZWFyKCk7CiAKICAgICAgICAgICAgICAgICAgICAgdm9pZCAqcHRyOwogICAgICAgICAgICAgICAgICAgICBlcnIgPSBtT01YLT5hbGxvY2F0ZUJ1ZmZlcigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgcG9ydEluZGV4LCBkZWYubkJ1ZmZlclNpemUsICZpbmZvLm1CdWZmZXJJRCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgcG9ydEluZGV4LCBidWZTaXplLCAmaW5mby5tQnVmZmVySUQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnB0cik7CiAKLSAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBidWZTaXplID0gbVVzZU1ldGFkYXRhT25FbmNvZGVyT3V0cHV0ID8KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAoNCArIHNpemVvZihidWZmZXJfaGFuZGxlX3QpKSA6IGRlZi5uQnVmZmVyU2l6ZTsKLQogICAgICAgICAgICAgICAgICAgICBpbmZvLm1EYXRhID0gbmV3IEFCdWZmZXIocHRyLCBidWZTaXplKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG1RdWlya3MgJiByZXF1aXJlc0FsbG9jYXRlQnVmZmVyQml0KSB7CiAgICAgICAgICAgICAgICAgICAgIGVyciA9IG1PTVgtPmFsbG9jYXRlQnVmZmVyV2l0aEJhY2t1cCgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgcG9ydEluZGV4LCBtZW0sICZpbmZvLm1CdWZmZXJJRCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU5vZGUsIHBvcnRJbmRleCwgbWVtLCAmaW5mby5tQnVmZmVySUQsIGFsbG90dGVkU2l6ZSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgZXJyID0gbU9NWC0+dXNlQnVmZmVyKG1Ob2RlLCBwb3J0SW5kZXgsIG1lbSwgJmluZm8ubUJ1ZmZlcklEKTsKKyAgICAgICAgICAgICAgICAgICAgZXJyID0gbU9NWC0+dXNlQnVmZmVyKG1Ob2RlLCBwb3J0SW5kZXgsIG1lbSwgJmluZm8ubUJ1ZmZlcklELCBhbGxvdHRlZFNpemUpOwogICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgIGlmIChtZW0gIT0gTlVMTCkgewotICAgICAgICAgICAgICAgICAgICBpbmZvLm1EYXRhID0gbmV3IEFCdWZmZXIobWVtLT5wb2ludGVyKCksIGRlZi5uQnVmZmVyU2l6ZSk7CisgICAgICAgICAgICAgICAgICAgIGluZm8ubURhdGEgPSBuZXcgQUJ1ZmZlcihtZW0tPnBvaW50ZXIoKSwgY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RXhwZXJpbWVudEVuYWJsZWQoCisgICAgICAgICAgICAgICAgICAgICAgICAibGVnYWN5LWFkYXB0aXZlIiwgIW1zZy0+Y29udGFpbnMoIm5vLWV4cGVyaW1lbnRzIikpOworCiAgICAgICAgICAgICAgICAgaW5wdXRGb3JtYXQtPnNldEludDMyKCJhZGFwdGl2ZS1wbGF5YmFjayIsIHRydWUpOwogICAgICAgICAgICAgfQogCkBAIC0xNjI3LDIyICsxODg1LDMwIEBACiAKICAgICAgICAgaWYgKGhhdmVOYXRpdmVXaW5kb3cpIHsKICAgICAgICAgICAgIG1OYXRpdmVXaW5kb3cgPSBzdGF0aWNfY2FzdDxTdXJmYWNlICo+KG9iai5nZXQoKSk7Ci0gICAgICAgICAgICBDSEVDSyhtTmF0aXZlV2luZG93ICE9IE5VTEwpOwogICAgICAgICB9CiAKICAgICAgICAgLy8gaW5pdGlhbGl6ZSBuYXRpdmUgd2luZG93IG5vdyB0byBnZXQgYWN0dWFsIG91dHB1dCBmb3JtYXQKICAgICAgICAgLy8gVE9ETzogdGhpcyBpcyBuZWVkZWQgZm9yIHNvbWUgZW5jb2RlcnMgZXZlbiB0aG91Z2ggdGhleSBkb24ndCB1c2UgbmF0aXZlIHdpbmRvdwotICAgICAgICBDSEVDS19FUSgoc3RhdHVzX3QpT0ssIGluaXROYXRpdmVXaW5kb3coKSk7CisgICAgICAgIGVyciA9IGluaXROYXRpdmVXaW5kb3coKTsKKyAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgfQogCiAgICAgICAgIC8vIGZhbGxiYWNrIGZvciBkZXZpY2VzIHRoYXQgZG8gbm90IGhhbmRsZSBmbGV4LVlVViBmb3IgbmF0aXZlIGJ1ZmZlcnMKICAgICAgICAgaWYgKGhhdmVOYXRpdmVXaW5kb3cpIHsKICAgICAgICAgICAgIGludDMyX3QgcmVxdWVzdGVkQ29sb3JGb3JtYXQgPSBPTVhfQ09MT1JfRm9ybWF0VW51c2VkOwogICAgICAgICAgICAgaWYgKG1zZy0+ZmluZEludDMyKCJjb2xvci1mb3JtYXQiLCAmcmVxdWVzdGVkQ29sb3JGb3JtYXQpICYmCiAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RlZENvbG9yRm9ybWF0ID09IE9NWF9DT0xPUl9Gb3JtYXRZVVY0MjBGbGV4aWJsZSkgewotICAgICAgICAgICAgICAgIENIRUNLX0VRKGdldFBvcnRGb3JtYXQoa1BvcnRJbmRleE91dHB1dCwgb3V0cHV0Rm9ybWF0KSwgKHN0YXR1c190KU9LKTsKKyAgICAgICAgICAgICAgICBzdGF0dXNfdCBlcnIgPSBnZXRQb3J0Rm9ybWF0KGtQb3J0SW5kZXhPdXRwdXQsIG91dHB1dEZvcm1hdCk7CisgICAgICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXJyOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBpbnQzMl90IGNvbG9yRm9ybWF0ID0gT01YX0NPTE9SX0Zvcm1hdFVudXNlZDsKICAgICAgICAgICAgICAgICBPTVhfVTMyIGZsZXhpYmxlRXF1aXZhbGVudCA9IE9NWF9DT0xPUl9Gb3JtYXRVbnVzZWQ7Ci0gICAgICAgICAgICAgICAgQ0hFQ0sob3V0cHV0Rm9ybWF0LT5maW5kSW50MzIoImNvbG9yLWZvcm1hdCIsICZjb2xvckZvcm1hdCkpOworICAgICAgICAgICAgICAgIGlmICghb3V0cHV0Rm9ybWF0LT5maW5kSW50MzIoImNvbG9yLWZvcm1hdCIsICZjb2xvckZvcm1hdCkpIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoIm91cHR1dCBwb3J0IGRpZCBub3QgaGF2ZSBhIGNvbG9yIGZvcm1hdCAod3JvbmcgZG9tYWluPykiKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgQUxPR0QoIlslc10gUmVxdWVzdGVkIG91dHB1dCBmb3JtYXQgJSN4IGFuZCBnb3QgJSN4LiIsCiAgICAgICAgICAgICAgICAgICAgICAgICBtQ29tcG9uZW50TmFtZS5jX3N0cigpLCByZXF1ZXN0ZWRDb2xvckZvcm1hdCwgY29sb3JGb3JtYXQpOwogICAgICAgICAgICAgICAgIGlmICghaXNGbGV4aWJsZUNvbG9yRm9ybWF0KApAQCAtMTY1NCw5ICsxOTIwLDEwIEBACiAgICAgICAgICAgICAgICAgICAgIG1OYXRpdmVXaW5kb3cuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgaGF2ZU5hdGl2ZVdpbmRvdyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICB1c2luZ1N3UmVuZGVyZXIgPSB0cnVlOwotICAgICAgICAgICAgICAgICAgICBpZiAobVN0b3JlTWV0YURhdGFJbk91dHB1dEJ1ZmZlcnMpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGVyciA9IG1PTVgtPnN0b3JlTWV0YURhdGFJbkJ1ZmZlcnMobU5vZGUsIGtQb3J0SW5kZXhPdXRwdXQsIE9NWF9GQUxTRSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBtU3RvcmVNZXRhRGF0YUluT3V0cHV0QnVmZmVycyA9IGZhbHNlOworICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmluZ01ldGFkYXRhSW5EZWNvZGVkQnVmZmVycygpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBlcnIgPSBtT01YLT5zdG9yZU1ldGFEYXRhSW5CdWZmZXJzKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwga1BvcnRJbmRleE91dHB1dCwgT01YX0ZBTFNFLCAmbU91dHB1dE1ldGFkYXRhVHlwZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBtT3V0cHV0TWV0YWRhdGFUeXBlID0ga01ldGFkYXRhQnVmZmVyVHlw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HVzX3QpT0spOworICAgIHN0YXR1c190IGVyciA9IG1PTVgtPmdldFBhcmFtZXRlcihtTm9kZSwgT01YX0luZGV4UGFyYW1Qb3J0RGVmaW5pdGlvbiwgJmRlZiwgc2l6ZW9mKGRlZikpOworICAgIGlmIChlcnIgIT0gT0spIHsKKyAgICAgICAgcmV0dXJuIGVycjsKKyAgICB9CiAKLSAgICBDSEVDS19FUSgoaW50KWRlZi5lRGlyLAotICAgICAgICAgICAgKGludCkocG9ydEluZGV4ID09IGtQb3J0SW5kZXhPdXRwdXQgPyBPTVhfRGlyT3V0cHV0IDogT01YX0RpcklucHV0KSk7CisgICAgaWYgKGRlZi5lRGlyICE9IChwb3J0SW5kZXggPT0ga1BvcnRJbmRleE91dHB1dCA/IE9NWF9EaXJPdXRwdXQgOiBPTVhfRGlySW5wdXQpKSB7CisgICAgICAgIEFMT0dFKCJ1bmV4cGVjdGVkIGRpcjogJXMoJWQpIG9uICVzIHBvcnQiLCBhc1N0cmluZyhkZWYuZURpciksIGRlZi5lRGlyLCBuaWNlSW5kZXgpOworICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgIH0KIAogICAgIHN3aXRjaCAoZGVmLmVEb21haW4pIHsKICAgICAgICAgY2FzZSBPTVhfUG9ydERvbWFpblZpZGVvOgpAQCAtMzc0NSwxMiArNDAyOSwxNiBAQAogICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5uSGVpZ2h0ID0gdmlkZW9EZWYtPm5GcmFtZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgICAgIENIRUNLX0dFKHJlY3QubkxlZnQsIDApOwotICAgICAgICAgICAgICAgICAgICBDSEVDS19HRShyZWN0Lm5Ub3AsIDApOwotICAgICAgICAgICAgICAgICAgICBDSEVDS19HRShyZWN0Lm5XaWR0aCwgMHUpOwotICAgICAgICAgICAgICAgICAgICBDSEVDS19HRShyZWN0Lm5IZWlnaHQsIDB1KTsKLSAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfTEUocmVjdC5uTGVmdCArIHJlY3QubldpZHRoIC0gMSwgdmlkZW9EZWYtPm5GcmFtZVdpZHRoKTsKLSAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfTEUocmVjdC5uVG9wICsgcmVjdC5uSGVpZ2h0IC0gMSwgdmlkZW9EZWYtPm5GcmFtZUhlaWdodCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0Lm5MZWZ0IDwgMCB8fAorICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5uVG9wIDwgMCB8fAorICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5uTGVmdCArIHJlY3QubldpZHRoID4gdmlkZW9EZWYtPm5GcmFtZVdpZHRoIHx8CisgICAgICAgICAgICAgICAgICAgICAgICByZWN0Lm5Ub3AgKyByZWN0Lm5IZWlnaHQgPiB2aWRlb0RlZi0+bkZyYW1lSGVpZ2h0KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiV3JvbmcgY3JvcHBlZCByZWN0ICglZCwgJWQpIC0gKCV1LCAldSkgdnMuIGZyYW1lICgldSwgJXUpIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5uTGVmdCwgcmVjdC5uVG9wLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0Lm5MZWZ0ICsgcmVjdC5uV2lkdGgsIHJlY3QublRvcCArIHJlY3QubkhlaWdodCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlkZW9EZWYtPm5GcmFtZVdpZHRoLCB2aWRlb0RlZi0+bkZyYW1lSGVpZ2h0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldFJlY3QoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImNyb3AiLApAQCAtMzgwNyw3ICs0MDk1LDEzIEBACiAKICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgIHsKLSAgICAgICAgICAgICAgICAgICAgQ0hFQ0sobUlzRW5jb2RlciBeIChwb3J0SW5kZXggPT0ga1BvcnRJbmRleElucHV0KSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChtSXNFbmNvZGVyIF4gKHBvcnRJbmRleCA9PSBrUG9ydEluZGV4T3V0cHV0KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgLy8gc2hvdWxkIGJlIENvZGluZ1VudXNlZAorICAgICAgICAgICAgICAgICAgICAgICAgQUxPR0UoIlJhdyBwb3J0IHZpZGVvIGNvbXByZXNzaW9uIGZvcm1hdCBpcyAlcyglZCkiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhc1N0cmluZyh2aWRlb0RlZi0+ZUNvbXByZXNzaW9uRm9ybWF0KSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlkZW9EZWYtPmVDb21wcmVzc2lvbkZvcm1hdCk7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIEFTdHJpbmcgbWltZTsKICAgICAgICAgICAgICAgICAgICAgaWYgKEdldE1pbWVUeXBlRm9yVmlkZW9Db2RpbmcoCiAgICAgICAgICAgICAgICAgICAgICAgICB2aWRlb0RlZi0+ZUNvbXByZXNzaW9uRm9ybWF0LCAmbWltZSkgIT0gT0spIHsKQEAgLTM4MzgsMjAgKzQxMzIsMjUgQEAKICAgICAgICAgICAgICAgICAgICAgSW5pdE9NWFBhcmFtcygmcGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLm5Qb3J0SW5kZXggPSBwb3J0SW5kZXg7CiAKLSAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfRVEobU9NWC0+Z2V0UGFyYW1ldGVyKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgT01YX0luZGV4UGFyYW1BdWRpb1BjbSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnBhcmFtcywgc2l6ZW9mKHBhcmFtcykpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3RhdHVzX3QpT0spOworICAgICAgICAgICAgICAgICAgICBlcnIgPSBtT01YLT5nZXRQYXJhbWV0ZXIoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU5vZGUsIE9NWF9JbmRleFBhcmFtQXVkaW9QY20sICZwYXJhbXMsIHNpemVvZihwYXJhbXMpKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgICAgIENIRUNLX0dUKHBhcmFtcy5uQ2hhbm5lbHMsIDApOwotICAgICAgICAgICAgICAgICAgICBDSEVDSyhwYXJhbXMubkNoYW5uZWxzID09IDEgfHwgcGFyYW1zLmJJbnRlcmxlYXZlZCk7Ci0gICAgICAgICAgICAgICAgICAgIENIRUNLX0VRKHBhcmFtcy5uQml0UGVyU2FtcGxlLCAxNnUpOwotCi0gICAgICAgICAgICAgICAgICAgIENIRUNLX0VRKChpbnQpcGFyYW1zLmVOdW1EYXRhLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoaW50KU9NWF9OdW1lcmljYWxEYXRhU2lnbmVkKTsKLQotICAgICAgICAgICAgICAgICAgICBDSEVDS19FUSgoaW50KXBhcmFtcy5lUENNTW9kZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGludClPTVhfQVVESU9fUENNTW9kZUxpbmVhcik7CisgICAgICAgICAgICAgICAgICAgIGlmIChwYXJhbXMubkNoYW5uZWxzIDw9IDAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB8fCAocGFyYW1zLm5DaGFubmVscyAhPSAxICYmICFwYXJhbXMuYkludGVybGVhdmVkKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHx8IHBhcmFtcy5uQml0UGVyU2FtcGxlICE9IDE2dQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHx8IHBhcmFtcy5lTnVtRGF0YSAhPSBPTVhfTnVtZXJpY2FsRGF0YVNpZ25lZAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHx8IHBhcmFtcy5lUENNTW9kZSAhPSBPTVhfQVVESU9fUENNTW9kZUxpbmVhcikgeworICAgICAgICAgICAgICAgICAgICAgICAgQUxPR0UoInVuc3VwcG9ydGVkIFBDTSBwb3J0OiAldSBjaGFubmVscyVzLCAldS1iaXQsICVzKCVkKSwgJXMoJWQpIG1vZGUgIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLm5DaGFubmVscywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLmJJbnRlcmxlYXZlZCA/ICIgaW50ZXJsZWF2ZWQiIDogIiIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy5uQml0UGVyU2FtcGxlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhc1N0cmluZyhwYXJhbXMuZU51bURhdGEpLCBwYXJhbXMuZU51bURhdGEsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFzU3RyaW5nKHBhcmFtcy5lUENNTW9kZSksIHBhcmFtcy5lUENNTW9kZSk7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gRkFJTEVEX1RSQU5TQUNUSU9OOworICAgICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAgICAgbm90aWZ5LT5zZXRTdHJpbmcoIm1pbWUiLCBNRURJQV9NSU1FVFlQRV9BVURJT19SQVcpOwogICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldEludDMyKCJjaGFubmVsLWNvdW50IiwgcGFyYW1zLm5DaGFubmVscyk7CkBAIC0zODY5LDEwICs0MTY4LDExIEBACiAgICAgICAgICAgICAgICAgICAgIEluaXRPTVhQYXJhbXMoJnBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy5uUG9ydEluZGV4ID0gcG9ydEluZGV4OwogCi0gICAgICAgICAgICAgICAgICAgIENIRUNLX0VRKG1PTVgtPmdldFBhcmFtZXRlcigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU5vZGUsIE9NWF9JbmRleFBhcmFtQXVkaW9BYWMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZwYXJhbXMsIHNpemVvZihwYXJhbXMpKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHN0YXR1c190KU9LKTsKKyAgICAgICAgICAgICAgICAgICAgZXJyID0gbU9NWC0+Z2V0UGFyYW1ldGVyKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Ob2RlLCBPTVhfSW5kZXhQYXJhbUF1ZGlvQWFjLCAmcGFyYW1zLCBzaXplb2YocGFyYW1zKSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChlcnIgIT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnI7CisgICAgICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldFN0cmluZygibWltZSIsIE1FRElBX01JTUVUWVBFX0FVRElPX0FBQyk7CiAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0SW50MzIoImNoYW5uZWwtY291bnQiLCBwYXJhbXMubkNoYW5uZWxzKTsKQEAgLTM4ODYsMjEgKzQxODYsMTggQEAKICAgICAgICAgICAgICAgICAgICAgSW5pdE9NWFBhcmFtcygmcGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLm5Qb3J0SW5kZXggPSBwb3J0SW5kZXg7CiAKLSAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfRVEobU9NWC0+Z2V0UGFyYW1ldGVyKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgT01YX0luZGV4UGFyYW1BdWRpb0FtciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnBhcmFtcywgc2l6ZW9mKHBhcmFtcykpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3RhdHVzX3QpT0spOworICAgICAgICAgICAgICAgICAgICBlcnIgPSBtT01YLT5nZXRQYXJhbWV0ZXIoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU5vZGUsIE9NWF9JbmRleFBhcmFtQXVkaW9BbXIsICZwYXJhbXMsIHNpemVvZihwYXJhbXMpKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0SW50MzIoImNoYW5uZWwtY291bnQiLCAxKTsKICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtcy5lQU1SQmFuZE1vZGUgPj0gT01YX0FVRElPX0FNUkJhbmRNb2RlV0IwKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldFN0cmluZygKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIm1pbWUiLCBNRURJQV9NSU1FVFlQRV9BVURJT19BTVJfV0IpOwotCisgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldFN0cmluZygibWltZSIsIE1FRElBX01JTUVUWVBFX0FVRElPX0FNUl9XQik7CiAgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldEludDMyKCJzYW1wbGUtcmF0ZSIsIDE2MDAwKTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0U3RyaW5nKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAibWltZSIsIE1FRElBX01JTUVUWVBFX0FVRElPX0FNUl9OQik7Ci0KKyAgICAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0U3RyaW5nKCJtaW1lIiwgTUVESUFfTUlNRVRZUEVfQVVESU9fQU1SX05CKTsKICAgICAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0SW50MzIoInNhbXBsZS1yYXRlIiwgODAwMCk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0zOTEyLDEwICs0MjA5LDExIEBACiAgICAgICAgICAgICAgICAgICAgIEluaXRPTVhQYXJhbXMoJnBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy5uUG9ydEluZGV4ID0gcG9ydEluZGV4OwogCi0gICAgICAgICAgICAgICAgICAgIENIRUNLX0VRKG1PTVgtPmdldFBhcmFtZXRlcigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU5vZGUsIE9NWF9JbmRleFBhcmFtQXVkaW9GbGFjLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmcGFyYW1zLCBzaXplb2YocGFyYW1zKSksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzdGF0dXNfdClPSyk7CisgICAgICAgICAgICAgICAgICAgIGVyciA9IG1PTVgtPmdldFBhcmFtZXRlcigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgT01YX0luZGV4UGFyYW1BdWRpb0ZsYWMsICZwYXJhbXMsIHNpemVvZihwYXJhbXMpKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0U3RyaW5nKCJtaW1lIiwgTUVESUFfTUlNRVRZUEVfQVVESU9fRkxBQyk7CiAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0SW50MzIoImNoYW5uZWwtY291bnQiLCBwYXJhbXMubkNoYW5uZWxzKTsKQEAgLTM5MjksMTAgKzQyMjcsMTEgQEAKICAgICAgICAgICAgICAgICAgICAgSW5pdE9NWFBhcmFtcygmcGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLm5Qb3J0SW5kZXggPSBwb3J0SW5kZXg7CiAKLSAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfRVEobU9NWC0+Z2V0UGFyYW1ldGVyKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgT01YX0luZGV4UGFyYW1BdWRpb01wMywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnBhcmFtcywgc2l6ZW9mKHBhcmFtcykpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3RhdHVzX3QpT0spOworICAgICAgICAgICAgICAgICAgICBlcnIgPSBtT01YLT5nZXRQYXJhbWV0ZXIoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU5vZGUsIE9NWF9JbmRleFBhcmFtQXVkaW9NcDMsICZwYXJhbXMsIHNpemVvZihwYXJhbXMpKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0U3RyaW5nKCJtaW1lIiwgTUVESUFfTUlNRVRZUEVfQVVESU9fTVBFRyk7CiAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0SW50MzIoImNoYW5uZWwtY291bnQiLCBwYXJhbXMubkNoYW5uZWxzKTsKQEAgLTM5NDYsMTAgKzQyNDUsMTEgQEAKICAgICAgICAgICAgICAgICAgICAgSW5pdE9NWFBhcmFtcygmcGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLm5Qb3J0SW5kZXggPSBwb3J0SW5kZXg7CiAKLSAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfRVEobU9NWC0+Z2V0UGFyYW1ldGVyKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgT01YX0luZGV4UGFyYW1BdWRpb1ZvcmJpcywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnBhcmFtcywgc2l6ZW9mKHBhcmFtcykpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3RhdHVzX3QpT0spOworICAgICAgICAgICAgICAgICAgICBlcnIgPSBtT01YLT5nZXRQYXJhbWV0ZXIoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU5vZGUsIE9NWF9JbmRleFBhcmFtQXVkaW9Wb3JiaXMsICZwYXJhbXMsIHNpemVvZihwYXJhbXMpKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0U3RyaW5nKCJtaW1lIiwgTUVESUFfTUlNRVRZUEVfQVVESU9fVk9SQklTKTsKICAgICAgICAgICAgICAgICAgICAgbm90aWZ5LT5zZXRJbnQzMigiY2hhbm5lbC1jb3VudCIsIHBhcmFtcy5uQ2hhbm5lbHMpOwpAQCAtMzk2MywxMSArNDI2MywxMiBAQAogICAgICAgICAgICAgICAgICAgICBJbml0T01YUGFyYW1zKCZwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICBwYXJhbXMublBvcnRJbmRleCA9IHBvcnRJbmRleDsKIAotICAgICAgICAgICAgICAgICAgICBDSEVDS19FUSgoc3RhdHVzX3QpT0ssIG1PTVgtPmdldFBhcmFtZXRlcigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAoT01YX0lOREVYVFlQRSlPTVhfSW5kZXhQYXJhbUF1ZGlvQW5kcm9pZEFjMywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAmcGFyYW1zLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVvZihwYXJhbXMpKSk7CisgICAgICAgICAgICAgICAgICAgIGVyciA9IG1PTVgtPmdldFBhcmFtZXRlcigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgKE9NWF9JTkRFWFRZUEUpT01YX0luZGV4UGFyYW1BdWRpb0FuZHJvaWRBYzMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnBhcmFtcywgc2l6ZW9mKHBhcmFtcykpOworICAgICAgICAgICAgICAgICAgICBpZiAoZXJyICE9IE9LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXJyOworICAgICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAgICAgbm90aWZ5LT5zZXRTdHJpbmcoIm1pbWUiLCBNRURJQV9NSU1FVFlQRV9BVURJT19BQzMpOwogICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldEludDMyKCJjaGFubmVsLWNvdW50IiwgcGFyYW1zLm5DaGFubmVscyk7CkBAIC0zOTgxLDExICs0MjgyLDEyIEBACiAgICAgICAgICAgICAgICAgICAgIEluaXRPTVhQYXJhbXMoJnBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy5uUG9ydEluZGV4ID0gcG9ydEluZGV4OwogCi0gICAgICAgICAgICAgICAgICAgIENIRUNLX0VRKChzdGF0dXNfdClPSywgbU9NWC0+Z2V0UGFyYW1ldGVyKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Ob2RlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIChPTVhfSU5ERVhUWVBFKU9NWF9JbmRleFBhcmFtQXVkaW9BbmRyb2lkRWFjMywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAmcGFyYW1zLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVvZihwYXJhbXMpKSk7CisgICAgICAgICAgICAgICAgICAgIGVyciA9IG1PTVgtPmdldFBhcmFtZXRlcigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgKE9NWF9JTkRFWFRZUEUpT01YX0luZGV4UGFyYW1BdWRpb0FuZHJvaWRFYWMzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICZwYXJhbXMsIHNpemVvZihwYXJhbXMpKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0U3RyaW5nKCJtaW1lIiwgTUVESUFfTUlNRVRZUEVfQVVESU9fRUFDMyk7CiAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0SW50MzIoImNoYW5uZWwtY291bnQiLCBwYXJhbXMubkNoYW5uZWxzKTsKQEAgLTM5OTksMTEgKzQzMDEsMTIgQEAKICAgICAgICAgICAgICAgICAgICAgSW5pdE9NWFBhcmFtcygmcGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLm5Qb3J0SW5kZXggPSBwb3J0SW5kZXg7CiAKLSAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfRVEoKHN0YXR1c190KU9LLCBtT01YLT5nZXRQYXJhbWV0ZXIoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbU5vZGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgKE9NWF9JTkRFWFRZUEUpT01YX0luZGV4UGFyYW1BdWRpb0FuZHJvaWRPcHVzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICZwYXJhbXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZW9mKHBhcmFtcykpKTsKKyAgICAgICAgICAgICAgICAgICAgZXJyID0gbU9NWC0+Z2V0UGFyYW1ldGVyKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Ob2RlLCAoT01YX0lOREVYVFlQRSlPTVhfSW5kZXhQYXJhbUF1ZGlvQW5kcm9pZE9wdXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnBhcmFtcywgc2l6ZW9mKHBhcmFtcykpOworICAgICAgICAgICAgICAgICAgICBpZiAoZXJyICE9IE9LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXJyOworICAgICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAgICAgbm90aWZ5LT5zZXRTdHJpbmcoIm1pbWUiLCBNRURJQV9NSU1FVFlQRV9BVURJT19PUFVTKTsKICAgICAgICAgICAgICAgICAgICAgbm90aWZ5LT5zZXRJbnQzMigiY2hhbm5lbC1jb3VudCIsIHBhcmFtcy5uQ2hhbm5lbHMpOwpAQCAtNDAxNywxMSArNDMyMCwxMSBAQAogICAgICAgICAgICAgICAgICAgICBJbml0T01YUGFyYW1zKCZwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICBwYXJhbXMublBvcnRJbmRleCA9IHBvcnRJbmRleDsKIAotICAgICAgICAgICAgICAgICAgICBDSEVDS19FUSgoc3RhdHVzX3QpT0ssIG1PTVgtPmdldFBhcmFtZXRlcigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAoT01YX0lOREVYVFlQRSlPTVhfSW5kZXhQYXJhbUF1ZGlvUGNtLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICZwYXJhbXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZW9mKHBhcmFtcykpKTsKKyAgICAgICAgICAgICAgICAgICAgZXJyID0gbU9NWC0+Z2V0UGFyYW1ldGVyKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Ob2RlLCAoT01YX0lOREVYVFlQRSlPTVhfSW5kZXhQYXJhbUF1ZGlvUGNtLCAmcGFyYW1zLCBzaXplb2YocGFyYW1zKSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChlcnIgIT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnI7CisgICAgICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyICptaW1lID0gTlVMTDsKICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtcy5lUENNTW9kZSA9PSBPTVhfQVVESU9fUENNTW9kZU1VTGF3KSB7CkBAIC00MDM5LDMwICs0MzQyLDMzIEBACiAKICAgICAgICAgICAgICAgICBjYXNlIE9NWF9BVURJT19Db2RpbmdHU01GUjoKICAgICAgICAgICAgICAgICB7Ci0gICAgICAgICAgICAgICAgICAgIE9NWF9BVURJT19QQVJBTV9NUDNUWVBFIHBhcmFtczsKKyAgICAgICAgICAgICAgICAgICAgT01YX0FVRElPX1BBUkFNX1BDTU1PREVUWVBFIHBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgSW5pdE9NWFBhcmFtcygmcGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLm5Qb3J0SW5kZXggPSBwb3J0SW5kZXg7CiAKLSAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfRVEobU9NWC0+Z2V0UGFyYW1ldGVyKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTm9kZSwgT01YX0luZGV4UGFyYW1BdWRpb1BjbSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnBhcmFtcywgc2l6ZW9mKHBhcmFtcykpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3RhdHVzX3QpT0spOworICAgICAgICAgICAgICAgICAgICBlcnIgPSBtT01YLT5nZXRQYXJhbWV0ZXIoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Ob2RlLCBPTVhfSW5kZXhQYXJhbUF1ZGlvUGNtLCAmcGFyYW1zLCBzaXplb2YocGFyYW1zKSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChlcnIgIT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnI7CisgICAgICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldFN0cmluZygibWltZSIsIE1FRElBX01JTUVUWVBFX0FVRElPX01TR1NNKTsKICAgICAgICAgICAgICAgICAgICAgbm90aWZ5LT5zZXRJbnQzMigiY2hhbm5lbC1jb3VudCIsIHBhcmFtcy5uQ2hhbm5lbHMpOwotICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldEludDMyKCJzYW1wbGUtcmF0ZSIsIHBhcmFtcy5uU2FtcGxlUmF0ZSk7CisgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0SW50MzIoInNhbXBsZS1yYXRlIiwgcGFyYW1zLm5TYW1wbGluZ1JhdGUpOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgICAgICBBTE9HRSgiVU5LTk9XTiBBVURJTyBDT0RJTkc6ICVkXG4iLCBhdWRpb0RlZi0+ZUVuY29kaW5nKTsKLSAgICAgICAgICAgICAgICAgICAgVFJFU1BBU1MoKTsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoIlVuc3VwcG9ydGVkIGF1ZGlvIGNvZGluZzogJXMoJWQpXG4iLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFzU3RyaW5nKGF1ZGlvRGVmLT5lRW5jb2RpbmcpLCBhdWRpb0RlZi0+ZUVuY29kaW5nKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9UWVBFOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0K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XX1dSSVRFX09GVEVOLCAodm9pZCoqKSgmaW1nKSk7Ci0gICAgICAgIGlmIChlcnIgIT0gTk9fRVJST1IpIHsKLSAgICAgICAgICAgIEFMT0dFKCJlcnJvciBwdXNoaW5nIGJsYW5rIGZyYW1lczogbG9jayBmYWlsZWQ6ICVzICglZCkiLAotICAgICAgICAgICAgICAgICAgICBzdHJlcnJvcigtZXJyKSwgLWVycik7Ci0gICAgICAgICAgICBnb3RvIGVycm9yOwotICAgICAgICB9Ci0KLSAgICAgICAgKmltZyA9IDA7Ci0KLSAgICAgICAgZXJyID0gYnVmLT51bmxvY2soKTsKLSAgICAgICAgaWYgKGVyciAhPSBOT19FUlJPUikgewotICAgICAgICAgICAgQUxPR0UoImVycm9yIHB1c2hpbmcgYmxhbmsgZnJhbWVzOiB1bmxvY2sgZmFpbGVkOiAlcyAoJWQpIiwKLSAgICAgICAgICAgICAgICAgICAgc3RyZXJyb3IoLWVyciksIC1lcnIpOwotICAgICAgICAgICAgZ290byBlcnJvcjsKLSAgICAgICAgfQotCi0gICAgICAgIGVyciA9IG1OYXRpdmVXaW5kb3ctPnF1ZXVlQnVmZmVyKG1OYXRpdmVXaW5kb3cuZ2V0KCksCi0gICAgICAgICAgICAgICAgYnVmLT5nZXROYXRpdmVCdWZmZXIoKSwgLTEpOwotICAgICAgICBpZiAoZXJyICE9IE5PX0VSUk9SKSB7Ci0gICAgICAgICAgICBBTE9HRSgiZXJyb3IgcHVzaGluZyBibGFuayBmcmFtZXM6IHF1ZXVlQnVmZmVyIGZhaWxlZDogJXMgKCVkKSIsCi0gICAgICAgICAgICAgICAgICAgIHN0cmVycm9yKC1lcnIpLCAtZXJyKTsKLSAgICAgICAgICAgIGdvdG8gZXJyb3I7Ci0gICAgICAgIH0KLQotICAgICAgICBhbmIgPSBOVUxMOwotICAgIH0KLQotZXJyb3I6Ci0KLSAgICBpZiAoZXJyICE9IE5PX0VSUk9SKSB7Ci0gICAgICAgIC8vIENsZWFuIHVwIGFmdGVy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Q0sobXNnLT5maW5kSW50MzIoInJhbmdlX29mZnNldCIsICZyYW5nZU9mZnNldCkpOwogICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50MzIoInJhbmdlX2xlbmd0aCIsICZyYW5nZUxlbmd0aCkpOwogICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50MzIoImZsYWdzIiwgJmZsYWdzKSk7CiAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQ2NCgidGltZXN0YW1wIiwgJnRpbWVVcykpOworICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50MzIoImZlbmNlX2ZkIiwgJmZlbmNlRmQpKTsKIAogICAgICAgICAgICAgcmV0dXJuIG9uT01YRmlsbEJ1ZmZlckRvbmUoCiAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlcklELAogICAgICAgICAgICAgICAgICAgICAoc2l6ZV90KXJhbmdlT2Zmc2V0LCAoc2l6ZV90KXJhbmdlTGVuZ3RoLAogICAgICAgICAgICAgICAgICAgICAoT01YX1UzMilmbGFncywKLSAgICAgICAgICAgICAgICAgICAgdGltZVVzKTsKKyAgICAgICAgICAgICAgICAgICAgdGltZVVzLAorICAgICAgICAgICAgICAgICAgICBmZW5jZUZkKTsKKyAgICAgICAgfQorCisgICAgICAgIGNhc2Ugb214X21lc3NhZ2U6OkZSQU1FX1JFTkRFUkVEOgorICAgICAgICB7CisgICAgICAgICAgICBpbnQ2NF90IG1lZGlhVGltZVVzLCBzeXN0ZW1OYW5vOworCisgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQ2NCgibWVkaWFfdGltZV91cyIsICZtZWRpYVRpbWVVcykpOworICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50NjQoInN5c3RlbV9uYW5vIiwgJnN5c3RlbU5hbm8pKTsKKworICAgICAgICAgICAgcmV0dXJuIG9uT01YRnJhbWVSZW5kZXJlZCgKKyAgICAgICAgICAgICAgICAgICAgbWVkaWFUaW1lVX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cyIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTWV0YURhdGFCdWZmZXJzVG9TdWJtaXQsCisgICAgICAgICAgICAgICAgICAgIEFMT0dWKCJNZXRhZGF0YUJ1ZmZlcnNUb1N1Ym1pdD0ldSBwb3J0TW9kZT0lcyIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTWV0YWRhdGFCdWZmZXJzVG9TdWJtaXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKG91dHB1dE1vZGUgPT0gRlJFRV9CVUZGRVJTID8gIkZSRUUiIDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0TW9kZSA9PSBLRUVQX0JVRkZFUlMgPyAiS0VFUCIgOiAiUkVTVUJNSVQiKSk7CiAgICAgICAgICAgICAgICAgICAgIGlmIChvdXRwdXRNb2RlID09IFJFU1VCTUlUX0JVRkZFUlMpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+c3VibWl0T3V0cHV0TWV0YURhdGFCdWZmZXIoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+c3VibWl0T3V0cHV0TWV0YWRhdGFCdWZmZXIoKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgICAgIENIRUNLX0VRKG1Db2RlYy0+bU9NWC0+ZW1wdHlCdWZmZXIoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTm9kZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJJRCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAwLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci0+c2l6ZSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZsYWdzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWVVcyksCi0gICAgICAgICAgICAgICAgICAgICAgICAgKHN0YXR1c190KU9LKTsKLQorICAgICAgICAgICAgICAgIGluZm8tPmNoZWNrUmVhZEZlbmNlKCJvbklucHV0QnVmZmVyRmlsbGVkIik7CisgICAgICAgICAgICAgICAgc3RhdHVzX3QgZXJyMiA9IG1Db2RlYy0+bU9NWC0+ZW1wdHlCdWZmZXIoCisgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bU5vZGUsCisgICAgICAgICAgICAgICAgICAgIGJ1ZmZlcklELAorICAgICAgICAgICAgICAgICAgICAwLAorICAgICAgICAgICAgICAgICAgICBidWZmZXItPnNpemUoKSwKKyAgICAgICAgICAgICAgICAgICAgZmxhZ3MsCisgICAgICAgICAgICAgICAgICAgIHRpbWVVcywKKyAgICAgICAgICAgICAgICAgICAgaW5mby0+bUZlbmNlRmQpOworICAgICAgICAgICAgICAgIGluZm8tPm1GZW5jZUZkID0gLTE7CisgICAgICAgICAgICAgICAgaWYgKGVycjIgIT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5zaWduYWxFcnJvcihPTVhfRXJyb3JVbmRlZmluZWQsIG1ha2VOb1NpZGVFZmZlY3RTdGF0dXMoZXJyMikpOworICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGluZm8tPm1TdGF0dXMgPSBCdWZmZXJJbmZvOjpPV05FRF9CWV9DT01QT05FTlQ7CiAKLSAgICAgICAgICAgICAgICBpZiAoIWVvcykgeworICAgICAgICAgICAgICAgIGlmICghZW9zICYmIGVyciA9PSBPSykgewogICAgICAgICAgICAgICAgICAgICBnZXRNb3JlSW5wdXREYXRhSWZQb3NzaWJsZSgpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIEFMT0dWKCJbJXNdIFNpZ25hbGxlZCBFT1Mgb24gdGhlIGlucHV0IHBvcnQiLAotICAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bUNvbXBvbmVudE5hbWUuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgICAgIEFMT0dWKCJbJXNdIFNpZ25hbGxlZCBFT1MgKCVkKSBvbiB0aGUgaW5wdXQgcG9ydCIsCisgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tQ29tcG9uZW50TmFtZS5jX3N0cigpLCBlcnIpOwogCiAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bVBvcnRFT1Nba1BvcnRJbmRleElucHV0XSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bUlucHV0RU9TUmVzdWx0ID0gZXJyOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0gZWxzZSBpZiAoIW1Db2RlYy0+bVBvcnRFT1Nba1BvcnRJbmRleElucHV0XSkgewotICAgICAgICAgICAgICAgIGlmIChlcnIgIT0gRVJST1JfRU5EX09GX1NUUkVBTSkgewotICAgICAgICAgICAgICAgICAgICBBTE9HVigiWyVzXSBTaWduYWxsaW5nIEVPUyBvbiB0aGUgaW5wdXQgcG9ydCAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgImR1ZSB0byBlcnJvciAlZCIsCisgICAgICAgICAgICAgICAgaWYgKGVyciAhPSBPSyAmJiBlcnIgIT0gRVJST1JfRU5EX09GX1NUUkVBTSkgeworICAgICAgICAgICAgICAgICAgICBBTE9HVigiWyVzXSBTaWduYWxsaW5nIEVPUyBvbiB0aGUgaW5wdXQgcG9ydCBkdWUgdG8gZXJyb3IgJWQiLAogICAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bUNvbXBvbmVudE5hbWUuY19zdHIoKSwgZXJyKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICBBTE9HVigiWyVzXSBTaWduYWxsaW5nIEVPUyBvbiB0aGUgaW5wdXQgcG9ydCIsCkBAIC00Njc5LDE1ICs0OTQ0LDIwIEBACiAgICAgICAgICAgICAgICAgQUxPR1YoIlslc10gY2FsbGluZyBlbXB0eUJ1ZmZlciAldSBzaWduYWxsaW5nIEVPUyIsCiAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1Db21wb25lbnROYW1lLmNfc3RyKCksIGJ1ZmZlcklEKTsKIAotICAgICAgICAgICAgICAgIENIRUNLX0VRKG1Db2RlYy0+bU9NWC0+ZW1wdHlCdWZmZXIoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTm9kZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJJRCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAwLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIDAsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgT01YX0JVRkZFUkZMQUdfRU9TLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIDApLAotICAgICAgICAgICAgICAgICAgICAgICAgIChzdGF0dXNfdClPSyk7Ci0KKyAgICAgICAgICAgICAgICBpbmZvLT5jaGVja1JlYWRGZW5jZSgib25JbnB1dEJ1ZmZlckZpbGxlZCIpOworICAgICAgICAgICAgICAgIHN0YXR1c190IGVycjIgPSBtQ29kZWMtPm1PTVgtPmVtcHR5QnVmZmVyKAorICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTm9kZSwKKyAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlcklELAorICAgICAgICAgICAgICAgICAgICAgICAgMCwKKyAgICAgICAgICAgICAgICAgICAgICAgIDAsCisgICAgICAgICAgICAgICAgICAgICAgICBPTVhfQlVGRkVSRkxBR19FT1MsCisgICAgICAgICAgICAgICAgICAgICAgICAwLAorICAgICAgICAgICAgICAgICAgICAgICAgaW5mby0+bUZlbmNlRmQpOworICAgICAgICAgICAgICAgIGluZm8tPm1GZW5jZUZkID0gLTE7CisgICAgICAgICAgICAgICAgaWYgKGVycjIgIT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5zaWduYWxFcnJvcihPTVhfRXJyb3JVbmRlZmluZWQsIG1ha2VOb1NpZGVFZmZlY3RTdGF0dXMoZXJyMikpOworICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGluZm8tPm1TdGF0dXMgPSBCdWZmZXJJbmZvOjpPV05FRF9CWV9DT01QT05FTlQ7CiAKICAgICAgICAgICAgICAgICBtQ29kZWMtPm1Qb3J0RU9TW2tQb3J0SW5kZXhJbnB1dF0gPSB0cnVlOwpAQCAtNDY5Niw4ICs0OTY2LDExIEBACiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogCisgICAgICAgIGNhc2UgRlJFRV9CVUZGRVJTOgorICAgICAgICAgICAgYnJlYWs7CisKICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIENIRUNLX0VRKChpbnQpbW9kZSwgKGludClGUkVFX0JVRkZFUlMpOworICAgICAgICAgICAgQUxPR0UoImludmFsaWQgcG9ydCBtb2RlOiAlZCIsIG1vZGUpOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgfQogfQpAQCAtNDczNSwxMSArNTAwOCwxMyBAQAogICAgICAgICBJT01YOjpidWZmZXJfaWQgYnVmZmVySUQsCiAgICAgICAgIHNpemVfdCByYW5nZU9mZnNldCwgc2l6ZV90IHJhbmdlTGVuZ3RoLAogICAgICAgICBPTVhfVTMyIGZsYWdzLAotICAgICAgICBpbnQ2NF90IHRpbWVVcykgeworICAgICAgICBpbnQ2NF90IHRpbWVVcywKKyAgICAgICAgaW50IGZlbmNlRmQpIHsKICAgICBBTE9HVigiWyVzXSBvbk9NWEZpbGxCdWZmZXJEb25lICV1IHRpbWUgJSIgUFJJZDY0ICIgdXMsIGZsYWdzID0gMHglMDh4IiwKICAgICAgICAgIG1Db2RlYy0+bUNvbXBvbmVudE5hbWUuY19zdHIoKSwgYnVmZmVySUQsIHRpbWVVcywgZmxhZ3MpOwogCiAgICAgc3NpemV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ICAgIGZlbmNlRmQgPSAtMTsKKyAgICB9CisgICAgaW5mby0+c2V0UmVhZEZlbmNlKGZlbmNlRmQsICJvbk9NWEZpbGxCdWZmZXJEb25lIik7CisKICAgICBQb3J0TW9kZSBtb2RlID0gZ2V0UG9ydE1vZGUoa1BvcnRJbmRleE91dHB1dCk7CiAKICAgICBzd2l0Y2ggKG1vZGUpIHsKQEAgLTQ3NzcsOSArNTA3NiwxMiBAQAogICAgICAgICAgICAgICAgIEFMT0dWKCJbJXNdIGNhbGxpbmcgZmlsbEJ1ZmZlciAldSIsCiAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1Db21wb25lbnROYW1lLmNfc3RyKCksIGluZm8tPm1CdWZmZXJJRCk7CiAKLSAgICAgICAgICAgICAgICBDSEVDS19FUShtQ29kZWMtPm1PTVgtPmZpbGxCdWZmZXIoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTm9kZSwgaW5mby0+bUJ1ZmZlcklEKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAoc3RhdHVzX3QpT0spOworICAgICAgICAgICAgICAgIGVyciA9IG1Db2RlYy0+bU9NWC0+ZmlsbEJ1ZmZlcihtQ29kZWMtPm1Ob2RlLCBpbmZvLT5tQnVmZmVySUQsIGluZm8tPm1GZW5jZUZkKTsKKyAgICAgICAgICAgICAgICBpbmZvLT5tRmVuY2VGZCA9IC0xOworICAgICAgICAgICAgICAgIGlmIChlcnIgIT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5zaWduYWxFcnJvcihPTVhfRXJyb3JVbmRlZmluZWQsIG1ha2VOb1NpZGVFZmZlY3RTdGF0dXMoZXJyKSk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOworICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgIGluZm8tPm1TdGF0dXMgPSBCdWZmZXJJbmZvOjpPV05FRF9CWV9DT01QT05FTlQ7CiAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC00NzkxLDEwICs1MDkzLDE3IEBACiAgICAgICAgICAgICBpZiAoIW1Db2RlYy0+bVNlbnRGb3JtYXQgJiYgcmFuZ2VMZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgbUNvZGVjLT5zZW5kRm9ybWF0Q2hhbmdlKHJlcGx5KTsKICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgaWYgKG1Db2RlYy0+bVVzZU1ldGFkYXRhT25FbmNvZGVyT3V0cHV0KSB7Ci0gICAgICAgICAgICAgICAgbmF0aXZlX2hhbmRsZV90KiBoYW5kbGUgPQotICAgICAgICAgICAgICAgICAgICAgICAgKihuYXRpdmVfaGFuZGxlX3QqKikoaW5mby0+bURhdGEtPmRhdGEoKSArIDQpOworICAgICAgICAgICAgaWYgKG1Db2RlYy0+dXNpbmdNZXRhZGF0YU9uRW5jb2Rlck91dHB1dCgpKSB7CisgICAgICAgICAgICAgICAgbmF0aXZlX2hhbmRsZV90ICpoYW5kbGUgPSBOVUxMOworICAgICAgICAgICAgICAgIFZpZGVvR3JhbGxvY01ldGFkYXRhICZncmFsbG9jTWV0YSA9ICooVmlkZW9HcmFsbG9jTWV0YWRhdGEgKilpbmZvLT5tRGF0YS0+ZGF0YSgpOworICAgICAgICAgICAgICAgIFZpZGVvTmF0aXZlTWV0YWRhdGEgJm5hdGl2ZU1ldGEgPSAqKFZpZGVvTmF0aXZlTWV0YWRhdGEgKilpbmZvLT5tRGF0YS0+ZGF0YSgpOworICAgICAgICAgICAgICAgIGlmIChpbmZvLT5tRGF0YS0+c2l6ZSgpID49IHNpemVvZihncmFsbG9jTWV0YSkKKyAgICAgICAgICAgICAgICAgICAgICAgICYmIGdyYWxsb2NNZXRhLmVUeXBlID09IGtNZXRhZGF0YUJ1ZmZlclR5cGVHcmFsbG9jU291cmNlKSB7CisgICAgICAgICAgICAgICAgICAgIGhhbmRsZSA9IChuYXRpdmVfaGFuZGxlX3QgKilncmFsbG9jTWV0YS5wSGFuZGxlOworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5mby0+bURhdGEtPnNpemUoKSA+PSBzaXplb2YobmF0aXZlTWV0YSkKKyAgICAgICAgICAgICAgICAgICAgICAgICYmIG5hdGl2ZU1ldGEuZVR5cGUgPT0ga01ldGFkYXRhQnVmZmVyVHlwZUFOV0J1ZmZlcikgeworICAgICAgICAgICAgICAgICAgICBoYW5kbGUgPSAobmF0aXZlX2hhbmRsZV90ICopbmF0aXZlTWV0YS5wQnVmZmVyLT5oYW5kbGU7CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGluZm8tPm1EYXRhLT5tZXRhKCktPnNldFBvaW50ZXIoImhhbmRsZSIsIGhhbmRsZSk7CiAgICAgICAgICAgICAgICAgaW5mby0+bURhdGEtPm1ldGEoKS0+c2V0SW50MzIoInJhbmdlT2Zmc2V0IiwgcmFuZ2VPZmZzZXQpOwogICAgICAgICAgICAgICAgIGluZm8tPm1EYXRhLT5tZXRhKCktPnNldEludDMyKCJyYW5nZUxlbmd0aCIsIHJhbmdlTGVuZ3RoKTsKQEAgLTQ4NDEsMTQgKzUxNTAsMTcgQEAKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAKLSAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgewotICAgICAgICAgICAgQ0hFQ0tfRVEoKGludCltb2RlLCAoaW50KUZSRUVfQlVGRkVSUyk7Ci0KLSAgICAgICAgICAgIENIRUNLX0VRKChzdGF0dXNfdClPSywKLSAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+ZnJlZUJ1ZmZlcihrUG9ydEluZGV4T3V0cHV0LCBpbmRleCkpOworICAgICAgICBjYXNlIEZSRUVfQlVGRkVSUzoKKyAgICAgICAgICAgIGVyciA9IG1Db2RlYy0+ZnJlZUJ1ZmZlcihrUG9ydEluZGV4T3V0cHV0LCBpbmRleCk7CisgICAgICAgICAgICBpZiAoZXJyICE9IE9LKSB7CisgICAgICAgICAg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ID0gbUNvZGVjLT5tTmF0aXZlV2luZG93LT5xdWV1ZUJ1ZmZlcigKLSAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTmF0aXZlV2luZG93LmdldCgpLAotICAgICAgICAgICAgICAgICAgICBpbmZvLT5tR3JhcGhpY0J1ZmZlci5nZXQoKSwgLTEpKSA9PSBPSykgeworICAgICAgICBpbmZvLT5jaGVja1JlYWRGZW5jZSgib25PdXRwdXRCdWZmZXJEcmFpbmVkIGJlZm9yZSBxdWV1ZUJ1ZmZlciIpOworICAgICAgICBlcnIgPSBtQ29kZWMtPm1OYXRpdmVXaW5kb3ctPnF1ZXVlQnVmZmVyKAorICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1OYXRpdmVXaW5kb3cuZ2V0KCksIGluZm8tPm1HcmFwaGljQnVmZmVyLmdldCgpLCBpbmZvLT5tRmVuY2VGZCk7CisgICAgICAgIGluZm8tPm1GZW5jZUZkID0gLTE7CisgICAgICAgIGlmIChlcnIgPT0gT0spIHsKICAgICAgICAgICAgIGluZm8tPm1TdGF0dXMgPSBCdWZmZXJJbmZvOjpPV05FRF9CWV9OQVRJVkVfV0lORE9XOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgbUNvZGVjLT5zaWduYWxFcnJvcihPTVhfRXJyb3JVbmRlZmluZWQsIG1ha2VOb1NpZGVFZmZlY3RTdGF0dXMoZXJyKSk7CiAgICAgICAgICAgICBpbmZvLT5tU3RhdHVzID0gQnVmZmVySW5mbzo6T1dORURfQllfVVM7CisgICAgICAgICAgICAvLyBrZWVwaW5nIHJlYWQgZmVuY2UgYXMgd3JpdGUgZmVuY2UgdG8gYXZvaWQgY2xvYmJlcmluZworICAgICAgICAgICAgaW5mby0+bUlzUmVhZEZlbmNlID0gZmFsc2U7CiAgICAgICAgIH0KICAgICB9IGVsc2UgewogICAgICAgICBpZiAobUNvZGVjLT5tTmF0aXZlV2luZG93ICE9IE5VTEwgJiYKICAgICAgICAgICAgIChpbmZvLT5tRGF0YSA9PSBOVUxMIHx8IGluZm8tPm1EYXRhLT5zaXplKCkgIT0gMCkpIHsKKyAgICAgICAgICAgIC8vIG1vdmUgcmVhZCBmZW5jZSBpbnRvIHdyaXRlIGZlbmNlIHRvIGF2b2lkIGNsb2JiZXJpbmcKKyAgICAgICAgICAgIGluZm8tPm1Jc1JlYWRGZW5jZSA9IGZhbHNlOwogICAgICAgICAgICAgQVRSQUNFX05BTUUoImZyYW1lLWRyb3AiKTsKICAgICAgICAgfQogICAgICAgICBpbmZvLT5tU3RhdHVzID0gQnVmZmVySW5mbzo6T1dORURfQllfVVM7CkBAIC00OTQxLDI0ICs1MjY5LDMyIEBACiAgICAgICAgICAgICAgICAgaWYgKGluZm8gIT0gTlVMTCkgewogICAgICAgICAgICAgICAgICAgICBBTE9HVigiWyVzXSBjYWxsaW5nIGZpbGxCdWZmZXIgJXUiLAogICAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bUNvbXBvbmVudE5hbWUuY19zdHIoKSwgaW5mby0+bUJ1ZmZlcklEKTsKLQotICAgICAgICAgICAgICAgICAgICBDSEVDS19FUShtQ29kZWMtPm1PTVgtPmZpbGxCdWZmZXIobUNvZGVjLT5tTm9kZSwgaW5mby0+bUJ1ZmZlcklEKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHN0YXR1c190KU9LKTsKLQotICAgICAgICAgICAgICAgICAgICBpbmZvLT5tU3RhdHVzID0gQnVmZmVySW5mbzo6T1dORURfQllfQ09NUE9ORU5UOworICAgICAgICAgICAgICAgICAgICBpbmZvLT5jaGVja1dyaXRlRmVuY2UoIm9uT3V0cHV0QnVmZmVyRHJhaW5lZDo6UkVTVUJNSVRfQlVGRkVSUyIpOworICAgICAgICAgICAgICAgICAgICBzdGF0dXNfdCBlcnIgPSBtQ29kZWMtPm1PTVgtPmZpbGxCdWZmZXIoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTm9kZSwgaW5mby0+bUJ1ZmZlcklELCBpbmZvLT5tRmVuY2VGZCk7CisgICAgICAgICAgICAgICAgICAgIGluZm8tPm1GZW5jZUZkID0gLTE7CisgICAgICAgICAgICAgICAgICAgIGlmIChlcnIgPT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGluZm8tPm1TdGF0dXMgPSBCdWZmZXJJbmZvOjpPV05FRF9CWV9DT01QT05FTlQ7CisgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPnNpZ25hbEVycm9yKE9NWF9FcnJvclVuZGVmaW5lZCwgbWFrZU5vU2lkZUVmZmVjdFN0YXR1cyhlcnIpKTsKKyAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAKLSAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgY2FzZSBGUkVFX0JVRkZFUlM6CiAgICAgICAgIHsKLSAgICAgICAgICAgIENIRUNLX0VRKChpbnQpbW9kZSwgKGludClGUkVFX0JVRkZFUlMpOwotCi0gICAgICAgICAgICBDSEVDS19FUSgoc3RhdHVzX3QpT0ssCi0gICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPmZyZWVCdWZmZXIoa1BvcnRJbmRleE91dHB1dCwgaW5kZXgpKTsKKyAgICAgICAgICAgIHN0YXR1c190IGVyciA9IG1Db2RlYy0+ZnJlZUJ1ZmZlcihrUG9ydEluZGV4T3V0cHV0LCBpbmRleCk7CisgICAgICAgICAgICBpZiAoZXJyICE9IE9LKSB7CisgICAgICAgICAgICAgICAgbUNvZGVjLT5zaWduYWxFcnJvcihPTVhfRXJyb3JVbmRlZmluZWQsIG1ha2VOb1NpZGVFZmZlY3RTdGF0dXMoZXJyKSk7CisgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQorCisgICAgICAgIGRlZmF1bHQ6CisgICAgICA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y8vLy8vLy8vLy8vLy8vLy8KQEAgLTU1NDEsMTQgKzU4ODMsMjUgQEAKICAgICBzd2l0Y2ggKGV2ZW50KSB7CiAgICAgICAgIGNhc2UgT01YX0V2ZW50Q21kQ29tcGxldGU6CiAgICAgICAgIHsKLSAgICAgICAgICAgIENIRUNLX0VRKGRhdGExLCAoT01YX1UzMilPTVhfQ29tbWFuZFN0YXRlU2V0KTsKLSAgICAgICAgICAgIENIRUNLX0VRKGRhdGEyLCAoT01YX1UzMilPTVhfU3RhdGVJZGxlKTsKKyAgICAgICAgICAgIHN0YXR1c190IGVyciA9IE9LOworICAgICAgICAgICAgaWYgKGRhdGExICE9IChPTVhfVTMyKU9NWF9Db21tYW5kU3RhdGVTZXQKKyAgICAgICAgICAgICAgICAgICAgfHwgZGF0YTIgIT0gKE9NWF9VMzIpT01YX1N0YXRlSWRsZSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCJVbmV4cGVjdGVkIGNvbW1hbmQgY29tcGxldGlvbiBpbiBMb2FkZWRUb0lkbGVTdGF0ZTogJXMoJXUpICVzKCV1KSIsCisgICAgICAgICAgICAgICAgICAgICAgICBhc1N0cmluZygoT01YX0NPTU1BTkRUWVBFKWRhdGExKSwgZGF0YTEsCisgICAgICAgICAgICAgICAgICAgICAgICBhc1N0cmluZygoT01YX1NUQVRFVFlQRSlkYXRhMiksIGRhdGEyKTsKKyAgICAgICAgICAgICAgICBlcnIgPSBGQUlMRURfVFJBTlNBQ1RJT047CisgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIENIRUNLX0VRKG1Db2RlYy0+bU9NWC0+c2VuZENvbW1hbmQoCi0gICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1Ob2RlLCBPTVhfQ29tbWFuZFN0YXRlU2V0LCBPTVhfU3RhdGVFeGVjdXRpbmcpLAotICAgICAgICAgICAgICAgICAgICAgKHN0YXR1c190KU9LKTsKKyAgICAgICAgICAgIGlmIChlcnIgPT0gT0spIHsKKyAgICAg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GluZm8tPm1TdGF0dXMgPT0gQnVmZmVySW5mbzo6T1dORURfQllfTkFUSVZFX1dJTkRPVykgewogICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgQ0hFQ0tfRVEoKGludClpbmZvLT5tU3RhdHVzLCAoaW50KUJ1ZmZlckluZm86Ok9XTkVEX0JZX1VTKTsKKyAgICAgICAgICAgIGlmIChpbmZvLT5tU3RhdHVzICE9IEJ1ZmZlckluZm86Ok9XTkVEX0JZX1VTKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoImJ1ZmZlcnMgc2hvdWxkIGJlIG93bmVkIGJ5IHVzIik7CisgICAgICAgICAgICAgICAgZmFpbGVkID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KICAgICAgICAgfQogCi0gICAgICAgIEFMT0dWKCJbJXNdIGNhbGxpbmcgZmlsbEJ1ZmZlciAldSIsCi0gICAgICAgICAgICAgbUNvZGVjLT5tQ29tcG9uZW50TmFtZS5jX3N0cigpLCBpbmZvLT5tQnVmZmVySUQpOworICAgICAgICBBTE9HVigiWyVzXSBjYWxsaW5nIGZpbGxCdWZmZXIgJXUiLCBtQ29kZWMtPm1Db21wb25lbnROYW1lLmNfc3RyKCksIGluZm8tPm1CdWZmZXJJRCk7CiAKLSAgICAgICAgQ0hFQ0tfRVEobUNvZGVjLT5tT01YLT5maWxsQnVmZmVyKG1Db2RlYy0+bU5vZGUsIGluZm8tPm1CdWZmZXJJRCksCi0gICAgICAgICAgICAgICAgIChzdGF0dXNfdClPSyk7CisgICAgICAgIGluZm8tPmNoZWNrV3JpdGVGZW5jZSgic3VibWl0UmVndWxhck91dHB1dEJ1ZmZlcnMiKTsKKyAgICAgICAgc3RhdHVzX3QgZXJyID0gbUNvZGVjLT5tT01YLT5maWxsQnVmZmVyKG1Db2RlYy0+bU5vZGUsIGluZm8tPm1CdWZmZXJJRC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ICAgICAgIENIRUNLX0VRKG1Db2RlYy0+bU9NWC0+c2VuZENvbW1hbmQoCi0gICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1Ob2RlLCBPTVhfQ29tbWFuZFN0YXRlU2V0LCBPTVhfU3RhdGVJZGxlKSwKLSAgICAgICAgICAgICAgICAgICAgIChzdGF0dXNfdClPSyk7Ci0KLSAgICAgICAgICAgIG1Db2RlYy0+Y2hhbmdlU3RhdGUobUNvZGVjLT5tRXhlY3V0aW5nVG9JZGxlU3RhdGUpOworICAgICAgICAgICAgc3RhdHVzX3QgZXJyID0gbUNvZGVjLT5tT01YLT5zZW5kQ29tbWFuZCgKKyAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTm9kZSwgT01YX0NvbW1hbmRTdGF0ZVNldCwgT01YX1N0YXRlSWRsZSk7CisgICAgICAgICAgICBpZiAoZXJyICE9IE9LKSB7CisgICAgICAgICAgICAgICAgaWYgKGtlZXBDb21wb25lbnRBbGxvY2F0ZWQpIHsKKyAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5zaWduYWxFcnJvcihPTVhfRXJyb3JVbmRlZmluZWQsIEZBSUxFRF9UUkFOU0FDVElPTik7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIC8vIFRPRE86IGRvIHNvbWUgcmVjb3ZlcnkgaGVyZS4KKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgbUNvZGVjLT5jaGFuZ2VTdGF0ZShtQ29kZWMtPm1FeGVjdXRpbmdUb0lkbGVTdGF0ZSk7CisgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIGhhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgYnJlYWs7CkBAIC01NzQ5LDExICs2MTMyLDEzIEBACiAKICAgICAgICAgICAgIG1BY3RpdmUgPSBmYWxzZTsKIAotICAgICAgICAgICAgQ0hFQ0tfRVEobUNvZGVjLT5tT01YLT5zZW5kQ29tbWFuZCgKLSAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bU5vZGUsIE9NWF9Db21tYW5kRmx1c2gsIE9NWF9BTEwpLAotICAgICAgICAgICAgICAgICAgICAgKHN0YXR1c190KU9LKTsKKyAgICAgICAgICAgIHN0YXR1c190IGVyciA9IG1Db2RlYy0+bU9NWC0+c2VuZENvbW1hbmQobUNvZGVjLT5tTm9kZSwgT01YX0NvbW1hbmRGbHVzaCwgT01YX0FMTCk7CisgICAgICAgICAgICBpZiAoZXJyICE9IE9LKSB7CisgICAgICAgICAgICAgICAgbUNvZGVjLT5zaWduYWxFcnJvcihPTVhfRXJyb3JVbmRlZmluZWQsIEZBSUxFRF9UUkFOU0FDVElPTik7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIG1Db2RlYy0+Y2hhbmdlU3RhdGUobUNvZGVjLT5tRmx1c2hpbmdTdGF0ZSk7CisgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIG1Db2RlYy0+Y2hhbmdlU3RhdGUobUNvZGVjLT5tRmx1c2hpbmdTdGF0ZSk7CiAgICAgICAgICAgICBoYW5kbGVkID0gdHJ1ZTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CkBAIC01ODAyLDEzICs2MTg3LDEzIEBACiAgICAgICAgIH0KIAogICAgICAgICAvLyAqKiogTk9URTogVEhFIEZPTExPV0lORyBXT1JLQVJPVU5EIFdJTEwgQkUgUkVNT1ZFRCAqKioKLSAgICAgICAgY2FzZSBrV2hhdFN1Ym1pdE91dHB1dE1ldGFEYXRhQnVmZmVySWZFT1M6CisgICAgICAgIGNhc2Uga1doYXRTdWJtaXRPdXRwdXRNZXRhZGF0YUJ1ZmZlcklmRU9TOgogICAgICAgICB7CiAgICAgICAgICAgICBpZiAobUNvZGVjLT5tUG9ydEVPU1trUG9ydEluZGV4SW5wdXRdICYmCiAgICAgICAgICAgICAgICAgICAgICFtQ29kZWMtPm1Qb3J0RU9TW2tQb3J0SW5kZXhPdXRwdX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AgICBpZiAoZGF0YTIgPT0gMCB8fCBkYXRhMiA9PSBPTVhfSW5kZXhQYXJhbVBvcnREZWZpbml0aW9uKSB7Ci0gICAgICAgICAgICAgICAgbUNvZGVjLT5tTWV0YURhdGFCdWZmZXJzVG9TdWJtaXQgPSAwOworICAgICAgICAgICAgICAgIG1Db2RlYy0+bU1ldGFkYXRhQnVmZmVyc1RvU3VibWl0ID0gMDsKICAgICAgICAgICAgICAgICBDSEVDS19FUShtQ29kZWMtPm1PTVgtPnNlbmRDb21tYW5kKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bU5vZGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT01YX0NvbW1hbmRQb3J0RGlzYWJsZSwga1BvcnRJbmRleE91dHB1dCksCkBAIC01OTk4LDMxICs2Mzg4LDQ2IEBACiAgICAgICAgICBtQ29kZWMtPm1Db21wb25lbnROYW1lLmNfc3RyKCkpOwogfQogCitib29sIEFDb2RlYzo6T3V0cHV0UG9ydFNldHRpbmdzQ2hhbmdlZFN0YXRlOjpvbk9NWEZyYW1lUmVuZGVyZWQoCisgICAgICAgIGludDY0X3QgbWVkaWFUaW1lVXMsIG5zZWNzX3Qgc3lzdGVtTmFubykgeworICAgIG1Db2RlYy0+b25GcmFtZVJlbmRlcmVkKG1lZGlhVGltZVVzLCBzeXN0ZW1OYW5vKTsKKyAgICByZXR1cm4gdHJ1ZTsKK30KKwogYm9vbCBBQ29kZWM6Ok91dHB1dFBvcnRTZXR0aW5nc0NoYW5nZWRTdGF0ZTo6b25PTVhFdmVudCgKICAgICAgICAgT01YX0VWRU5UVFlQRSBldmVudCwgT01YX1UzMiBkYXRhMSwgT01YX1UzMiBkYXRhMikgewogICAgIHN3aXRjaCAoZXZlbnQpIHsKICAgICAgICAgY2FzZSBPTVhfRXZlbnRDbWRDb21wbGV0ZToKICAgICAgICAgewogICAgICAgICAgICAgaWYgKGRhdGExID09IChPTVhfVTMyKU9NWF9Db21tYW5kUG9ydERpc2FibGUpIHsKLSAgICAgICAgICAgICAgICBDSEVDS19FUShkYXRhMiwgKE9NWF9VMzIpa1BvcnRJbmRleE91dHB1dCk7CisgICAgICAgICAgICAgICAgaWYgKGRhdGEyICE9IChPTVhfVTMyKWtQb3J0SW5kZXhPdXRwdXQpIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR1coImlnbm9yaW5nIEV2ZW50Q21kQ29tcGxldGUgQ29tbWFuZFBvcnREaXNhYmxlIGZvciBwb3J0ICV1IiwgZGF0YTIpOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgQUxPR1YoIlslc10gT3V0cHV0IHBvcnQgbm93IGRpc2FibGVkLiIsCi0gICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1Db21wb25lbnROYW1lLmNfc3RyKCkpOworICAgICAgICAgICAgICAgIEFMT0dWKCJbJXNdIE91dHB1dCBwb3J0IG5vdyBkaXNhYmxlZC4iLCBtQ29kZWMtPm1Db21wb25lbnROYW1lLmNfc3RyKCkpOwogCi0gICAgICAgICAgICAgICAgQ0hFQ0sobUNvZGVjLT5tQnVmZmVyc1trUG9ydEluZGV4T3V0cHV0XS5pc0VtcHR5KCkpOwotICAgICAgICAgICAgICAgIG1Db2RlYy0+bURlYWxlcltrUG9ydEluZGV4T3V0cHV0XS5jbGVhcigpOworICAgICAgICAgICAgICAgIHN0YXR1c190IGVyciA9IE9LOworICAgICAgICAgICAgICAgIGlmICghbUNvZGVjLT5tQnVmZmVyc1trUG9ydEluZGV4T3V0cHV0XS5pc0VtcHR5KCkpIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoImRpc2FibGVkIHBvcnQgc2hvdWxkIGJlIGVtcHR5LCBidXQgaGFzICV6dSBidWZmZXJzIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1CdWZmZXJzW2tQb3J0SW5kZXhPdXRwdXRdLnNpemUoKSk7CisgICAgICAgICAgICAgICAgICAgIGVyciA9IEZBSUxFRF9UUkFOU0FDVElPTjsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1EZWFsZXJba1BvcnRJbmRleE91dHB1dF0uY2xlYXIoKTsKKyAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBDSEVDS19FUShtQ29kZWMtPm1PTVgtPnNlbmRDb21tYW5kKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bU5vZGUsIE9NWF9Db21tYW5kUG9ydEVuYWJsZSwga1BvcnRJbmRleE91dHB1dCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgKHN0YXR1c190KU9LKTsKKyAgICAgICAgICAgICAgICBpZiAoZXJyID09IE9LKSB7CisgICAgICAgICAgICAgICAgICAgIGVyciA9IG1Db2RlYy0+bU9NWC0+c2VuZENvbW1hbmQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTm9kZSwgT01YX0NvbW1hbmRQb3J0RW5hYmxlLCBrUG9ydEluZGV4T3V0cHV0KTsKKyAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBzdGF0dXNfdCBlcnI7Ci0gICAgICAgICAgICAgICAgaWYgKChlcnIgPSBtQ29kZWMtPmFsbG9jYXRlQnVmZmVyc09uUG9ydCgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga1BvcnRJbmRleE91dHB1dCkpICE9IE9LKSB7Ci0gICAgICAgICAgICAgICAgICAgIEFMT0dFKCJGYWlsZWQgdG8gYWxsb2NhdGUgb3V0cHV0IHBvcnQgYnVmZmVycyBhZnRlciAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgInBvcnQgcmVjb25maWd1cmF0aW9uIChlcnJvciAweCUwOHgpIiwKLSAgICAgICAgICAgICAgICAgICAgICAgICBlcnIpOworICAgICAgICAgICAgICAgIGlmIChlcnIgPT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgZXJyID0gbUNvZGVjLT5hbGxvY2F0ZUJ1ZmZlcnNPblBvcnQoa1BvcnRJbmRleE91dHB1dCk7CisgICAgICAgICAgICAgICAgICAgIEFMT0dFX0lGKGVyciAhPSBPSywgIkZhaWxlZCB0byBhbGxvY2F0ZSBvdXRwdXQgcG9ydCBidWZmZXJzIGFmdGVyIHBvcnQgIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICJyZWNvbmZpZ3VyYXRpb246ICglZCkiLCBlcnIpOworICAgICAgICAgICAgICAgIH0KIAorICAgICAgICAgICAgICAgIGlmIChlcnIgIT0gT0spIHsKICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5zaWduYWxFcnJvcihPTVhfRXJyb3JVbmRlZmluZWQsIG1ha2VOb1NpZGVFZmZlY3RTdGF0dXMoZXJyKSk7CiAKICAgICAgICAgICAgICAgICAgICAgLy8gVGhpcyBpcyB0ZWNobmljYWxseSBub3QgY29ycmVjdCwgYnV0IGFwcGVhcnMgdG8gYmUKQEAgLTYwMzcsMTIgKzY0NDIsMTQgQEAKIAogICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgfSBlbHNlIGlmIChkYXRhMSA9PSAoT01YX1UzMilPTVhfQ29tbWFuZFBvcnRFbmFibGUpIHsKLSAgICAgICAgICAgICAgICBDSEVDS19FUShkYXRhMiwgKE9NWF9VMzIpa1BvcnRJbmRleE91dHB1dCk7CisgICAgICAgICAgICAgICAgaWYgKGRhdGEyICE9IChPTVhfVTMyKWtQb3J0SW5kZXhPdXRwdXQpIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR1coImlnbm9yaW5nIEV2ZW50Q21kQ29tcGxldGUgT01YX0NvbW1hbmRQb3J0RW5hYmxlIGZvciBwb3J0ICV1IiwgZGF0YTIpOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgbUNvZGVjLT5tU2VudEZvcm1hdCA9IGZhbHNlOwogCi0gICAgICAgICAgICAgICAgQUxPR1YoIlslc10gT3V0cHV0IHBvcnQgbm93IHJlZW5hYmxlZC4iLAotICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tQ29tcG9uZW50TmFtZS5jX3N0cigpKTsKKyAgICAgICAgICAgICAgICBBTE9HVigiWyVzXSBPdXRwdXQgcG9ydCBub3cgcmVlbmFibGVkLiIsIG1Db2RlYy0+bUNvbXBvbmVudE5hbWUuY19zdHIoKSk7CiAKICAgICAgICAgICAgICAgICBpZiAobUNvZGVjLT5tRXhlY3V0aW5nU3RhdGUtPmFjdGl2ZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bUV4ZWN1dGluZ1N0YXRlLT5zdWJtaXRPdXRwdXRCdWZmZXJzKCk7CkBAIC02MDc2LDcgKzY0ODMsNyBAQAogICAgICAgICB7CiAgICAgICAgICAgICAvLyBEb24ndCBzZW5kIG1lIGEgZmx1c2ggcmVxdWVzdCBpZiB5b3UgcHJldmlvdXNseSB3YW50ZWQgbWUKICAgICAgICAgICAgIC8vIHRvIHNodXRkb3duLgotICAgICAgICAgICAgVFJFU1BBU1MoKTsKKyAgICAgICAgICAgIEFMT0dXKCJJZ25vcmluZyBmbHVzaCByZXF1ZXN0IGluIEV4ZWN1dGluZ1RvSWRsZVN0YXRlIik7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogCkBAIC02MTA4LDggKzY1MTUsMTQgQEAKICAgICBzd2l0Y2ggKGV2ZW50KSB7CiAgICAgICAgIGNhc2UgT01YX0V2ZW50Q21kQ29tcGxldGU6CiAgICAgICAgIHsKLSAgICAgICAgICAgIENIRUNLX0VRKGRhdGExLCAoT01YX1UzMilPTVhfQ29tbWFuZFN0YXRlU2V0KTsKLSAgICAgICAgICAgIENIRUNLX0VRKGRhdGEyLCAoT01YX1UzMilPTVhfU3RhdGVJZGxlKTsKKyAgICAgICAgICAgIGlmIChkYXRhMSAhPSAoT01YX1UzMilPTVhfQ29tbWFuZFN0YXRlU2V0CisgICAgICAgICAgICAgICAgICAgIHx8IGRhdGEyICE9IChPTVhfVTMyKU9NWF9TdGF0ZUlkbGUpIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiVW5leHBlY3RlZCBjb21tYW5kIGNvbXBsZXRpb24gaW4gRXhlY3V0aW5nVG9JZGxlU3RhdGU6ICVzKCV1KSAlcygldSkiLAorICAgICAgICAgICAgICAgICAgICAgICAgYXNTdHJpbmcoKE9NWF9DT01NQU5EVFlQRSlkYXRhMSksIGRhdGExLAorICAgICAgICAgICAgICAgICAgICAgICAgYXNTdHJpbmcoKE9NWF9TVEFURVRZUEUpZGF0YTIpLCBkYXRhMik7CisgICAgICAgICAgICAgICAgbUNvZGVjLT5zaWduYWxFcnJvcihPTVhfRXJyb3JVbmRlZmluZWQsIEZBSUxFRF9UUkFOU0FDVElPTik7CisgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIG1Db21wb25lbnROb3dJZGxlID0gdHJ1ZTsKIApAQCAtNjEzMiwxMiArNjU0NSwxNSBAQAogCiB2b2lkIEFDb2RlYzo6RXhlY3V0aW5nVG9JZGxlU3RhdGU6OmNoYW5nZVN0YXRlSWZXZU93bkFsbEJ1ZmZlcnMoKSB7CiAgICAgaWYgKG1Db21wb25lbnROb3dJZGxlICYmIG1Db2RlYy0+YWxsWW91ckJ1ZmZlcnNBcmVCZWxvbmdUb1VzKCkpIHsKLSAgICAgICAgQ0hFQ0tfRVEobUNvZGVjLT5tT01YLT5zZW5kQ29tbWFuZCgKLSAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tTm9kZSwgT01YX0NvbW1hbmRTdGF0ZVNldCwgT01YX1N0YXRlTG9hZGVkKSwKLSAgICAgICAgICAgICAgICAgKHN0YXR1c190KU9LKTsKLQotICAgICAgICBDSEVDS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sgb2Ygc2Nhbm5pbmcgb3V0IG9uZSBvZiB0aG9zZSBidWZmZXJzLgotICAgICAgICAgICAgbUNvZGVjLT5wdXNoQmxhbmtCdWZmZXJzVG9OYXRpdmVXaW5kb3coKTsKKyAgICAgICAgICAgIHB1c2hCbGFua0J1ZmZlcnNUb05hdGl2ZVdpbmRvdyhtQ29kZWMtPm1OYXRpdmVXaW5kb3cuZ2V0KCkpOworICAgICAgICB9CisKKyAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgbUNvZGVjLT5zaWduYWxFcnJvcihPTVhfRXJyb3JVbmRlZmluZWQsIEZBSUxFRF9UUkFOU0FDVElPTik7CisgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KIAogICAgICAgICBtQ29kZWMtPmNoYW5nZVN0YXRlKG1Db2RlYy0+bUlkbGVUb0xvYWRlZFN0YXRlKTsKQEAgLTYxODgsNyArNjYwOSw3IEBACiAgICAgICAgIHsKICAgICAgICAgICAgIC8vIERvbid0IHNlbmQgbWUgYSBmbHVzaCByZXF1ZXN0IGlmIHlvdSBwcmV2aW91c2x5IHdhbnRlZCBtZQogICAgICAgICAgICAgLy8gdG8gc2h1dGRvd24uCi0gICAgICAgICAgICBUUkVTUEFTUygpOworICAgICAgICAgICAgQUxPR0UoIkdvdCBmbHVzaCByZXF1ZXN0IGluIElkbGVUb0xvYWRlZFN0YXRlIik7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogCkBAIC02MjA5LDggKzY2MzAsMTQgQEAKICAgICBzd2l0Y2ggKGV2ZW50KSB7CiAgICAgICAgIGNhc2UgT01YX0V2ZW50Q21kQ29tcGxldGU6CiAgICAgICAgIHsKLSAgICAgICAgICAgIENIRUNLX0VRKGRhdGExLCAoT01YX1UzMilPTVhfQ29tbWFuZFN0YXRlU2V0KTsKLSAgICAgICAgICAgIENIRUNLX0VRKGRhdGEyLCAoT01YX1UzMilPTVhfU3RhdGVMb2FkZWQpOworICAgICAgICAgICAgaWYgKGRhdGExICE9IChPTVhfVTMyKU9NWF9Db21tYW5kU3RhdGVTZXQKKyAgICAgICAgICAgICAgICAgICAgfHwgZGF0YTIgIT0gKE9NWF9VMzIpT01YX1N0YXRlTG9hZGVkKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIlVuZXhwZWN0ZWQgY29tbWFuZCBjb21wbGV0aW9uIGluIElkbGVUb0xvYWRlZFN0YXRlOiAlcygldSkgJXMoJXUpIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIGFzU3RyaW5nKChPTVhfQ09NTUFORFRZUEUpZGF0YTEpLCBkYXRhMSwKKyAgICAgICAgICAgICAgICAgICAgICAgIGFzU3RyaW5nKChPTVhfU1RBVEVUWVBFKWRhdGEyKSwgZGF0YTIpOworICAgICAgICAgICAgICAgIG1Db2RlYy0+c2lnbmFsRXJyb3IoT01YX0Vycm9yVW5kZWZpbmVkLCBGQUlMRURfVFJBTlNBQ1RJT04pOworICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOworICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBtQ29kZWMtPmNoYW5nZVN0YXRlKG1Db2RlYy0+bUxvYWRlZFN0YXRlKTsKIApAQCAtNjI2NywyMiArNjY5NCwzNSBAQAogICAgIHN3aXRjaCAoZXZlbnQpIHsKICAgICAgICAgY2FzZSBPTVhfRXZlbnRDbWRDb21wbGV0ZToKICAgICAgICAgewotICAgICAgICAgICAgQ0hFQ0tfRVEoZGF0YTEsIChPTVhfVTMyKU9NWF9Db21tYW5kRmx1c2gpOworICAgICAgICAgICAgaWYgKGRhdGExICE9IChPTVhfVTMyKU9NWF9Db21tYW5kRmx1c2gpIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgidW5leHBlY3RlZCBFdmVudENtZENvbXBsZXRlICVzKCVkKSBkYXRhMjolZCBpbiBGbHVzaGluZ1N0YXRlIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIGFzU3RyaW5nKChPTVhfQ09NTUFORFRZUEUpZGF0YTEpLCBkYXRhMSwgZGF0YTIpOworICAgICAgICAgICAgICAgIG1Db2RlYy0+c2lnbmFsRXJyb3IoT01YX0Vycm9yVW5kZWZpbmVkLCBGQUlMRURfVFJBTlNBQ1RJT04pOworICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOworICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBpZiAoZGF0YTIgPT0ga1BvcnRJbmRleElucHV0IHx8IGRhdGEyID09IGtQb3J0SW5kZXhPdXRwdXQpIHsKLSAgICAgICAgICAgICAgICBDSEVDSyghbUZsdXNoQ29tcGxldGVbZGF0YTJdKTsKKyAgICAgICAgICAgICAgICBpZiAobUZsdXNoQ29tcGxldGVbZGF0YTJdKSB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dXKCJGbHVzaCBhbHJlYWR5IGNvbXBsZXRlZCBmb3IgJXMgcG9ydCIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTIgPT0ga1BvcnRJbmRleElucHV0ID8gImlucHV0IiA6ICJvdXRwdXQiKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIG1GbHVzaENvbXBsZXRlW2RhdGEyXSA9IHRydWU7CiAKLSAgICAgICAgICAgICAgICBpZiAobUZsdXNoQ29tcGxldGVba1BvcnRJbmRleElucHV0XQotICAgICAgICAgICAgICAgICAgICAgICAgJiYgbUZsdXNoQ29tcGxldGVba1BvcnRJbmRleE91dHB1dF0pIHsKKyAgICAgICAgICAgICAgICBpZiAobUZsdXNoQ29tcGxldGVba1BvcnRJbmRleElucHV0XSAmJiBtRmx1c2hDb21wbGV0ZVtrUG9ydEluZGV4T3V0cHV0XSkgewogICAgICAgICAgICAgICAgICAgICBjaGFuZ2VTdGF0ZUlmV2VPd25BbGxCdWZmZXJzKCk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBDSEVDS19FUShkYXRhMiwgT01YX0FMTCk7Ci0gICAgICAgICAgICAgICAgQ0hFQ0sobUZsdXNoQ29tcGxldGVba1BvcnRJbmRleElucHV0XSk7Ci0gICAgICAgICAgICAgICAgQ0hFQ0sobUZsdXNoQ29tcGxldGVba1BvcnRJbmRleE91dHB1dF0pOworICAgICAgICAgICAgfSBlbHNlIGlmIChkYXRhMiA9PSBPTVhfQUxMKSB7CisgICAgICAgICAgICAgICAgaWYgKCFtRmx1c2hDb21wbGV0ZVtrUG9ydEluZGV4SW5wdXRdIHx8ICFtRmx1c2hDb21wbGV0ZVtrUG9ydEluZGV4T3V0cHV0XSkgeworICAgICAgICAgICAgICAgICAgICBBTE9HVygicmVjZWl2ZWQgZmx1c2ggY29tcGxldGUgZXZlbnQgZm9yIE9NWF9BTEwgYmVmb3JlIHBvcnRzIGhhdmUgYmVlbiIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZmx1c2hlZCAoJWQvJWQpIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtRmx1c2hDb21wbGV0ZVtrUG9ydEluZGV4SW5wdXRdLCBtRmx1c2hDb21wbGV0ZVtrUG9ydEluZGV4T3V0cHV0XSk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICBjaGFuZ2VTdGF0ZUlmV2VPd25BbGxCdWZmZXJzKCk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIEFMT0dXKCJkYXRhMiBub3QgT01YX0FMTCBidXQgJXUgaW4gRXZlbnRDbWRDb21wbGV0ZSBDb21tYW5kRmx1c2giLCBkYXRhMik7CiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIHJldHVybiB0cnVlOwpAQCAtNjMzMiw2ICs2NzcyLDggQEAKICAgICAgICAgLy8gdGhlIG5hdGl2ZSB3aW5kb3cgZm9yIHJlbmRlcmluZy4gTGV0J3MgZ2V0IHR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sNyBAQAogICAgICAgICBTdGFnZWZyaWdodE1lZGlhU2Nhbm5lci5jcHAgICAgICAgXAogICAgICAgICBTdGFnZWZyaWdodE1ldGFkYXRhUmV0cmlldmVyLmNwcCAgXAogICAgICAgICBTdXJmYWNlTWVkaWFTb3VyY2UuY3BwICAgICAgICAgICAgXAorICAgICAgICBTdXJmYWNlVXRpbHMuY3BwICAgICAgICAgICAgICAgICAgXAogICAgICAgICBUaHJvdHRsZWRTb3VyY2UuY3BwICAgICAgICAgICAgICAgXAogICAgICAgICBUaW1lU291cmNlLmNwcCAgICAgICAgICAgICAgICAgICAgXAogICAgICAgICBUaW1lZEV2ZW50UXVldWUuY3BwICAgICAgICAgICAgICAgXApAQCAtODksNiArOTEsNyBAQAogICAgICAgICBsaWJpY3V1YyBcCiAgICAgICAgIGxpYmxvZyBcCiAgICAgICAgIGxpYm1lZGlhIFwKKyAgICAgICAgbGlibWVkaWF1dGlscyBcCiAgICAgICAgIGxpYm5ldGRfY2xpZW50IFwKICAgICAgICAgbGlib3B1cyBcCiAgICAgICAgIGxpYnNvbml2b3ggXApAQCAtMTIzLDcgKzEyNiw5IEBACiAgICAgICAgIGxpYmRsIFwKICAgICAgICAgbGliUlNjcHAgXAogCi1MT0NBTF9DRkxBR1MgKz0gLVduby1tdWx0aWNoYXIgLVdlcnJvciAtV2FsbAorTE9DQUxfQ0ZMQUdTICs9IC1Xbm8tbXVsdGljaGFyIC1XZXJyb3IgLVduby1lcnJvcj1kZXByZWNhdGVkLWRlY2xhcmF0aW9ucyAtV2FsbCBcCisgICAgICAgIC1ERU5BQkxFX1NUQUdFRlJJR0hUX0VYUEVSSU1FTlRTCisKIExPQ0FMX0NMQU5HIDo9IHRydWUKIAogTE9DQUxfTU9EVUxFOj0gbGlic3RhZ2VmcmlnaHQKZGlmZiAtLWdpdCBhL21lZGlhL2xpYnN0YWdlZnJpZ2h0L0F1ZGlvU291cmNlLmNwcCBiL21lZGlhL2xpYnN0YWdlZnJpZ2h0L0F1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GRhdGEgbGVuZ3RoIGluc2lkZSAiqXh5eiIgYm94Ci0gICAgICAgICAgICAvLyB3b3VsZCBiZSA4LCBmb3IgaW5zdGFuY2UgIql4eXoiICsgIlx4MDBceDA0XHgxNVx4YzciICsgIjArMC8iLAorICAgICAgICAgICAgLy8gQmVzdCBjYXNlIHRoZSB0b3RhbCBkYXRhIGxlbmd0aCBpbnNpZGUgIlx4QTl4eXoiIGJveAorICAgICAgICAgICAgLy8gd291bGQgYmUgOCwgZm9yIGluc3RhbmNlICJceEE5eHl6IiArICJceDAwXHgwNFx4MTVceGM3IiArICIwKzAvIiwKICAgICAgICAgICAgIC8vIHdoZXJlICJceDAwXHgwNCIgaXMgdGhlIHRleHQgc3RyaW5nIGxlbmd0aCB3aXRoIHZhbHVlID0gNCwKICAgICAgICAgICAgIC8vICJcMHgxNVx4YzciIGlzIHRoZSBsYW5ndWFnZSBjb2RlID0gZW4sIGFuZCAiMCswIiBpcyBhCiAgICAgICAgICAgICAvLyBsb2NhdGlvbiAoc3RyaW5nKSB2YWx1ZSB3aXRoIGxvbmdpdHVkZSA9IDAgYW5kIGxhdGl0dWRlID0gMC4KQEAgLTE5OTIsNiArMTk5MiwxMCBAQAogICAgICAgICAgICAgICAgIHNpemUgPSAwOwogICAgICAgICAgICAgfQogCisgICAgICAgICAgICBpZiAoU0laRV9NQVggLSBjaHVua19zaXplIDw9IHNpemUpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gRVJST1JfTUFMRk9STUVEOworICAgICAgICAgICAgfQorCiAgICAgICAgICAgICB1aW50OF90ICpidWZmZXIgPSBuZXcgKHN0ZDo6bm90aHJvdykgdWludDhfdFtzaXplICsgY2h1bmtfc2l6ZV07CiAgICAgICAgICAgICBpZiAoYnVmZmVyID09IE5VTEwpIHsKICAgICAgICAgICAgICAgICByZXR1cm4gRVJST1JfTUFMRk9STUVEOwpAQCAtMjAyNSwxNCArMjAyOSwyMiBAQAogICAgICAgICAgICAgKm9mZnNldCArPSBjaHVua19zaXplOwogCiAgICAgICAgICAgICBpZiAobUZpbGVNZXRhRGF0YSAhPSBOVUxMKSB7Ci0gICAgICAgICAgICAgICAgQUxPR1YoImNodW5rX2RhdGFfc2l6ZSA9ICVsbGQgYW5kIGRhdGFfb2Zmc2V0ID0gJWxsZCIsCi0gICAgICAgICAgICAgICAgICAgICAgICAobG9uZyBsb25nKWNodW5rX2RhdGFfc2l6ZSwgKGxvbmcgbG9uZylkYXRhX29mZnNldCk7CisgICAgICAgICAgICAgICAgQUxPR1YoImNodW5rX2RhdGFfc2l6ZSA9ICUiIFBSSWQ2NCAiIGFuZCBkYXRhX29mZnNldCA9ICUiIFBSSWQ2NCwKKyAgICAgICAgICAgICAgICAgICAgICBjaHVua19kYXRhX3NpemUsIGRhdGFfb2Zmc2V0KTsKKworICAgICAgICAgICAgICAgIGlmIChjaHVua19kYXRhX3NpemUgPCAwIHx8IHN0YXRpY19jYXN0PHVpbnQ2NF90PihjaHVua19kYXRhX3NpemUpID49IFNJWkVfTUFYIC0gMSkgeworICAgICAgICAgICAgICAgICAgICByZXR1cm4gRVJST1JfTUFMRk9STUVEOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBzcDxBQnVmZmVyPiBidWZmZXIgPSBuZXcgQUJ1ZmZlcihjaHVua19kYXRhX3NpemUgKyAxKTsKICAgICAgICAgICAgICAgICBpZiAobURhdGFTb3VyY2UtPnJlYWRBdCgKICAgICAgICAgICAgICAgICAgICAgZGF0YV9vZmZzZXQsIGJ1ZmZlci0+ZGF0YSgpLCBjaHVua19kYXRhX3NpemUpICE9IChzc2l6ZV90KWNodW5rX2RhdGFfc2l6ZSkgewogICAgICAgICAgICAgICAgICAgICByZXR1cm4gRVJST1JfSU87CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGNvbnN0IGludCBrU2tpcEJ5dGVzT2ZEYXRhQm94ID0gMTY7CisgICAgICAgICAgICAgICAgaWYgKGNodW5rX2RhdGFfc2l6ZSA8PSBr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IDA7CiAgICAgICAgICAgICAgICAgaWYgKCFpc01hbEZvcm1lZCkgewogICAgICAgICAgICAgICAgICAgICBuYWxMZW5ndGggPSBwYXJzZU5BTFNpemUoJm1TcmNCdWZmZXJbc3JjT2Zmc2V0XSk7CiAgICAgICAgICAgICAgICAgICAgIHNyY09mZnNldCArPSBtTkFMTGVuZ3RoU2l6ZTsKLSAgICAgICAgICAgICAgICAgICAgaXNNYWxGb3JtZWQgPSBzcmNPZmZzZXQgKyBuYWxMZW5ndGggPiBzaXplOworICAgICAgICAgICAgICAgICAgICBpc01hbEZvcm1lZCA9ICFpc0luUmFuZ2UoKHNpemVfdCkwdSwgc2l6ZSwgc3JjT2Zmc2V0LCBuYWxMZW5ndGgpOwogICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgIGlmIChpc01hbEZvcm1lZCkgewpAQCAtNDM5MiwxMiArNDQxNywxMiBAQAogICAgICAgICAgICAgc2l6ZV90IGRzdE9mZnNldCA9IDA7CiAKICAgICAgICAgICAgIHdoaWxlIChzcmNPZmZzZXQgPCBzaXplKSB7Ci0gICAgICAgICAgICAgICAgYm9vbCBpc01hbEZvcm1lZCA9IChzcmNPZmZzZXQgKyBtTkFMTGVuZ3RoU2l6ZSA+IHNpemUpOworICAgICAgICAgICAgICAgIGJvb2wgaXNNYWxGb3JtZWQgPSAhaXNJblJhbmdlKChzaXplX3QpMHUsIHNpemUsIHNyY09mZnNldCwgbU5BTExlbmd0aFNpemUpOwogICAgICAgICAgICAgICAgIHNpemVfdCBuYWxMZW5ndGggPSAwOwogICAgICAgICAgICAgICAgIGlmICghaXNNYWxGb3JtZWQpIHsKICAgICAgICAgICAgICAgICAgICAgbmFsTGVuZ3RoID0gcGFyc2VOQUxTaXplKCZtU3JjQnVmZmVyW3NyY09mZnNldF0pOwogICAgICAgICAgICAgICAgICAgICBzcmNPZmZzZXQgKz0gbU5BTExlbmd0aFNpemU7Ci0gICAgICAgICAgICAgICAgICAgIGlzTWFsRm9ybW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PdXRwdXRGb3JtYXRDaGFuZ2VkKSB7Ci0gICAgICAgIHJlc3BvbnNlLT5zZXRJbnQzMigiZXJyIiwgSU5GT19GT1JNQVRfQ0hBTkdFRCk7CisgICAgICAgIFBvc3RSZXBseVdpdGhFcnJvcihyZXBseUlELCBJTkZPX0ZPUk1BVF9DSEFOR0VEKTsKICAgICAgICAgbUZsYWdzICY9IH5rRmxhZ091dHB1dEZvcm1hdENoYW5nZWQ7CiAgICAgfSBlbHNlIHsKKyAgICAgICAgc3A8QU1lc3NhZ2U+IHJlc3BvbnNlID0gbmV3IEFNZXNzYWdlOwogICAgICAgICBzc2l6ZV90IGluZGV4ID0gZGVxdWV1ZVBvcnRCdWZmZXIoa1BvcnRJbmRleE91dHB1dCk7CiAKICAgICAgICAgaWYgKGluZGV4IDwgMCkgewpAQCAtMTA1NiwxMCArOTgyLDkgQEAKICAgICAgICAgfQogCiAgICAgICAgIHJlc3BvbnNlLT5zZXRJbnQzMigiZmxhZ3MiLCBmbGFncyk7CisgICAgICAgIHJlc3BvbnNlLT5wb3N0UmVwbHkocmVwbHlJRCk7CiAgICAgfQogCi0gICAgcmVzcG9uc2UtPnBvc3RSZXBseShyZXBseUlEKTsKLQogICAgIHJldHVybiB0cnVlOwogfQogCkBAIC0xMjczLDcgKzExOTgsNyBAQAogCiAgICAgICAgICAgICAgICAgY2FzZSBDb2RlY0Jhc2U6OmtXaGF0SW5wdXRTdXJmYWNlQWNjZXB0ZWQ6CiAgICAgICAgICAgICAgICAgewotICAgICAgICAgICAgICAgICAgICAvLyByZXNwb25zZSB0byBpbml0aWF0ZVVzZVBlcnNpc3RlbnRJbnB1dFN1cmZhY2UoKQorICAgICAgICAgICAgICAgICAgICAvLyByZXNwb25zZSB0byBpbml0aWF0ZVNldElucHV0U3VyZmFjZSgpCiAgICAgICAgICAgICAgICAgICAgIHN0YXR1c190IGVyciA9IE5PX0VSUk9SOwogICAgICAgICAgICAgICAgICAgICBzcDxBTWVzc2FnZT4gcmVzcG9uc2UgPSBuZXcgQU1lc3NhZ2UoKTsKICAgICAgICAgICAgICAgICAgICAgaWYgKCFtc2ctPmZpbmRJbnQzMigiZXJyIiwgJmVycikpIHsKQEAgLTE0MTQsNiArMTMzOSwxOCBAQAogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAKKyAgICAgICAgICAgICAgICBjYXNlIENvZGVjQmFzZTo6a1doYXRPdXRwdXRGcmFtZXNSZW5kZXJlZDoKKyAgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICAgIC8vIGlnbm9yZSB0aGVzZSBpbiBhbGwgc3RhdGVzIGV4Y2VwdCBydW5uaW5nLCBhbmQgY2hlY2sgdGhhdCB3ZSBoYXZlIGEKKyAgICAgICAgICAgICAgICAgICAgLy8gbm90aWZpY2F0aW9uIHNldAorICAgICAgICAgICAgICAgICAgICBpZiAobVN0YXRlID09IFNUQVJURUQgJiYgbU9uRnJhbWVSZW5kZXJlZE5vdGlmaWNhdGlvbiAhPSBOVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBzcDxBTWVzc2FnZT4gbm90aWZ5ID0gbU9uRnJhbWVSZW5kZXJlZE5vdGlmaWNhdGlvbi0+ZHVwKCk7CisgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldE1lc3NhZ2UoImRhdGEiLCBtc2cpOworICAgICAgICAgICAgICAgICAgICAgICAgbm90aWZ5LT5wb3N0KCk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorCiAgICAgICAgICAgICAgICAgY2FzZSBDb2RlY0Jhc2U6OmtXaGF0RmlsbFRoaXNCdWZmZXI6CiAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAvKiBzaXplX3QgaW5kZXggPSAqL3VwZGF0ZUJ1ZmZlcnMoa1BvcnRJbmRleElucHV0LCBtc2cpOwpAQCAtMTYxMSw2ICsxNTQ4LDE1IEBACiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogCisgICAgICAgIGNhc2Uga1doYXRTZXROb3RpZmljYXRpb246CisgICAgICAgIHsKKyAgICAgICAgICAgIHNwPEFNZXNzYWdlPiBub3RpZnk7CisgICAgICAgICAgICBpZiAobXNnLT5maW5kTWVzc2FnZSgib24tZnJhbWUtcmVuZGVyZWQiLCAmbm90aWZ5KSkgeworICAgICAgICAgICAgICAgIG1PbkZyYW1lUmVuZGVyZWROb3RpZmljYXRpb24gPSBub3RpZnk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorCiAgICAgICAgIGNhc2Uga1doYXRTZXRDYWxsYmFjazoKICAgICAgICAgewogICAgICAgICAgICAgc3A8QVJlcGx5VG9rZW4+IHJlcGx5SUQ7CkBAIC0xNjU5LDYgKzE2MDUsMTEgQEAKICAgICAgICAgICAgIHNwPEFNZXNzYWdlPiBmb3JtYXQ7CiAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRNZXNzYWdlKCJmb3JtYXQiLCAmZm9ybWF0KSk7CiAKKyAgICAgICAgICAgIGludDMyX3QgcHVzaDsKKyAgICAgICAgICAgIGlmIChtc2ctPmZpbmRJbnQzMigicHVzaC1ibGFuay1idWZmZXJzLW9uLXNodXRkb3duIiwgJnB1c2gpICYmIHB1c2ggIT0gMCkgeworICAgICAgICAgICAgICAgIG1GbGFncyB8PSBrRmxhZ1B1c2hCbGFua0J1ZmZlcnNPblNodXRkb3duOworICAgICAgICAgICAgfQorCiAgICAgICAgICAgICBpZiAob2JqICE9IE5VTEwpIHsKICAgICAgICAgICAgICAgICBmb3JtYXQtPnNldE9iamVjdCgibmF0aXZlLXdpbmRvdyIsIG9iaik7CiAgICAgICAgICAgICAgICAgc3RhdHVzX3QgZXJyID0gaGFuZGxlU2V0U3VyZmFjZShzdGF0aWNfY2FzdDxTdXJmYWNlICo+KG9iai5nZXQoKSkpOwpAQCAtMTcyNSw2ICsxNjc2LDEwIEBACiAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIgPT0gT0spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1GbGFncyAmIGtGbGFnVXNlc1NvZnR3YXJlUmVuZGVyZXIpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtU29mdFJlbmRlcmVyICE9IE5VTEwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgKG1GbGFncyAmIGtGbGFnUHVzaEJsYW5rQnVmZmVyc09uU2h1dGRvd24pKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHVzaEJsYW5rQnVmZmVyc1RvTmF0aXZlV2luZG93KG1TdXJmYWNlLmdldCgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Tb2Z0UmVuZGVyZXIgPSBuZXcgU29mdHdhcmVSZW5kZXJlcihzdXJmYWNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRPRE86IGNoZWNrIGlmIHRoaXMgd2FzIHN1Y2Nlc3NmdWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTE3NTAsNyArMTcwNSw3IEBACiAgICAgICAgIH0KIAogICAgICAgICBjYXNlIGtXaGF0Q3JlYXRlSW5wdXRTdXJmYWNlOgotICAgICAgICBjYXNlIGtXaGF0VXNlUGVyc2lzdGVudElucHV0U3VyZmFjZToKKyAgICAgICAgY2FzZSBrV2hhdFNldElucHV0U3VyZmFjZToKICAgICAgICAgewogICAgICAgICAgICAgc3A8QVJlcGx5VG9rZW4+IHJlcGx5SUQ7CiAgICAgICAgICAgICBDSEVDSyhtc2ctPnNlbmRlckF3YWl0c1Jlc3BvbnNlKCZyZXBseUlEKSk7CkBAIC0xNzY4LDcgKzE3MjMsNyBAQAogICAgICAgICAgICAgICAgIHNwPFJlZkJhc2U+IG9iajsKICAgICAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRPYmplY3QoImlucHV0LXN1cmZhY2UiLCAmb2JqKSk7CiAKLSAgICAgICAgICAgICAgICBtQ29kZWMtPmluaXRpYXRlVXNlUGVyc2lzdGVudElucHV0U3VyZmFjZSgKKyAgICAgICAgICAgICAgICBtQ29kZWMtPmluaXRpYXRlU2V0SW5wdXRTdXJmYWNlKAogICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8UGVyc2lzdGVudFN1cmZhY2UgKj4ob2JqLmdldCgpKSk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKQEAgLTE4MDgsNiArMTc2MywyMCBAQAogICAgICAgICAgICAgc3A8QVJlcGx5VG9rZW4+IHJlcGx5SUQ7CiAgICAgICAgICAgICBDSEVDSyhtc2ctPnNlbmRlckF3YWl0c1Jlc3BvbnNlKCZyZXBseUlEKSk7CiAKKyAgICAgICAgICAgIC8vIGFscmVhZHkgc3RvcHBlZC9yZWxlYXNlZAorICAgICAgICAgICAgaWYgKG1TdGF0ZSA9PSBVTklOSVRJQUxJWkVEICYmIG1SZWxlYXNlZEJ5UmVzb3VyY2VNYW5hZ2VyKSB7CisgICAgICAgICAgICAgICAgc3A8QU1lc3NhZ2U+IHJlc3BvbnNlID0gbmV3IEFNZXNzYWdlOworICAgICAgICAgICAgICAgIHJlc3BvbnNlLT5zZXRJbnQzMigiZXJyIiwgT0spOworICAgICAgICAgICAgICAgIHJlc3BvbnNlLT5wb3N0UmVwbHkocmVwbHlJRCk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIGludDMyX3QgcmVjbGFpbWVkID0gMDsKKyAgICAgICAgICAgIG1zZy0+ZmluZEludDMyKCJyZWNsYWltZWQiLCAmcmVjbGFpbWVkKTsKKyAgICAgICAgICAgIGlmIChyZWNsYWltZWQpIHsKKyAgICAgICAgICAgICAgICBtUmVsZWFzZWRCeVJlc291cmNlTWFuYWdlciA9IHRydWU7CisgICAgICAgICAgICB9CisKICAgICAgICAgICAgIGlmICghKChtRmxhZ3MgJiBrRmxhZ0lzQ29tcG9uZW50QWxsb2NhdGVkKSAmJiB0YXJnZXRTdGF0ZSA9PSBVTklOSVRJQUxJWkVEKSAvLyBTZWUgMQogICAgICAgICAgICAgICAgICAgICAmJiBtU3RhdGUgIT0gSU5JVElBTElaRUQKICAgICAgICAgICAgICAgICAgICAgJiYgbVN0YXRlICE9IENPTkZJR1VSRUQgJiYgIWlzRXhlY3V0aW5nKCkpIHsKQEAgLTE4MjEsNiArMTc5MCw4IEBACiAgICAgICAgICAgICAgICAgLy8gYW5kIGl0IHNob3VsZCBiZSBpbiB0aGlzIGNhc2UsIG5vIGhhcm0gdG8gYWxsb3cgYSByZWxlYXNlKCkKICAgICAgICAgICAgICAgICAvLyBpZiB3ZSdyZSBhbHJlYWR5IHVuaW5pdGlhbGl6ZWQuCiAgICAgICAgICAgICAgICAgc3A8QU1lc3NhZ2U+IHJlc3BvbnNlID0gbmV3IEFNZXNzYWdlOworICAgICAgICAgICAgICAgIC8vIFRPRE86IHdlIHNob3VsZG4ndCB0aHJvdyBhbiBleGNlcHRpb24gZm9yIHN0b3AvcmVsZWFzZS4gQ2hhbmdlIHRoaXMgdG8gd2FpdCB1bnRpbAorICAgICAgICAgICAgICAgIC8vIHRoZSBwcmV2aW91cyBzdG9wL3JlbGVhc2UgY29tcGxldGVzIGFuZCB0aGVuIHJlcGx5IHdpdGggT0suCiAgICAgICAgICAgICAgICAgc3RhdHVzX3QgZXJyID0gbVN0YXRlID09IHRhcmdldFN0YXRlID8gT0sgOiBJTlZBTElEX09QRVJBVElPTjsKICAgICAgICAgICAgICAgICByZXNwb25zZS0+c2V0SW50MzIoImVyciIsIGVycik7CiAgICAgICAgICAgICAgICAgaWYgKGVyciA9PSBPSyAmJiB0YXJnZXRTdGF0ZSA9PSBVTklOSVRJQUxJWkVEKSB7CkBAIC0xODQ4LDYgKzE4MTksMTAgQEAKICAgICAgICAgICAgICAgICAgICAgbXNnLT53aGF0KCkgPT0ga1doYXRTdG9wIC8qIGtlZXBDb21wb25lbnRBbGxvY2F0ZWQgKi8pOwogCiAgICAgICAgICAgICByZXR1cm5CdWZmZXJzVG9Db2RlYygpOworCisgICAgICAgICAgICBpZiAobVNvZnRSZW5kZXJlciAhPSBOVUxMICYmIChtRmxhZ3MgJiBrRmxhZ1B1c2hCbGFua0J1ZmZlcnNPblNodXRkb3duKSkgeworICAgICAgICAgICAgICAgIHB1c2hCbGFua0J1ZmZlcnNUb05hdGl2ZVdpbmRvdyhtU3VyZmFjZS5nZXQoKSk7CisgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogCkBAIC0yNDI0LDYgKzIzOTksMjMgQEAKICAgICByZXR1cm4gT0s7CiB9CiAKKy8vc3RhdGljCitzaXplX3QgTWVkaWFDb2RlYzo6Q3JlYXRlRnJhbWVzUmVuZGVyZWRNZXNzYWdlKAorICAgICAgICBzdGQ6Omxpc3Q8RnJhbWVSZW5kZXJUcmFja2VyOjpJbmZvPiBkb25lLCBzcDxBTWVzc2FnZT4gJm1zZykgeworICAgIHNpemVfdCBpbmRleCA9IDA7CisKKyAgICBmb3IgKHN0ZDo6bGlzdDxGcmFtZVJlbmRlclRyYWNrZXI6OkluZm8+Ojpjb25zdF9pdGVyYXRvciBpdCA9IGRvbmUuY2JlZ2luKCk7CisgICAgICAgICAgICBpdCAhPSBkb25lLmNlbmQoKTsgKytpdCkgeworICAgICAgICBpZiAoaXQtPmdldFJlbmRlclRpbWVOcygpIDwgMCkgeworICAgICAgICAgICAgY29udGludWU7IC8vIGRyb3BwZWQgZnJhbWUgZnJvbSB0cmFja2luZworICAgICAgICB9CisgICAgICAgIG1zZy0+c2V0SW50NjQoQVN0cmluZ1ByaW50ZigiJXp1LW1lZGlhLXRpbWUtdXMiLCBpbmRleCkuY19zdHIoKSwgaXQtPmdldE1lZGlhVGltZVVzKCkpOworICAgICAgICBtc2ctPnNldEludDY0KEFTdHJpbmdQcmludGYoIiV6dS1zeXN0ZW0tbmFubyIsIGluZGV4KS5jX3N0cigpLCBpdC0+Z2V0UmVuZGVyVGltZU5zKCkpOworICAgICAgICArK2luZGV4OworICAgIH0KKyAgICByZXR1cm4gaW5kZXg7Cit9CisKIHN0YXR1c190IE1lZGlhQ29kZWM6Om9uUmVsZWFzZU91dHB1dEJ1ZmZlcihjb25zdCBzcDxBTWVzc2FnZT4gJm1zZykgewogICAgIHNpemVfdCBpbmRleDsKICAgICBDSEVDSyhtc2ctPmZpbmRTaXplKCJpbmRleCIsICZpbmRleCkpOwpAQCAtMjQ1NiwyNiArMjQ0OCwzNyBAQAogICAgIGlmIChyZW5kZXIgJiYgaW5mby0+bURhdGEgIT0gTlVMTCAmJiBpbmZvLT5tRGF0YS0+c2l6ZSgpICE9IDApIHsKICAgICAgICAgaW5mby0+bU5vdGlmeS0+c2V0SW50MzIoInJlbmRlciIsIHRydWUpOwogCi0gICAgICAgIGludDY0X3QgdGltZXN0YW1wTnMgPSAwOwotICAgICAgICBpZiAobXNnLT5maW5kSW50NjQoInRpbWVzdGFtcE5zIiwgJnRpbWVzdGFtcE5zKSkgewotICAgICAgICAgICAgaW5mby0+bU5vdGlmeS0+c2V0SW50NjQoInRpbWVzdGFtcE5zIiwgdGltZXN0YW1wTnMpOworICAgICAgICBpbnQ2NF90IG1lZGlhVGltZVVzID0gLTE7CisgICAgICAgIGluZm8tPm1EYXRhLT5tZXRhKCktPmZpbmRJbnQ2NCgidGltZVVzIiwgJm1lZGlhVGltZVVzKTsKKworICAgICAgICBpbnQ2NF90IHJlbmRlclRpbWVOcyA9IDA7CisgICAgICAgIGlmIChtc2ctPmZpbmRJbnQ2NCgidGltZXN0YW1wTnMiLC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c3QgPT0gTlVMTCkgeworICAgICAgICBNZWRpYUNvZGVjTGlzdCAqY29kZWNMaXN0ID0gbmV3IE1lZGlhQ29kZWNMaXN0OworICAgICAgICBpZiAoY29kZWNMaXN0LT5pbml0Q2hlY2soKSA9PSBPSykgeworICAgICAgICAgICAgc0NvZGVjTGlzdCA9IGNvZGVjTGlzdDsKKworICAgICAgICAgICAgaWYgKGlzUHJvZmlsaW5nTmVlZGVkKCkpIHsKKyAgICAgICAgICAgICAgICBBTE9HVigiQ29kZWMgcHJvZmlsaW5nIG5lZWRlZCwgd2lsbCBiZSBydW4gaW4gc2VwYXJhdGVkIHRocmVhZC4iKTsKKyAgICAgICAgICAgICAgICBwdGhyZWFkX3QgcHJvZmlsZXI7CisgICAgICAgICAgICAgICAgaWYgKHB0aHJlYWRfY3JlYXRlKCZwcm9maWxlciwgTlVMTCwgcHJvZmlsZXJUaHJlYWRXcmFwcGVyLCBOVUxMKSAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dXKCJGYWlsZWQgdG8gY3JlYXRlIHRocmVhZCBmb3IgY29kZWMgcHJvZmlsaW5nLiIpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgLy8gZmFpbHVyZSB0byBpbml0aWFsaXplIG1heSBiZSB0ZW1wb3JhcnkuIHJldHJ5IG9uIG5leHQgY2FsbC4KLSAgICAgICAgICAgICAgICBkZWxldGUgZ0NvZGVjTGlzdDsKLSAgICAgICAgICAgICAgICBnQ29kZWNMaXN0ID0gTlVMTDsKICAgICAgICAgICAgIH0KKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIC8vIGZhaWx1cmUgdG8gaW5pdGlhbGl6ZSBtYXkgYmUgdGVtcG9yYXJ5LiByZXRyeSBvbiBuZXh0IGNhbGwuCisgICAgICAgICAgICBkZWxldGUgY29kZWNMaXN0OwogICAgICAgICB9CiAgICAgfQogCi0gICAgaWYgKHByb2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4gKnJlc3VsdHMsCisgICAgICAgIENvZGVjU2V0dGluZ3MgKmdsb2JhbF9yZXN1bHRzLAorICAgICAgICBLZXllZFZlY3RvcjxBU3RyaW5nLCBDb2RlY1NldHRpbmdzPiAqZW5jb2Rlcl9yZXN1bHRzLAorICAgICAgICBLZXllZFZlY3RvcjxBU3RyaW5nLCBDb2RlY1NldHRpbmdzPiAqZGVjb2Rlcl9yZXN1bHRzLAogICAgICAgICBib29sIGZvcmNlVG9NZWFzdXJlKSB7CiAgICAgS2V5ZWRWZWN0b3I8QVN0cmluZywgc3A8TWVkaWFDb2RlY0luZm86OkNhcGFiaWxpdGllcz4+IGNvZGVjc05lZWRNZWFzdXJlOworICAgIEFTdHJpbmcgc3VwcG9ydE11bHRpcGxlU2VjdXJlQ29kZWNzID0gInRydWUiOworICAgIHNpemVfdCBtYXhFbmNvZGVySW5wdXRCdWZmZXJzID0gMDsKICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IGluZm9zLnNpemUoKTsgKytpKSB7CiAgICAgICAgIGNvbnN0IHNwPE1lZGlhQ29kZWNJbmZvPiBpbmZvID0gaW5mb3NbaV07CiAgICAgICAgIEFTdHJpbmcgbmFtZSA9IGluZm8tPmdldENvZGVjTmFtZSgpOwpAQCAtMjQwLDE1NyArMzA1LDEwNyBAQAogICAgICAgICAgICAgICAgIEFTdHJpbmcga2V5ID0gbmFtZTsKICAgICAgICAgICAgICAgICBrZXkuYXBwZW5kKCIgIik7CiAgICAgICAgICAgICAgICAga2V5LmFwcGVuZChtaW1lc1tpXSk7Ci0gICAgICAgICAgICAgICAga2V5LmFwcGVuZCgiICIpOwotICAgICAgICAgICAgICAgIGtleS5hcHBlbmQoaW5mby0+aXNFbmNvZGVyKCkgPyAiZW5jb2RlciIgOiAiZGVjb2RlciIpOwotICAgICAgICAgICAgICAgIHJlc3VsdHMtPmFkZChrZXksIHNldHRpbmdzKTsKKworICAgICAgICAgICAgICAgIGlmIChpbmZvLT5pc0VuY29kZXIoKSkgeworICAgICAgICAgICAgICAgICAgICBlbmNvZGVyX3Jlc3VsdHMtPmFkZChrZXksIHNldHRpbmdzKTsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBkZWNvZGVyX3Jlc3VsdHMtPmFkZChrZXksIHNldHRpbmdzKTsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBpZiAobmFtZS5lbmRzV2l0aCgiLnNlY3VyZSIpKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChtYXggPD0gMSkgeworICAgICAgICAgICAgICAgICAgICAgICAgc3VwcG9ydE11bHRpcGxlU2VjdXJlQ29kZWNzID0gImZhbHNlIjsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAoaW5mby0+aXNFbmNvZGVyKCkgJiYgbWltZXNbaV0uc3RhcnRzV2l0aCgidmlkZW8vIikpIHsKKyAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGVuY29kZXJJbnB1dEJ1ZmZlcnMgPQorICAgICAgICAgICAgICAgICAgICAgICAgZG9Qcm9maWxlRW5jb2RlcklucHV0QnVmZmVycyhuYW1lLCBtaW1lc1tpXSwgY2Fwcyk7CisgICAgICAgICAgICAgICAgICAgIGlmIChlbmNvZGVySW5wdXRCdWZmZXJzID4gbWF4RW5jb2RlcklucHV0QnVmZmVycykgeworICAgICAgICAgICAgICAgICAgICAgICAgbWF4RW5jb2RlcklucHV0QnVmZmVycyA9IGVuY29kZXJJbnB1dEJ1ZmZlcnM7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CisgICAgaWYgKG1heEVuY29kZXJJbnB1dEJ1ZmZlcnMgPiAwKSB7CisgICAgICAgIGNoYXIgdG1wWzMyXTsKKyAgICAgICAgc3ByaW50Zih0bXAsICIlenUiLCBtYXhFbmNvZGVySW5w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ICAgICAgY29udGludWU7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjb25zdCBzcDxNZWRpYUNvZGVjSW5mbzo6Q2FwYWJpbGl0aWVzPiAmY2FwcyA9IGluZm8tPmdldENhcGFiaWxpdGllc0ZvcihtaW1lLmNfc3RyKCkpOwotICAgICAgICAgICAgZm9yIChzaXplX3QgayA9IDA7IGsgPCBzZXR0aW5ncy5zaXplKCk7ICsraykgewotICAgICAgICAgICAgICAgIGNhcHMtPmdldERldGFpbHMoKS0+c2V0U3RyaW5nKAotICAgICAgICAgICAgICAgICAgICAgICAgc2V0dGluZ3Mua2V5QXQoaykuY19zdHIoKSwgc2V0dGluZ3MudmFsdWVBdChrKS5jX3N0cigpKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgIH0KLX0KLQotdm9pZCBleHBvcnRSZXN1bHRzVG9YTUwoY29uc3QgY2hhciAqZmlsZU5hbWUsIGNvbnN0IEtleWVkVmVjdG9yPEFTdHJpbmcsIENvZGVjU2V0dGluZ3M+JiByZXN1bHRzKSB7Ci0jaWYgTE9HX05ERUJVRyA9PSAwCi0gICAgQUxPR0UoIm1lYXN1cmVtZW50IHJlc3VsdHMiKTsKK3N0YXRpYyBBU3RyaW5nIGdsb2JhbFJlc3VsdHNUb1htbChjb25zdCBDb2RlY1NldHRpbmdzJiByZXN1bHRzKSB7CisgICAgQVN0cmluZyByZXQ7CiAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCByZXN1bHRzLnNpemUoKTsgKytpKSB7Ci0gICAgICAgIEFMT0dFKCJrZXkgJXMiLCByZXN1bHRzLmtleUF0KGkpLmNfc3RyKCkpOwotICAgICAgICBjb25zdCBDb2RlY1NldHRpbmdzICZzZXR0aW5ncyA9IHJlc3VsdHMudmFsdWVBdChpKTsKLSAgICAgICAgZm9yIChzaXplX3QgaiA9IDA7IGogPCBzZXR0aW5ncy5zaXplKCk7ICsraikgewotICAgICAgICAgICAgQUxPR0UoIm5hbWUgJXMgdmFsdWUgJXMiLCBzZXR0aW5ncy5rZXlBdChqKS5jX3N0cigpLCBzZXR0aW5ncy52YWx1ZUF0KGopLmNfc3RyKCkpOwotICAgICAgICB9CisgICAgICAgIEFTdHJpbmcgc2V0dGluZyA9IEFTdHJpbmdQcmludGYoCisgICAgICAgICAgICAgICAgIiAgICAgICAgPFNldHRpbmcgbmFtZT1cIiVzXCIgdmFsdWU9XCIlc1wiIC8+XG4iLAorICAgICAgICAgICAgICAgIHJlc3VsdHMua2V5QXQoaSkuY19zdHIoKSwKKyAgICAgICAgICAgICAgICByZXN1bHRzLnZhbHVlQXQoaSkuY19zdHIoKSk7CisgICAgICAgIHJldC5hcHBlbmQoc2V0dGluZyk7CiAgICAgfQotI2VuZGlmCisgICAgcmV0dXJuIHJldDsKK30KIAotICAgIEFTdHJpbmcgb3ZlcnJpZGVzOwotICAgIEZJTEUgKmYgPSBmb3BlbihmaWxlTmFtZSwgInJiIik7Ci0gICAgaWYgKGYgIT0gTlVMTCkgewotICAgICAgICBmc2VlayhmLCAwLCBTRUVLX0VORCk7Ci0gICAgICAgIGxvbmcgc2l6ZSA9IGZ0ZWxsKGYpOwotICAgICAgICByZXdpbmQoZik7Ci0KLSAgICAgICAgY2hhciAqYnVmID0gKGNoYXIgKiltYWxsb2Moc2l6ZSk7Ci0gICAgICAgIGlmIChmcmVhZChidWYsIHNpemUsIDEsIGYpID09IDEpIHsKLSAgICAgICAgICAgIG92ZXJyaWRlcy5zZXRUbyhidWYsIHNpemUpOwotICAgICAgICAgICAgaWYgKCFMT0dfTkRFQlVHKSB7Ci0gICAgICAgICAgICAgICAgQUxPR1YoIkV4aXN0aW5nIG92ZXJyaWRlczoiKTsKLSAgICAgICAgICAgICAgICBwcmludExvbmdTdHJpbmcoYnVmLCBzaXplKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIEFMT0dFKCJGYWlsZWQgdG8gcmVhZCAlcyIsIGZpbGVOYW1lKT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FbmNvZGVycz4iIDogIjxEZWNvZGVycz4iOwotICAgICAgICAgICAgQVN0cmluZyBlbmNvZGVyc0RlY29kZXJzRW5kID0gKHR5cGUgPT0gImVuY29kZXIiKSA/ICI8L0VuY29kZXJzPiIgOiAiPC9EZWNvZGVycz4iOwotICAgICAgICAgICAgc3NpemVfdCBwb3NFbmNvZGVyc0RlY29kZXJzID0gb3ZlcnJpZGVzLmZpbmQoZW5jb2RlcnNEZWNvZGVycy5jX3N0cigpKTsKLSAgICAgICAgICAgIGlmIChwb3NFbmNvZGVyc0RlY29kZXJzIDwgMCkgewotICAgICAgICAgICAgICAgIEFTdHJpbmcgbWVkaWFDb2RlY3MgPSAiPE1lZGlhQ29kZWNzPiI7Ci0gICAgICAgICAgICAgICAgc3NpemVfdCBwb3NNZWRpYUNvZGVjID0gb3ZlcnJpZGVzLmZpbmQobWVkaWFDb2RlY3MuY19zdHIoKSk7Ci0gICAgICAgICAgICAgICAgaWYgKHBvc01lZGlhQ29kZWMgPCAwKSB7Ci0gICAgICAgICAgICAgICAgICAgIHBvc01lZGlhQ29kZWMgPSBvdmVycmlkZXMuc2l6ZSgpOwotICAgICAgICAgICAgICAgICAgICBvdmVycmlkZXMuaW5zZXJ0KCJcbjxNZWRpYUNvZGVjcz5cbjwvTWVkaWFDb2RlY3M+XG4iLCBwb3NNZWRpYUNvZGVjKTsKLSAgICAgICAgICAgICAgICAgICAgcG9zTWVkaWFDb2RlYyA9IG92ZXJyaWRlcy5maW5kKG1lZGlhQ29kZWNzLmNfc3RyKCksIHBvc01lZGlhQ29kZWMpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBwb3NFbmNvZGVyc0RlY29kZXJzID0gcG9zTWVkaWFDb2RlYyArIG1lZGlhQ29kZWNzLnNpemUoKTsKLSAgICAgICAgICAgICAgICBBU3RyaW5nIGNvZGVjcyA9IEFTdHJpbmdQcmludGYoCi0gICAgICAgICAgICAgICAgICAgICAgICAiXG4gICAgJXNcbiAgIC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wiJXNcIiB1cGRhdGU9XCJ0cnVlXCIgPlxuIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUuY19zdHIoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbWUuY19zdHIoKSk7CisgICAgICAgIHJldC5hcHBlbmQoY29kZWMpOwogICAgICAgICBDb2RlY1NldHRpbmdzIHNldHRpbmdzID0gcmVzdWx0cy52YWx1ZUF0KGkpOwogICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IHNldHRpbmdzLnNpemUoKTsgKytpKSB7CiAgICAgICAgICAgICAvLyBXQVJOSU5HOiB3ZSBhc3N1bWUgYWxsIHRoZSBzZXR0aW5ncyBhcmUgIkxpbWl0Ii4gQ3VycmVudGx5IHdlIGhhdmUgb25seSBvbmUgdHlwZQogICAgICAgICAgICAgLy8gb2Ygc2V0dGluZyBpbiB0aGlzIGNhc2UsIHdoaWNoIGlzICJtYXgtc3VwcG9ydGVkLWluc3RhbmNlcyIuCi0gICAgICAgICAgICBBU3RyaW5nIHN0ckluc2VydCA9IEFTdHJpbmdQcmludGYoCi0gICAgICAgICAgICAgICAgICAgICJcbiAgICAgICAgICAgIDxMaW1pdCBuYW1lPVwiJXNcIiB2YWx1ZT1cIiVzXCIgLz4iLAorICAgICAgICAgICAgQVN0cmluZyBzZXR0aW5nID0gQVN0cmluZ1ByaW50ZigKKyAgICAgICAgICAgICAgICAgICAgIiAgICAgICAgICAgIDxMaW1pdCBuYW1lPVwiJXNcIiB2YWx1ZT1cIiVzXCIgLz5cbiIsCiAgICAgICAgICAgICAgICAgICAgIHNldHRpbmdzLmtleUF0KGkpLmNfc3RyKCksCiAgICAgICAgICAgICAgICAgICAgIHNldHRpbmdzLnZhbHVlQXQoaSkuY19zdHIoKSk7Ci0gICAgICAgICAgICBvdmVycmlkZXMuaW5zZXJ0KHN0ckluc2VydCwgcG9zSW5zZXJ0KTsKKyAgICAgICAgICAgIHJldC5hcHBlbmQoc2V0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YXBpX2Nvbm5lY3QobU5hdGl2ZVdpbmRvdy5nZXQoKSwKLSAgICAgICAgICAgIE5BVElWRV9XSU5ET1dfQVBJX0NQVSk7Ci0gICAgaWYgKGVyciAhPSBOT19FUlJPUikgewotICAgICAgICBBTE9HRSgiZXJyb3IgcHVzaGluZyBibGFuayBmcmFtZXM6IGFwaV9jb25uZWN0IGZhaWxlZDogJXMgKCVkKSIsCi0gICAgICAgICAgICAgICAgc3RyZXJyb3IoLWVyciksIC1lcnIpOwotICAgICAgICByZXR1cm4gZXJyOwotICAgIH0KLQotICAgIGVyciA9IG5hdGl2ZV93aW5kb3dfc2V0X2J1ZmZlcnNfZGltZW5zaW9ucyhtTmF0aXZlV2luZG93LmdldCgpLCAxLCAxKTsKLSAgICBpZiAoZXJyICE9IE5PX0VSUk9SKSB7Ci0gICAgICAgIEFMT0dFKCJlcnJvciBwdXNoaW5nIGJsYW5rIGZyYW1lczogc2V0X2J1ZmZlcnNfZGltZW5zaW9ucyBmYWlsZWQ6ICVzICglZCkiLAotICAgICAgICAgICAgICAgIHN0cmVycm9yKC1lcnIpLCAtZXJyKTsKLSAgICAgICAgZ290byBlcnJvcjsKLSAgICB9Ci0KLSAgICBlcnIgPSBuYXRpdmVfd2luZG93X3NldF9idWZmZXJzX2Zvcm1hdChtTmF0aXZlV2luZG93LmdldCgpLCBIQUxfUElYRUxfRk9STUFUX1JHQlhfODg4OCk7Ci0gICAgaWYgKGVyciAhPSBOT19FUlJPUikgewotICAgICAgICBBTE9HRSgiZXJyb3IgcHVzaGluZyBibGFuayBmcmFtZXM6IHNldF9idWZmZXJzX2Zvcm1hdCBmYWlsZWQ6ICVzICglZCkiLAotICAgICAgICAgICAgICAgIHN0cmVycm9yKC1lcnIpLCAtZXJyKTsKLSAgICAgICAgZ290byBlcnJvcjsKLSAgICB9Ci0KLSAgICBlcnIgPSBuYXRpdmVfd2luZG93X3NldF91c2FnZShtTmF0aXZlV2luZG93LmdldCgpLAotICAgICAgICAgICAgR1J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gLWVycik7Ci0gICAgICAgICAgICBnb3RvIGVycm9yOwotICAgICAgICB9Ci0KLSAgICAgICAgc3A8R3JhcGhpY0J1ZmZlcj4gYnVmKG5ldyBHcmFwaGljQnVmZmVyKGFuYiwgZmFsc2UpKTsKLQotICAgICAgICAvLyBGaWxsIHRoZSBidWZmZXIgd2l0aCB0aGUgYSAxeDEgY2hlY2tlcmJvYXJkIHBhdHRlcm4gOykKLSAgICAgICAgdWludDMyX3QqIGltZyA9IE5VTEw7Ci0gICAgICAgIGVyciA9IGJ1Zi0+bG9jayhHUkFMTE9DX1VTQUdFX1NXX1dSSVRFX09GVEVOLCAodm9pZCoqKSgmaW1nKSk7Ci0gICAgICAgIGlmIChlcnIgIT0gTk9fRVJST1IpIHsKLSAgICAgICAgICAgIEFMT0dFKCJlcnJvciBwdXNoaW5nIGJsYW5rIGZyYW1lczogbG9jayBmYWlsZWQ6ICVzICglZCkiLAotICAgICAgICAgICAgICAgICAgICBzdHJlcnJvcigtZXJyKSwgLWVycik7Ci0gICAgICAgICAgICBnb3RvIGVycm9yOwotICAgICAgICB9Ci0KLSAgICAgICAgKmltZyA9IDA7Ci0KLSAgICAgICAgZXJyID0gYnVmLT51bmxvY2soKTsKLSAgICAgICAgaWYgKGVyciAhPSBOT19FUlJPUikgewotICAgICAgICAgICAgQUxPR0UoImVycm9yIHB1c2hpbmcgYmxhbmsgZnJhbWVzOiB1bmxvY2sgZmFpbGVkOiAlcyAoJWQpIiwKLSAgICAgICAgICAgICAgICAgICAgc3RyZXJyb3IoLWVyciksIC1lcnIpOwotICAgICAgICAgICAgZ290byBlcnJvcjsKLSAgICAgICAgfQotCi0gICAgICAgIGVyciA9IG1OYXRpdmVXaW5kb3ctPnF1ZXVlQnVmZmVyKG1OYXRpdmVXaW5kb3cuZ2V0KCksCi0gICAgICAgICAgICAgICAgYnVmLT5nZXROYXRpdmVCdWZmZXIoKSwgLTEpOwotICAgICAgICBpZiAoZXJyICE9IE5PX0VSUk9SKSB7Ci0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BpX2Rpc2Nvbm5lY3QgZmFpbGVkOiAlcyAoJWQpIiwKLSAgICAgICAgICAgICAgICAgICAgc3RyZXJyb3IoLWVyciksIC1lcnIpOwotICAgICAgICAgICAgcmV0dXJuIGVycjsKLSAgICAgICAgfQotCi0gICAgICAgIGVyciA9IG5hdGl2ZV93aW5kb3dfYXBpX2Nvbm5lY3QobU5hdGl2ZVdpbmRvdy5nZXQoKSwKLSAgICAgICAgICAgICAgICBOQVRJVkVfV0lORE9XX0FQSV9NRURJQSk7Ci0gICAgICAgIGlmIChlcnIgIT0gTk9fRVJST1IpIHsKLSAgICAgICAgICAgIEFMT0dFKCJlcnJvciBwdXNoaW5nIGJsYW5rIGZyYW1lczogYXBpX2Nvbm5lY3QgZmFpbGVkOiAlcyAoJWQpIiwKLSAgICAgICAgICAgICAgICAgICAgc3RyZXJyb3IoLWVyciksIC1lcnIpOwotICAgICAgICAgICAgcmV0dXJuIGVycjsKLSAgICAgICAgfQotCi0gICAgICAgIHJldHVybiBOT19FUlJPUjsKLSAgICB9Ci19Ci0KIGludDY0X3QgT01YQ29kZWM6OmdldERlY29kaW5nVGltZVVzKCkgewogICAgIENIRUNLKG1Jc0VuY29kZXIgJiYgbUlzVmlkZW8pOwogCkBAIC0yNzg0LDcgKzI1NzUsNyBAQAogICAgICAgICAgICAgICAgICAgICAvLyB0aGVtIGhhcyBtYWRlIGl0IHRvIHRoZSBkaXNwbGF5LiAgVGhpcyBhbGxvd3MgdGhlIE9NWAogICAgICAgICAgICAgICAgICAgICAvLyBjb21wb25lbnQgdGVhcmRvd24gdG8gemVybyBvdXQgYW55IHByb3RlY3RlZCBidWZmZXJzCiAgICAgICAgICAgICAgICAgICAgIC8vIHdpdGhvdXQgdGhlIHJpc2sgb2Ygc2Nhbm5pbmcgb3V0IG9uZSBvZiB0aG9zZSBidWZmZXJzLgotICAgICAgICAgICAgICAgICAgICBwdXNoQmxhbmtCdWZmZXJzVG9OYXRpdmVXaW5kb3coKTsKKyAgICAgICAg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xldGUgc2FtcGxlKSBvZiB0aGUgZmlyc3QgcGFnZS4gVGhpcyBoYXBwZW5zCisgICAgICAgIC8vIHRoZSBmaXJzdCB0aW1lIGJlZm9yZSB3ZSBhdHRlbXB0IHRvIHJlYWQgYSBwYWNrZXQgZnJvbSB0aGUgZmlyc3QgcGFnZS4KKyAgICAgICAgTWVkaWFCdWZmZXIgKm1CdWY7CisgICAgICAgIHVpbnQzMl90IG51bVNhbXBsZXMgPSAwOworICAgICAgICB1aW50NjRfdCBjdXJHcmFudWxlUG9zaXRpb24gPSAwOworICAgICAgICB3aGlsZSAodHJ1ZSkgeworICAgICAgICAgICAgc3RhdHVzX3QgZXJyID0gX3JlYWROZXh0UGFja2V0KCZtQnVmLCAvKiBjYWxjVm9yYmlzVGltZXN0YW1wID0gKi9mYWxzZSk7CisgICAgICAgICAgICBpZiAoZXJyICE9IE9LICYmIGVyciAhPSBFUlJPUl9FTkRfT0ZfU1RSRUFNKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIC8vIEZpcnN0IHR3byBwYWdlcyBhcmUgaGVhZGVyIHBhZ2VzLgorICAgICAgICAgICAgaWYgKGVyciA9PSBFUlJPUl9FTkRfT0ZfU1RSRUFNIHx8IG1DdXJyZW50UGFnZS5tUGFnZU5vID4gMikgeworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorICAgICAgICAgICAgY3VyR3JhbnVsZVBvc2l0aW9uID0gbUN1cnJlbnRQYWdlLm1HcmFudWxlUG9zaXRpb247CisgICAgICAgICAgICBudW1TYW1wbGVzICs9IGdldE51bVNhbXBsZXNJblBhY2tldChtQnVmKTsKKyAgICAgICAgICAgIG1CdWYtPnJlbGVhc2UoKTsKKyAgICAgICAgICAgIG1CdWYgPSBOVUxMOworICAgICAgICB9CisKKyAgICAgICAgaWYgKGN1ckdyYW51bGVQb3NpdGlvbiA+IG51bVNhbXBsZXMpIHsKKyAgIC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JhbnVsZVBvc2l0aW9uIC0gY3VycmVudFBhZ2VTYW1wbGVzOworICAgIH0KKworICAgIGludDY0X3QgdGltZVVzID0gZ2V0VGltZVVzT2ZHcmFudWxlKG1DdXJHcmFudWxlUG9zaXRpb24pOworICAgICgqb3V0KS0+bWV0YV9kYXRhKCktPnNldEludDY0KGtLZXlUaW1lLCB0aW1lVXMpOworCisgICAgdWludDMyX3QgZnJhbWVzID0gZ2V0TnVtU2FtcGxlc0luUGFja2V0KCpvdXQpOworICAgIG1DdXJHcmFudWxlUG9zaXRpb24gKz0gZnJhbWVzOworICAgIHJldHVybiBPSzsKK30KKwordWludDMyX3QgTXlPcHVzRXh0cmFjdG9yOjpnZXROdW1TYW1wbGVzSW5QYWNrZXQoTWVkaWFCdWZmZXIgKmJ1ZmZlcikgY29uc3QgeworICAgIGlmIChidWZmZXIgPT0gTlVMTCB8fCBidWZmZXItPnJhbmdlX2xlbmd0aCgpIDwgMSkgeworICAgICAgICByZXR1cm4gMDsKKyAgICB9CisKKyAgICB1aW50OF90ICpkYXRhID0gKHVpbnQ4X3QgKilidWZmZXItPmRhdGEoKSArIGJ1ZmZlci0+cmFuZ2Vfb2Zmc2V0KCk7CisgICAgdWludDhfdCB0b2MgPSBkYXRhWzBdOworICAgIHVpbnQ4X3QgY29uZmlnID0gKHRvYyA+PiAzKSAmIDB4MWY7CisgICAgdWludDMyX3QgZnJhbWVTaXplc1VzW10gPSB7CisgICAgICAgIDEwMDAwLCAyMDAwMCwgNDAwMDAsIDYwMDAwLCAvLyAwLi4uMworICAgICAgICAxMDAwMCwgMjAwMDAsIDQwMDAwLCA2MDAwMCwgLy8gNC4uLjcKKyAgICAgICAgMTAwMDAsIDIwMDAwLCA0MDAwMCwgNjAwMDAsIC8vIDguLi4xMQorICAgICAgICAxMDAwMCwgMjAwMDAsICAgICAgICAgICAgICAgLy8gMTIuLi4xMworICAgICAgICAxMDAwMCwgMjAwMDAsICAgICAgICAgICAgICAgLy8gMTQuLi4xNQorICAgICAgICAyNTAwLCA1MDAwLCAxMDAwMCwgMjAwMDAsICAgLy8gMTYuLi4xOQorICAgICAgICAyNTAwLCA1MDAwLCAxMDAwMCwgMjAwMDAsICAgLy8gMjAuLi4yMworICAgICAgICAyNTAwLCA1MDAwLCAxMDAwMCwgMjAwMDAsICAgLy8gMjQuLi4yNworICAgICAgICAyNTAwLCA1MDAwLCAxMDAwMCwgMjAwMDAgICAgLy8gMjguLi4zMQorICAgIH07CisgICAgdWludDMyX3QgZnJhbWVTaXplVXMgPSBmcmFtZVNpemVzVXNbY29uZmlnXTsKKworICAgIHVpbnQzMl90IG51bUZyYW1lczsKKyAgICB1aW50OF90IGMgPSB0b2MgJiAzOworICAgIHN3aXRjaCAoYykgeworICAgIGNhc2UgMDoKKyAgICAgICAgbnVtRnJhbWVzID0gMTsKKyAgICAgICAgYnJlYWs7CisgICAgY2FzZSAxOgorICAgIGNhc2UgMjoKKyAgICAgICAgbnVtRnJhbWVzID0gMjsKKyAgICAgICAgYnJlYWs7CisgICAgY2FzZSAzOgorICAgICAgICBpZiAoYnVmZmVyLT5yYW5nZV9sZW5ndGgoKSA8IDMpIHsKKyAgICAgICAgICAgIG51bUZyYW1lcyA9IDA7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBudW1GcmFtZXMgPSBkYXRhWzJdICYgMHgzZjsKKyAgICAgICAgfQorICAgICAgICBicmVhazsKKyAgICBkZWZhdWx0OgorICAgICAgICBUUkVTUEFTUygpOworICAgIH0KKworICAgIHVpbnQzMl90IG51bVNhbXBsZXMgPSBmcmFtZVNpemVVcyAqIG51bUZyYW1lcyAqIGtPcHVzU2FtcGxlUmF0ZSAvIDEwMDAwMDA7CisgICAgcmV0dXJuIG51bVNhbXBsZXM7Cit9CisKK3N0YXR1c190IE15T2dnRXh0cmFjdG9yOjpfcmVhZE5leHRQYWNrZXQoTWVkaWFCdWZmZXIgKipvdXQsIGJvb2wgY2FsY1ZvcmJpc1RpbWVzdGFtcCkgewogICAgICpvdXQgPSBOVUxMOwogCiAgICAgTWVkaWFCdWZmZXIgKmJ1ZmZlciA9IE5VTEw7CkBAIC01MjMsOSArNzI3LDggQEAKICAgICAgICAgICAgICAgICAgICAgbUZpcnN0UGFja2V0SW5QYWdlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgLy8gaWdub3JlIHRpbWVzdGFtcCBmb3IgY29uZmlndXJhdGlvbiBwYWNrZXRzCi0gICAgICAgICAgICAgICAgaWYgKCFjb25mKSB7Ci0gICAgICAgICAgICAgICAgICAgIGludDMyX3QgY3VyQmxvY2tTaXplID0gcGFja2V0QmxvY2tTaXplKGJ1ZmZlcik7CisgICAgICAgICAgICAgICAgaWYgKGNhbGNWb3JiaXNUaW1lc3RhbXApIHsKKyAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBjdXJCbG9ja1NpemUgPSBnZXRQYWNrZXRCbG9ja1NpemUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgaWYgKG1DdXJyZW50UGFnZS5tUHJldlBhY2tldFNpemUgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBtQ3VycmVudFBhZ2UubVByZXZQYWNrZXRTaXplID0gY3VyQmxvY2tTaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgbUN1cnJlbnRQYWdlLm1QcmV2UGFja2V0UG9zID0KQEAgLTU5Nyw0MyArODAwLDI0IEBACiAgICAgfQogfQogCi1zdGF0dXNfdCBNeVZvcmJpc0V4dHJhY3Rvcjo6aW5pdCgpIHsKK3N0YXR1c190IE15T2dnRXh0cmFjdG9yOjppbml0KCkgewogICAgIG1NZXRhID0gbmV3IE1ldGFEYXRhOwotICAgIG1NZXRhLT5zZXRDU3RyaW5nKGtLZXlNSU1FVHlwZSwgTUVESUFfTUlNRVRZUEVfQVVESU9fVk9SQklTKTsKKyAgICBtTWV0YS0+c2V0Q1N0cmluZyhrS2V5TUlNRVR5cGUsIG1NaW1lVHlwZSk7CiAK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mV0dXJuIHZlcmlmeU9wdXNIZWFkZXIoYnVmZmVyKTsKKyAgICAgICAgY2FzZSAzOgorICAgICAgICAgICAgcmV0dXJuIHZlcmlmeU9wdXNDb21tZW50cyhidWZmZXIpOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgcmV0dXJuIElOVkFMSURfT1BFUkFUSU9OOworICAgIH0KK30KKworc3RhdHVzX3QgTXlPcHVzRXh0cmFjdG9yOjp2ZXJpZnlPcHVzSGVhZGVyKE1lZGlhQnVmZmVyICpidWZmZXIpIHsKKyAgICBjb25zdCBzaXplX3Qga09wdXNIZWFkZXJTaXplID0gMTk7CisgICAgY29uc3QgdWludDhfdCAqZGF0YSA9CisgICAgICAgIChjb25zdCB1aW50OF90ICopYnVmZmVyLT5kYXRhKCkgKyBidWZmZXItPnJhbmdlX29mZnNldCgpOworCisgICAgc2l6ZV90IHNpemUgPSBidWZmZXItPnJhbmdlX2xlbmd0aCgpOworCisgICAgaWYgKHNpemUgPCBrT3B1c0hlYWRlclNpemUKKyAgICAgICAgICAgIHx8IG1lbWNtcChkYXRhLCAiT3B1c0hlYWQiLCA4KQorICAgICAgICAgICAgfHwgLyogdmVyc2lvbiA9ICovIGRhdGFbOF0gIT0gMSkgeworICAgICAgICByZXR1cm4gRVJST1JfTUFMRk9STUVEOworICAgIH0KKworICAgIG1DaGFubmVsQ291bnQgPSBkYXRhWzldOworICAgIG1Db2RlY0RlbGF5ID0gVTE2TEVfQVQoJmRhdGFbMTBdKTsKKworICAgIG1NZXRhLT5zZXREYXRhKGtLZXlPcHVzSGVhZGVyLCAwLCBkYXRhLCBzaXplKTsKKyAgICBtTWV0YS0+c2V0SW50MzIoa0tleVNhbXBsZVJhdGUsIGtPcHVzU2FtcGxlUmF0ZSk7CisgICAgbU1ldGEtPnNldEludDMyKGtLZXlDaGFubmVsQ291bnQsIG1DaGFubmVsQ291bnQpOworICAgIG1NZXRhLT5zZXRJbnQ2NChrS2V5T3B1c1NlZWtQcmVSb2xsI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2dwYWNrX3JlYWQoJmJpdHMsIDgpOworICAgIH0KKworICAgIGludDMyX3QgbiA9IG9nZ3BhY2tfcmVhZCgmYml0cywgMzIpOworICAgIGZyYW1pbmdCaXRPZmZzZXQgKz0gNDsKKyAgICBpZiAobiA8IDAgfHwgbiA+ICgoY29tbWVudFNpemUgLSBvZ2dwYWNrX2J5dGVzKCZiaXRzKSkgPj4gMikpIHsKKyAgICAgICAgcmV0dXJuIEVSUk9SX01BTEZPUk1FRDsKKyAgICB9CisgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKKyAgICAgICAgaW50MzJfdCBsZW4gPSBvZ2dwYWNrX3JlYWQoJmJpdHMsIDMyKTsKKyAgICAgICAgZnJhbWluZ0JpdE9mZnNldCArPSA0OworICAgICAgICBpZiAobGVuICA8IDAgfHwgbGVuICA+IChjb21tZW50U2l6ZSAtIG9nZ3BhY2tfYnl0ZXMoJmJpdHMpKSkgeworICAgICAgICAgICAgcmV0dXJuIEVSUk9SX01BTEZPUk1FRDsKKyAgICAgICAgfQorICAgICAgICBmcmFtaW5nQml0T2Zmc2V0ICs9IGxlbjsKKyAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBsZW47ICsraikgeworICAgICAgICAgICAgb2dncGFja19yZWFkKCZiaXRzLCA4KTsKKyAgICAgICAgfQorICAgIH0KKyAgICBpZiAoZnJhbWluZ0JpdE9mZnNldCA8IDAgfHwgZnJhbWluZ0JpdE9mZnNldCA+PSBjb21tZW50U2l6ZSkgeworICAgICAgICByZXR1cm4gRVJST1JfTUFMRk9STUVEOworICAgIH0KKyAgICBjb21tZW50RGF0YVtmcmFtaW5nQml0T2Zmc2V0XSA9IDE7CisKKyAgICBidWYuZGF0YSA9IGNvbW1lbnREYXRhICsgaGVhZGVyTGVuOworICAgIGJ1Zi5zaXplID0gY29tbWVudFNpemUgLSBoZWFkZXJMZW47CisgICAgYnVmLnJlZmNvdW50ID0gMTsKKyAgICBidWYucHRyLm93bmVyID0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luZG93KTsKKyAgICAgICAgaWYgKGVyciAhPSBOT19FUlJPUikgeworICAgICAgICAgICAgQUxPR0UoImVycm9yIGF1dGhlbnRpY2F0aW5nIG5hdGl2ZSB3aW5kb3c6ICVzICglZCkiLCBzdHJlcnJvcigtZXJyKSwgLWVycik7CisgICAgICAgICAgICByZXR1cm4gZXJyOworICAgICAgICB9CisgICAgICAgIGlmIChxdWV1ZXNUb05hdGl2ZVdpbmRvdyAhPSAxKSB7CisgICAgICAgICAgICBBTE9HRSgibmF0aXZlIHdpbmRvdyBjb3VsZCBub3QgYmUgYXV0aGVudGljYXRlZCIpOworICAgICAgICAgICAgcmV0dXJuIFBFUk1JU1NJT05fREVOSUVEOworICAgICAgICB9CisgICAgfQorCisgICAgaW50IGNvbnN1bWVyVXNhZ2UgPSAwOworICAgIGVyciA9IG5hdGl2ZVdpbmRvdy0+cXVlcnkobmF0aXZlV2luZG93LCBOQVRJVkVfV0lORE9XX0NPTlNVTUVSX1VTQUdFX0JJVFMsICZjb25zdW1lclVzYWdlKTsKKyAgICBpZiAoZXJyICE9IE5PX0VSUk9SKSB7CisgICAgICAgIEFMT0dXKCJmYWlsZWQgdG8gZ2V0IGNvbnN1bWVyIHVzYWdlIGJpdHMuIGlnbm9yaW5nIik7CisgICAgICAgIGVyciA9IE5PX0VSUk9SOworICAgIH0KKworICAgIGludCBmaW5hbFVzYWdlID0gdXNhZ2UgfCBjb25zdW1lclVzYWdlOworICAgIEFMT0dWKCJncmFsbG9jIHVzYWdlOiAlI3gocHJvZHVjZXIpICsgJSN4KGNvbnN1bWVyKSA9ICUjeCIsIHVzYWdlLCBjb25zdW1lclVzYWdlLCBmaW5hbFVzYWdlKTsKKyAgICBlcnIgPSBuYXRpdmVfd2luZG93X3NldF91c2FnZShuYXRpdmVXaW5kb3csIGZpbmFsVXNhZ2UpOworICAgIGlmIChlcnIgIT0gTk9fRVJST1IpIHsKKyAgICAgICAgQUxPR0UoIm5hdGl2ZV93aW5kb3dfc2V0X3Vz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VFlQRV9WSURFT19BVkMpIHsKICAgICAgICAgICAgIHNwPEFCdWZmZXI+IGNzZDE7CiAgICAgICAgICAgICBpZiAobXNnLT5maW5kQnVmZmVyKCJjc2QtMSIsICZjc2QxKSkgewogICAgICAgICAgICAgICAgIGNoYXIgYXZjY1sxMDI0XTsgLy8gdGhhdCBvdWdodGEgYmUgZW5vdWdoLCByaWdodD8KICAgICAgICAgICAgICAgICBzaXplX3Qgb3V0c2l6ZSA9IHJlYXNzZW1ibGVBVkNDKGNzZDAsIGNzZDEsIGF2Y2MpOwogICAgICAgICAgICAgICAgIG1ldGEtPnNldERhdGEoa0tleUFWQ0MsIGtLZXlBVkNDLCBhdmNjLCBvdXRzaXplKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIGlmIChtaW1lLnN0YXJ0c1dpdGgoImF1ZGlvLyIpKSB7CisgICAgICAgIH0gZWxzZSBpZiAobWltZSA9PSBNRURJQV9NSU1FVFlQRV9BVURJT19BQUMgfHwgbWltZSA9PSBNRURJQV9NSU1FVFlQRV9WSURFT19NUEVHNCkgewogICAgICAgICAgICAgaW50IGNzZDBzaXplID0gY3NkMC0+c2l6ZSgpOwogICAgICAgICAgICAgY2hhciBlc2RzW2NzZDBzaXplICsgMzFdOworICAgICAgICAgICAgLy8gVGhlIHdyaXR0ZW4gRVNEUyBpcyBhY3R1YWxseSBmb3IgYW4gYXVkaW8gc3RyZWFtLCBidXQgaXQncyBlbm91Z2gKKyAgICAgICAgICAgIC8vIGZvciB0cmFuc3BvcnRpbmcgdGhlIENTRCB0byBtdXhlcnMuCiAgICAgICAgICAgICByZWFzc2VtYmxlRVNEUyhjc2QwLCBlc2RzKTsKICAgICAgICAgICAgIG1ldGEtPnNldERhdGEoa0tleUVTRFMsIGtLZXlFU0RTLCBlc2RzLCBzaXplb2YoZXNkcykpOwogICAgICAgICB9CmRpZmYgLS1naXQgYS9tZWRpYS9saWJzdGFnZWZyaWdodC9jb2RlY3MvYWFjZGVjL1NvZ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DMxOworICAgICAgICB9IGVsc2UgaWYgKGRpc3BsYXlTaXplWSA+ICg2MjQgKiAzMjApKSB7CisgICAgICAgICAgICBpNF9sZXZlbCA9IDMwOworICAgICAgICB9IGVsc2UgaWYgKGRpc3BsYXlTaXplWSA+ICgzNTIgKiAyODgpKSB7CisgICAgICAgICAgICBpNF9sZXZlbCA9IDIxOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgaTRfbGV2ZWwgPSAyMDsKKyAgICAgICAgfQogICAgIH0gZWxzZSB7Ci0gICAgICAgIGk0X2xldmVsID0gMjA7CisgICAgICAgIGk0X2xldmVsID0gbU5ld0xldmVsOwogICAgIH0KIAogICAgIHsKQEAgLTY5MSw2ICs2OTYsNyBAQAogICAgICAgICAgICAgYm9vbCB1bnN1cHBvcnRlZERpbWVuc2lvbnMgPQogICAgICAgICAgICAgICAgIChJVkRfU1RSRUFNX1dJRFRIX0hFSUdIVF9OT1RfU1VQUE9SVEVEID09IChzX2RlY19vcC51NF9lcnJvcl9jb2RlICYgMHhGRikpOwogICAgICAgICAgICAgYm9vbCByZXNDaGFuZ2VkID0gKElWRF9SRVNfQ0hBTkdFRCA9PSAoc19kZWNfb3AudTRfZXJyb3JfY29kZSAmIDB4RkYpKTsKKyAgICAgICAgICAgIGJvb2wgdW5zdXBwb3J0ZWRMZXZlbCA9IChJSDI2NERfVU5TVVBQT1JURURfTEVWRUwgPT0gKHNfZGVjX29wLnU0X2Vycm9yX2NvZGUgJiAweEZGKSk7CiAKICAgICAgICAgICAgIEdFVFRJTUUoJm1UaW1lRW5kLCBOVUxMKTsKICAgICAgICAgICAgIC8qIENvbXB1dGUgdGltZSB0YWtlbiBmb3IgZGVjb2RlKCkgKi8KQEAgLTcyMiw2ICs3MjgsMTggQEAKICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICB9CiAKKyAgICAgICAgICAgIGlmICh1bnN1cHBvcnRlZExldmVsICYmICFtRmx1c2hOZWVkZWQpIHsKKworICAgICAgICAgICAgICAgIG1OZXdMZXZlbCA9IDUxOworCisgICAgICAgICAgICAgICAgQ0hFQ0tfRVEocmVJbml0RGVjb2RlcigpLCAoc3RhdHVzX3QpT0spOworCisgICAgICAgICAgICAgICAgc2V0RGVjb2RlQXJncygmc19kZWNfaXAsICZzX2RlY19vcCwgaW5IZWFkZXIsIG91dEhlYWRlciwgdGltZVN0YW1wSXgpOworCisgICAgICAgICAgICAgICAgaXZkZWNfYXBpX2Z1bmN0aW9uKG1Db2RlY0N0eCwgKHZvaWQgKikmc19kZWNfaXAsICh2b2lkICopJnNfZGVjX29wKTsKKyAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICB9CisKICAgICAgICAgICAgIC8vIElmIHRoZSBkZWNvZGVyIGlzIGluIHRoZSBjaGFuZ2luZyByZXNvbHV0aW9uIG1vZGUgYW5kIHRoZXJlIGlzIG5vIG91dHB1dCBwcmVzZW50LAogICAgICAgICAgICAgLy8gdGhhdCBtZWFucyB0aGUgc3dpdGNoaW5nIGlzIGRvbmUgYW5kIGl0J3MgcmVhZHkgdG8gcmVzZXQgdGhlIGRlY29kZXIgYW5kIHRoZSBwbHVnaW4uCiAgICAgICAgICAgICBpZiAobUNoYW5naW5nUmVzb2x1dGlvbiAmJiAhc19kZWNfb3AudTRfb3V0cHV0X3ByZXNlbnQpIHsKQEAgLTc0NSw2ICs3NjMsMTcgQEAKICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgIH0KIAorICAgICAgICAgICAgaWYgKHVuc3VwcG9ydGVkTGV2ZWwpIHsKKworICAgICAgICAgICAgICAgIGlmIChtRmx1c2hOZWVkZWQpIHsKKyAgICAgICAgICAgICAgICAgICAgc2V0Rmx1c2hNb2RlKCk7CisgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgbU5ld0xldmVsID0gNTE7CisgICAgICAgICAgICAgICAgbUluaXROZWVkZWQgPSB0cnVlOworICAgICAgICAgICAgICAgIGNvbnRpbnVlOwor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b3BXaWR0aCAtIDEsIG1Dcm9wSGVpZ2h0IC0gMSk7CiAgICAgfSBlbHNlIGlmIChtQ29sb3JGb3JtYXQgPT0gT01YX0NPTE9SX0Zvcm1hdFlVVjQyMFBsYW5hcikgeworICAgICAgICBpZiAoKHNpemVfdCltV2lkdGggKiBtSGVpZ2h0ICogMyAvIDIgPiBzaXplKSB7CisgICAgICAgICAgICBnb3RvIHNraXBfY29weWluZzsKKyAgICAgICAgfQogICAgICAgICBjb25zdCB1aW50OF90ICpzcmNfeSA9IChjb25zdCB1aW50OF90ICopZGF0YTsKICAgICAgICAgY29uc3QgdWludDhfdCAqc3JjX3UgPQogICAgICAgICAgICAgICAgIChjb25zdCB1aW50OF90ICopZGF0YSArIG1XaWR0aCAqIG1IZWlnaHQ7CkBAIC0yNTgsNiArMjczLDkgQEAKICAgICAgICAgfQogICAgIH0gZWxzZSBpZiAobUNvbG9yRm9ybWF0ID09IE9NWF9USV9DT0xPUl9Gb3JtYXRZVVY0MjBQYWNrZWRTZW1pUGxhbmFyCiAgICAgICAgICAgICB8fCBtQ29sb3JGb3JtYXQgPT0gT01YX0NPTE9SX0Zvcm1hdFlVVjQyMFNlbWlQbGFuYXIpIHsKKyAgICAgICAgaWYgKChzaXplX3QpbVdpZHRoICogbUhlaWdodCAqIDMgLyAyID4gc2l6ZSkgeworICAgICAgICAgICAgZ290byBza2lwX2NvcHlpbmc7CisgICAgICAgIH0KICAgICAgICAgY29uc3QgdWludDhfdCAqc3JjX3kgPSAoY29uc3QgdWludDhfdCAqKWRhdGE7CiAgICAgICAgIGNvbnN0IHVpbnQ4X3QgKnNyY191diA9IChjb25zdCB1aW50OF90ICopZGF0YQogICAgICAgICAgICAgICAgICsgbVdpZHRoICogKG1IZWlnaHQgLSBtQ3JvcFRvcCAvIDIpOwpAQCAtMjg5LDYgKzMwNyw5IEBACiAgICAgICAgICAgICBkc3RfdiArPSBkc3RfY19zdHJpZGU7CiAgICAgICAgIH0KICAgICB9IGVsc2UgaWYgKG1Db2xvckZvcm1hdCA9PSBPTVhfQ09MT1JfRm9ybWF0MjRiaXRSR0I4ODgpIHsKKyAgICAgICAgaWYgKChzaXplX3QpbVdpZHRoICogbUhlaWdodCAqIDMgPiBzaXplKSB7CisgICAgICAgICAgICBnb3RvIHNraXBfY29weWluZzsKKyAgICAgICAgfQogICAgICAgICB1aW50OF90KiBzcmNQdHIgPSAodWludDhfdCopZGF0YTsKICAgICAgICAgdWludDhfdCogZHN0UHRyID0gKHVpbnQ4X3QqKWRzdDsKIApAQCAtMjk4LDYgKzMxOSw5IEBACiAgICAgICAgICAgICBkc3RQdHIgKz0gYnVmLT5zdHJpZGUgKiAzOwogICAgICAgICB9CiAgICAgfSBlbHNlIGlmIChtQ29sb3JGb3JtYXQgPT0gT01YX0NPTE9SX0Zvcm1hdDMyYml0QVJHQjg4ODgpIHsKKyAgICAgICAgaWYgKChzaXplX3QpbVdpZHRoICogbUhlaWdodCAqIDQgPiBzaXplKSB7CisgICAgICAgICAgICBnb3RvIHNraXBfY29weWluZzsKKyAgICAgICAgfQogICAgICAgICB1aW50OF90ICpzcmNQdHIsICpkc3RQdHI7CiAKICAgICAgICAgZm9yIChzaXplX3QgeSA9IDA7IHkgPCAoc2l6ZV90KW1Dcm9wSGVpZ2h0OyArK3kpIHsKQEAgLTMxMiw2ICszMzYsOSBAQAogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfSBlbHNlIGlmIChtQ29sb3JGb3JtYXQgPT0gT01YX0NPTE9SX0Zvcm1hdDMyQml0UkdCQTg4ODgpIHsKKyAgICAgICAgaWYgKChzaXplX3QpbVdpZHRoICogbUhlaWdodCAqIDQgPiBzaXplKSB7CisgICAgICAgICAgICBnb3RvIHNraXBfY29weWluZzsKKyAgICAgICAgfQogICAgICAgICB1aW50OF90KiBzcmNQdHIgPSAodWludDhfdCopZGF0YTsKICAgICAgICAgdWludDhfdCogZHN0UHRyID0gKHVpbnQ4X3QqKWRzdDsKIApAQCAtMzI0LDE4ICsz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WQgb24gc2VyaWFsIG51bWJlcgorICAgICAgICBzdGF0aWMgY2hhciBzZXJpYWxbUFJPUEVSVFlfVkFMVUVfTUFYXTsKKyAgICAgICAgcHJvcGVydHlfZ2V0KCJyby5zZXJpYWxubyIsIHNlcmlhbCwgIjAiKTsKKyAgICAgICAgdWludDY0X3QgbnVtID0gMDsgLy8gaXQgaXMgb2theSBmb3IgdGhpcyBudW1iZXIgdG8gb3ZlcmZsb3cKKyAgICAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBORUxFTShzZXJpYWwpICYmIHNlcmlhbFtpXSAhPSAnXDAnOyArK2kpIHsKKyAgICAgICAgICAgIGNvbnN0IGNoYXIgJmMgPSBzZXJpYWxbaV07CisgICAgICAgICAgICAvLyB0cnkgdG8gdXNlIG1vc3QgbGV0dGVycyBvZiBzZXJpYWxubworICAgICAgICAgICAgaWYgKGlzZGlnaXQoYykpIHsKKyAgICAgICAgICAgICAgICBudW0gPSBudW0gKiAxMCArIChjIC0gJzAnKTsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNsb3dlcihjKSkgeworICAgICAgICAgICAgICAgIG51bSA9IG51bSAqIDI2ICsgKGMgLSAnYScpOworICAgICAgICAgICAgfSBlbHNlIGlmIChpc3VwcGVyKGMpKSB7CisgICAgICAgICAgICAgICAgbnVtID0gbnVtICogMjYgKyAoYyAtICdBJyk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIG51bSA9IG51bSAqIDI1NiArIGM7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgQUxPR0koImdvdCBzZXJpYWwiKTsKKyAgICAgICAgc2VyaWFsTnVtID0gbnVtOworICAgICAgICBhbmRyb2lkX2F0b21pY19yZWxlYXNlX3N0b3JlKDEsICZoYXZlU2VyaWFsKTsKKyAgICB9CisgICAgQUxPR0koInNlcmlhbDogJWxsdSwgdGltZTogJWxsdSIsIChsb25nIGxvbmcpc2VyaWFsTnVtLCAobG9uZy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W5QbGF5bGlzdCwKICAgICAgICAgICAgICAgICAgICAgICBmaXJzdFNlcU51bWJlckluUGxheWxpc3QgKyAoaW50MzJfdCltUGxheWxpc3QtPnNpemUoKSAtIDEpOwogCisgICAgICAgICAgICAgICAgaWYgKG1UU1BhcnNlciAhPSBOVUxMKSB7CisgICAgICAgICAgICAgICAgICAgIG1UU1BhcnNlci0+c2lnbmFsRU9TKEVSUk9SX0VORF9PRl9TVFJFQU0pOworICAgICAgICAgICAgICAgICAgICAvLyBVc2UgYW4gZW1wdHkgYnVmZmVyOyB3ZSBkb24ndCBoYXZlIGFueSBuZXcgZGF0YSwganVzdCB3YW50IHRvIGV4dHJhY3QKKyAgICAgICAgICAgICAgICAgICAgLy8gcG90ZW50aWFsIG5ldyBhY2Nlc3MgdW5pdHMgYWZ0ZXIgZmx1c2guICBSZXNldCBtU2VxTnVtYmVyIHRvCisgICAgICAgICAgICAgICAgICAgIC8vIGxhc3RTZXFOdW1iZXJJblBsYXlsaXN0IHN1Y2ggdGhhdCB3ZSBzZXQgdGhlIGNvcnJlY3QgYWNjZXNzIHVuaXQKKyAgICAgICAgICAgICAgICAgICAgLy8gcHJvcGVydGllcyBpbiBleHRyYWN0QW5kUXVldWVBY2Nlc3NVbml0c0Zyb21Ucy4KKyAgICAgICAgICAgICAgICAgICAgc3A8QUJ1ZmZlcj4gYnVmZmVyID0gbmV3IEFCdWZmZXIoMCk7CisgICAgICAgICAgICAgICAgICAgIG1TZXFOdW1iZXIgPSBsYXN0U2VxTnVtYmVySW5QbGF5bGlzdDsKKyAgICAgICAgICAgICAgICAgICAgZXh0cmFjdEFuZFF1ZXVlQWNjZXNzVW5pdHNGcm9tVHMoYnVmZmVyKTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgbm90aWZ5RXJyb3IoRVJST1JfRU5EX09GX1NUUkVBTSk7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIC8vIEl0J3MgcG9zc2libGUgdGhh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BBVFNQYXJzZXI6OlN0cmVhbTo6cGFyc2VQRVMoQUJpdFJlYWRlciAqYnIsIFN5bmNFdmVudCAqZXZlbnQpIHsKICAgICB1bnNpZ25lZCBwYWNrZXRfc3RhcnRjb2RlX3ByZWZpeCA9IGJyLT5nZXRCaXRzKDI0KTsKIAogICAgIEFMT0dWKCJwYWNrZXRfc3RhcnRjb2RlX3ByZWZpeCA9IDB4JTA4eCIsIHBhY2tldF9zdGFydGNvZGVfcHJlZml4KTsKQEAgLTk3MiwxMyArMTAwMSwxMyBAQAogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBvblBheWxvYWREYXRhKAotICAgICAgICAgICAgICAgICAgICBQVFNfRFRTX2ZsYWdzLCBQVFMsIERUUywgYnItPmRhdGEoKSwgZGF0YUxlbmd0aCk7CisgICAgICAgICAgICAgICAgICAgIFBUU19EVFNfZmxhZ3MsIFBUUywgRFRTLCBici0+ZGF0YSgpLCBkYXRhTGVuZ3RoLCBldmVudCk7CiAKICAgICAgICAgICAgIGJyLT5za2lwQml0cyhkYXRhTGVuZ3RoICogOCk7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBvblBheWxvYWREYXRhKAogICAgICAgICAgICAgICAgICAgICBQVFNfRFRTX2ZsYWdzLCBQVFMsIERUUywKLSAgICAgICAgICAgICAgICAgICAgYnItPmRhdGEoKSwgYnItPm51bUJpdHNMZWZ0KCkgLyA4KTsKKyAgICAgICAgICAgICAgICAgICAgYnItPmRhdGEoKSwgYnItPm51bUJpdHNMZWZ0KCkgLyA4LCBldmVudCk7CiAKICAgICAgICAgICAgIHNpemVfdCBwYXlsb2FkU2l6ZUJpdHMgPSBici0+bnVtQml0c0xlZnQoKTsKICAgICAgICAgICAgIGlmIChwYXlsb2FkU2l6ZUJpdHMgJSA4ICE9IDB1KSB7CkBAIC0xMDAyLDggKzEwMzEsOCBAQAogICAgIHJldHVybiBPSzsKIH0KIAotc3RhdHVzX3QgQVRTUGFyc2VyOjpTdHJlY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ID0gbVF1ZXVlLT5kZXF1ZXVlQWNjZXNzVW5pdCgpKSAhPSBOVUxMKSB7CiAgICAgICAgIGlmIChtU291cmNlID09IE5VTEwpIHsKICAgICAgICAgICAgIHNwPE1ldGFEYXRhPiBtZXRhID0gbVF1ZXVlLT5nZXRGb3JtYXQoKTsKQEAgLTEwNzQsNiArMTEwNCwxNyBAQAogICAgICAgICAgICAgfQogICAgICAgICAgICAgbVNvdXJjZS0+cXVldWVBY2Nlc3NVbml0KGFjY2Vzc1VuaXQpOwogICAgICAgICB9CisKKyAgICAgICAgaWYgKChldmVudCAhPSBOVUxMKSAmJiAhZm91bmQgJiYgbVF1ZXVlLT5nZXRGb3JtYXQoKSAhPSBOVUxMKSB7CisgICAgICAgICAgICBpbnQzMl90IHN5bmMgPSAwOworICAgICAgICAgICAgaWYgKGFjY2Vzc1VuaXQtPm1ldGEoKS0+ZmluZEludDMyKCJpc1N5bmMiLCAmc3luYykgJiYgc3luYykgeworICAgICAgICAgICAgICAgIGludDY0X3QgdGltZVVzOworICAgICAgICAgICAgICAgIGlmIChhY2Nlc3NVbml0LT5tZXRhKCktPmZpbmRJbnQ2NCgidGltZVVzIiwgJnRpbWVVcykpIHsKKyAgICAgICAgICAgICAgICAgICAgZm91bmQgPSB0cnVlOworICAgICAgICAgICAgICAgICAgICBldmVudC0+aW5pdChtUGVzU3RhcnRPZmZzZXQsIG1Tb3VyY2UsIHRpbWVVcyk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICB9CiAgICAgfQogfQogCkBAIC0xMTI2LDE0ICsxMTY3LDE1IEBACiBBVFNQYXJzZXI6On5BVFNQYXJzZXIoKSB7CiB9CiAKLXN0YXR1c190IEFUU1BhcnNlcjo6ZmVlZFRTUGFja2V0KGNvbnN0IHZvaWQgKmRhdGEsIHNpemVfdCBzaXplKSB7CitzdGF0dXNfdCBBVFNQYXJzZXI6OmZlZWRUU1BhY2tldChjb25zdCB2b2lkICpkYXRhLCBzaXplX3Qgc2l6ZSwKKyAgICAgICAgU3luY0V2ZW50ICpldmVudCkgewogICAgIGlmIChzaXplICE9IGtUU1BhY2tldFNpemUpIHsKICAgICAgICAgQUxPR0UoIldyb25nIFRTIHBhY2tldCBzaXplIik7CiAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CiAgICAgfQogCiAgICAgQUJpdFJlYWRlciBicigoY29uc3QgdWludDhfdCAqKWRhdGEsIGtUU1BhY2tldFNpemUpOwotICAgIHJldHVybiBwYXJzZVRTKCZicik7CisgICAgcmV0dXJuIHBhcnNlVFMoJmJyLCBldmVudCk7CiB9CiAKIHZvaWQgQVRTUGFyc2VyOjpzaWduYWxEaXNjb250aW51aXR5KApAQCAtMTI2MSw3ICsxMzAzLDggQEAKIHN0YXR1c190IEFUU1BhcnNlcjo6cGFyc2VQSUQoCiAgICAgICAgIEFCaXRSZWFkZXIgKmJyLCB1bnNpZ25lZCBQSUQsCiAgICAgICAgIHVuc2lnbmVkIGNvbnRpbnVpdHlfY291bnRlciwKLSAgICAgICAgdW5zaWduZWQgcGF5bG9hZF91bml0X3N0YXJ0X2luZGljYXRvcikgeworICAgICAgICB1bnNpZ25lZCBwYXlsb2FkX3VuaXRfc3RhcnRfaW5kaWNhdG9yLAorICAgICAgICBTeW5jRXZlbnQgKmV2ZW50KSB7CiAgICAgc3NpemVfdCBzZWN0aW9uSW5kZXggPSBtUFNJU2VjdGlvbnMuaW5kZXhPZktleShQSUQpOwogCiAgICAgaWYgKHNlY3Rpb25JbmRleCA+PSAwKSB7CkBAIC0xMzMzLDcgKzEzNzYsNyBAQAogICAgICAgICBzdGF0dXNfdCBlcnI7CiAgICAgICAgIGlmIChtUHJvZ3JhbXMuZWRpdEl0ZW1BdChpKS0+cGFyc2VQSUQoCiAgICAgICAgICAgICAgICAgICAgIFBJRCwgY29udGludWl0eV9jb3VudGVyLCBwYXlsb2FkX3VuaXRfc3RhcnRfaW5kaWNhdG9yLAotICAgICAgICAgICAgICAgICAgICBiciwgJmVycikpIHsKKyAgICAgICAgICAgICAgICAgICAgYnIsICZlcnIsIGV2ZW50KSkgewogICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgewogICAgICAgICAgICAgICAgIHJldHVybiBlcnI7CiAgICAgICAgICAgICB9CkBAIC0xMzU0LDYgKzEzOTcsMTEgQEAKICAgICB1bnNpZ25lZCBhZGFwdGF0aW9uX2ZpZWxkX2xlbmd0aCA9IGJyLT5nZXRCaXRzKDgpOwogCiAgICAgaWYgKGFkYXB0YXRpb25fZmllbGRfbGVuZ3RoID4gMCkgeworICAgICAgICBpZiAoYWRhcHRhdGlvbl9maWVsZF9sZW5ndGggKiA4ID4gYnItPm51bUJpdHNMZWZ0KCkpIHsKKyAgICAgICAgICAgIEFMT0dWKCJBZGFwdGF0aW9uIGZpZWxkIHNob3VsZCBiZSBpbmNsdWRlZCBpbiBhIHNpbmdsZSBUUyBwYWNrZXQuIik7CisgICAgICAgICAgICByZXR1cm4gRVJST1JfTUFMRk9STUVEOworICAgICAgICB9CisKICAgICAgICAgdW5zaWduZWQgZGlzY29udGludWl0eV9pbmRpY2F0b3IgPSBici0+Z2V0Qml0cygxKTsKIAogICAgICAgICBpZiAoZGlzY29udGludWl0eV9pbmRpY2F0b3IpIHsKQEAgLTE0MDQsNyArMTQ1Miw3IEBACiAgICAgcmV0dXJuIE9LOwogfQogCi1zdGF0dXNfdCBBVFNQYXJzZXI6OnBhcnNlVFMoQUJpdFJlYWRlciAqYnIpIHsKK3N0YXR1c190IEFUU1BhcnNlcjo6cGFyc2VUUyhBQml0UmVhZGVyICpiciwgU3luY0V2ZW50ICpldmVudCkgewogICAgIEFMT0dWKCItLS0iKTsKIAogICAgIHVuc2lnbmVkIHN5bmNfYnl0ZSA9IGJyLT5nZXRCaXRzKDgpOwpAQCAtMTQ0Myw4ICsxNDkxLDggQEAKICAgICB9CiAgICAgaWYgKGVyciA9PSBPSykgewogICAgICAgICBpZiAoYWRhcHRhdGlvbl9maWVsZF9jb250cm9sID09IDEgf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dXJyZW50IHBvc2l0aW9uCi0gICAgICAgIGludDY0X3QgbmV4dEJ1ZlRpbWVVczsKLSAgICAgICAgaWYgKG1JbXBsLT5uZXh0QnVmZmVyVGltZSgmbmV4dEJ1ZlRpbWVVcykgIT0gT0sgfHwgc2Vla1RpbWVVcyAhPSBuZXh0QnVmVGltZVVzKSB7Ci0gICAgICAgICAgICByZXR1cm4gRVJST1JfVU5TVVBQT1JURUQ7Ci0gICAgICAgIH0KKyAgICBpZiAobUV4dHJhY3Rvci0+ZmVlZFVudGlsQnVmZmVyQXZhaWxhYmxlKG1JbXBsKSAhPSBPSykgeworICAgICAgICByZXR1cm4gRVJST1JfRU5EX09GX1NUUkVBTTsKICAgICB9CiAKICAgICByZXR1cm4gbUltcGwtPnJlYWQob3V0LCBvcHRpb25zKTsKQEAgLTEyOSwyMyArMTI1LDEwIEBACiAgICAgICAgIHJldHVybiBOVUxMOwogICAgIH0KIAotICAgIGJvb2wgc2Vla2FibGUgPSB0cnVlOwotICAgIGlmIChtU291cmNlSW1wbHMuc2l6ZSgpID4gMSkgewotICAgICAgICBpZiAobVNvdXJjZUltcGxzLnNpemUoKSAhPSAydSkgewotICAgICAgICAgICAgQUxPR0UoIldyb25nIHNpemUiKTsKLSAgICAgICAgICAgIHJldHVybiBOVUxMOwotICAgICAgICB9Ci0KLSAgICAgICAgc3A8TWV0YURhdGE+IG1ldGEgPSBtU291cmNlSW1wbHMuZWRpdEl0ZW1BdChpbmRleCktPmdldEZvcm1hdCgpOwotICAgICAgICBjb25zdCBjaGFyICptaW1lOwotICAgICAgICBDSEVDSyhtZXRhLT5maW5kQ1N0cmluZyhrS2V5TUlNRVR5cGUsICZtaW1lKSk7Ci0KLSAgICAgICAgaWYgKCFzdHJuY2FzZWNtcCgiYXVkaW8vIiwgbWltZSwgNikpIHsKLSAgICAgICAgICAgIHNlZWthYmxlID0gZmFsc2U7Ci0gICAgICAgIH0KLSAgICB9Ci0KLSAgICByZXR1cm4gbmV3IE1QRUcyVF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Vla1N5bmNQb2ludHMgPSAmbVN5bmNQb2ludHMuZWRpdFRvcCgpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAKQEAgLTE4OSwxNSArMTc0LDc1IEBACiAgICAgICAgICAgICBpZiAoaW1wbCAhPSBOVUxMKSB7CiAgICAgICAgICAgICAgICAgaGF2ZUF1ZGlvID0gdHJ1ZTsKICAgICAgICAgICAgICAgICBtU291cmNlSW1wbHMucHVzaChpbXBsKTsKKyAgICAgICAgICAgICAgICBtU3luY1BvaW50cy5wdXNoKCk7CisgICAgICAgICAgICAgICAgaWYgKCFoYXZlVmlkZW8pIHsKKyAgICAgICAgICAgICAgICAgICAgbVNlZWtTeW5jUG9pbnRzID0gJm1TeW5jUG9pbnRzLmVkaXRUb3AoKTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAotICAgICAgICBpZiAoKytudW1QYWNrZXRzUGFyc2VkID4gMTAwMDApIHsKKyAgICAgICAgLy8gV2FpdCBvbmx5IGZvciAyIHNlY29uZHMgdG8gZGV0ZWN0IGF1ZGlvL3ZpZGVvIHN0cmVhbXMuCisgICAgICAgIGlmIChBTG9vcGVyOjpHZXROb3dVcygpIC0gc3RhcnRUaW1lID4gMjAwMDAwMGxsKSB7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KIAotICAgIEFMT0dJKCJoYXZlQXVkaW89JWQsIGhhdmVWaWRlbz0lZCIsIGhhdmVBdWRpbywgaGF2ZVZpZGVvKTsKKyAgICBvZmY2NF90IHNpemU7CisgICAgaWYgKG1EYXRhU291cmNlLT5nZXRTaXplKCZzaXplKSA9PSBPSyAmJiAoaGF2ZUF1ZGlvIHx8IGhhdmVWaWRlbykpIHsKKyAgICAgICAgc3A8QW5vdGhlclBhY2tldFNvdXJjZT4gaW1wbCA9IGhhdmVWaWRlbworICAgICAgICAgICAgICAgID8gKEFub3RoZXJQYWNrZXRTb3VyY2UgKiltUGFyc2VyLT5nZXRTb3VyY2UoCisgICAgICAgICAgICAgICAgICAgICAgICBBVFNQYXJzZXI6OlZJREVPKS5nZXQoKQorICAgICAgICAgICAgICAgIDogKEFub3RoZXJQYWNrZXRTb3VyY2UgKiltUGFyc2VyLT5nZXRTb3VyY2UoCisgICAgICAgICAgICAgICAgICAgICAgICBBVFNQYXJzZXI6OkFVRElPKS5nZXQoKTsKKyAgICAgICAgc2l6ZV90IHByZXZTeW5jU2l6ZSA9IDE7CisgICAgICAgIGludDY0X3QgZHVyYXRpb25VcyA9IC0xOworICAgICAgICBMaXN0PGludDY0X3Q+IGR1cmF0aW9uczsKKyAgICAgICAgLy8gRXN0aW1hdGUgZHVyYXRpb24gLS0tIHN0YWJpbGl6ZSB1bnRpbCB5b3UgZ2V0IDw1MDBtcyBkZXZpYXRpb24uCisgICAgICAgIHdoaWxlIChmZWVkTW9yZSgpID09IE9LCisgICAgICAgICAgICAgICAgJiYgQUxvb3Blcjo6R2V0Tm93VXMoKSAtIHN0YXJ0VGltZSA8PSAyMDAwMDAwbGwpIHsKKyAgICAgICAgICAgIGlmIChtU2Vla1N5bmNQb2ludHMtPnNpemUoKSA+IHByZXZTeW5jU2l6ZSkgeworICAgICAgICAgICAgICAgIHByZXZTeW5jU2l6ZSA9IG1TZWVrU3luY1BvaW50cy0+c2l6ZSgpOworICAgICAgICAgICAgICAgIGludDY0X3QgZGlmZlVzID0gbVNlZWtTeW5jUG9pbnRzLT5rZXlBdChwcmV2U3luY1NpemUgLSAxKQorICAgICAgICAgICAgICAgICAgICAgICAgLSBtU2Vla1N5bmNQb2ludHMtPmtleUF0KDApOworICAgICAgICAgICAgICAgIG9mZjY0X3QgZGlmZk9mZnNldCA9IG1TZWVrU3luY1BvaW50cy0+dmFsdWVBdChwcmV2U3luY1NpemUgLSAxKQorICAgICAgICAgICAgICAgICAgICAgICAgLSBtU2Vla1N5bmNQb2ludHMtPnZhbHVlQXQoMCk7CisgICAgICAgICAgICAgICAgZHVyYXRpb25VcyA9IHNpemUgKiBkaWZmVXMgLyBkaWZmT2Zmc2V0OworICAgICAgICAgICAgICAgIGR1cmF0aW9ucy5wdXNoX2JhY2soZHVyYXRpb25Vcyk7CisgICAgICAgICAgICAgICAgaWYgKGR1cmF0aW9ucy5zaXplKCkgPiA1KSB7CisgICAgICAgICAgICAgICAgICAgIGR1cmF0aW9ucy5lcmFzZShkdXJhdGlvbnMuYmVnaW4oKSk7CisgICAgICAgICAgICAgICAgICAgIGludDY0X3QgbWluID0gKmR1cmF0aW9ucy5iZWdpbigpOworICAgICAgICAgICAgICAgICAgICBpbnQ2NF90IG1heCA9ICpkdXJhdGlvbnMuYmVnaW4oKTsKKyAgICAgICAgICAgICAgICAgICAgZm9yIChMaXN0PGludDY0X3Q+OjppdGVyYXRvciBpID0gZHVyYXRpb25zLmJlZ2luKCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaSAhPSBkdXJhdGlvbnMuZW5kKCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKytpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWluID4gKmkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW4gPSAqaTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXggPCAqaSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heCA9ICppOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGlmIChtYXggLSBtaW4gPCA1MDAgKiAxMDAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBzdGF0dXNfdCBlcnI7CisgICAgICAgIGludDY0X3QgYnVmZmVyZWREdXJhdGlvblVzOworICAgICAgICBidWZmZXJlZER1cmF0aW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ICBib29sIHNob3VsZFNlZWtCZXlvbmQgPQorICAgICAgICAgICAgKHNlZWtUaW1lVXMgPiBtU2Vla1N5bmNQb2ludHMtPmtleUF0KG1TZWVrU3luY1BvaW50cy0+c2l6ZSgpIC0gMSkpOworCisgICAgLy8gRGV0ZXJtaW5lIHRoZSBzeW5jIHBvaW50IHRvIHNlZWsuCisgICAgc2l6ZV90IGluZGV4ID0gMDsKKyAgICBmb3IgKDsgaW5kZXggPCBtU2Vla1N5bmNQb2ludHMtPnNpemUoKTsgKytpbmRleCkgeworICAgICAgICBpbnQ2NF90IHRpbWVVcyA9IG1TZWVrU3luY1BvaW50cy0+a2V5QXQoaW5kZXgpOworICAgICAgICBpZiAodGltZVVzID4gc2Vla1RpbWVVcykgeworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBzd2l0Y2ggKHNlZWtNb2RlKSB7CisgICAgICAgIGNhc2UgTWVkaWFTb3VyY2U6OlJlYWRPcHRpb25zOjpTRUVLX05FWFRfU1lOQzoKKyAgICAgICAgICAgIGlmIChpbmRleCA9PSBtU2Vla1N5bmNQb2ludHMtPnNpemUoKSkgeworICAgICAgICAgICAgICAgIEFMT0dXKCJOZXh0IHN5bmMgbm90IGZvdW5kOyBzdGFydGluZyBmcm9tIHRoZSBsYXRlc3Qgc3luYy4iKTsKKyAgICAgICAgICAgICAgICAtLWluZGV4OworICAgICAgICAgICAgfQorICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgTWVkaWFTb3VyY2U6OlJlYWRPcHRpb25zOjpTRUVLX0NMT1NFU1RfU1lOQzoKKyAgICAgICAgY2FzZSBNZWRpYVNvdXJjZTo6UmVhZE9wdGlvbnM6OlNFRUtfQ0xPU0VTVDoKKyAgICAgICAgICAgIEFMT0dXKCJzZWVrTW9kZSBub3Qgc3VwcG9ydGVkOiAlZDsgZmFsbGluZyBiYWNrIHRvIFBSRVZJT1VTX1NZTkMiLAorICAgICAgICAgICAgICAgICAgICBzZWVrTW9kZSk7CisgICAgICAgICAgICAvLyBmYWxsLXRocm91Z2gKKyAgICAgICAgY2FzZSBNZWRpYVNvdXJjZTo6UmVhZE9wdGlvbnM6OlNFRUtfUFJFVklPVVNfU1lOQzoKKyAgICAgICAgICAgIGlmIChpbmRleCA9PSAwKSB7CisgICAgICAgICAgICAgICAgQUxPR1coIlByZXZpb3VzIHN5bmMgbm90IGZvdW5kOyBzdGFydGluZyBmcm9tIHRoZSBlYXJsaWVzdCAiCisgICAgICAgICAgICAgICAgICAgICAgICAic3luYy4iKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgLS1pbmRleDsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGJyZWFrOworICAgIH0KKyAgICBpZiAoIXNob3VsZFNlZWtCZXlvbmQgfHwgbU9mZnNldCA8PSBtU2Vla1N5bmNQb2ludHMtPnZhbHVlQXQoaW5kZXgpKSB7CisgICAgICAgIGludDY0X3QgYWN0dWFsU2Vla1RpbWVVcyA9IG1TZWVrU3luY1BvaW50cy0+a2V5QXQoaW5kZXgpOworICAgICAgICBtT2Zmc2V0ID0gbVNlZWtTeW5jUG9pbnRzLT52YWx1ZUF0KGluZGV4KTsKKyAgICAgICAgc3RhdHVzX3QgZXJyID0gcXVldWVEaXNjb250aW51aXR5Rm9yU2VlayhhY3R1YWxTZWVrVGltZVVzKTsKKyAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgfQorICAgIH0KKworICAgIGlmIChzaG91bGRTZWVrQmV5b25kKSB7CisgICAgICAgIHN0YXR1c190IGVyciA9IHNlZWtCZXlvbmQoc2Vla1RpbWVVcyk7CisgICAgICAgIGlmIChlcnIgIT0gT0spIHsKKyAgICAgICAgICAgIHJldHVybiBlcnI7CisgICAgICAgIH0KKyAgICB9CisKKyAgICAvLyBGYXN0LWZvcndhcmQgdG8gc3luYyBmcmFtZS4KKyAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IG1Tb3VyY2VJbXBscy5zaXplKCk7ICsraSkgeworICAgICAgICBjb25zdCBzcDxBbm90aGVyUGFja2V0U291cmNlPiAmaW1wbCA9IG1Tb3VyY2VJbXBsc1tpXTsKKyAgICAgICAgc3RhdHVzX3QgZXJyOworICAgICAgICBmZWVkVW50aWxCdWZmZXJBdmFpbGFibGUoaW1wbCk7CisgICAgICAgIHdoaWxlIChpbXBsLT5oYXNCdWZmZXJBdmFpbGFibGUoJmVycikpIHsKKyAgICAgICAgICAgIHNwPEFNZXNzYWdlPiBtZXRhID0gaW1wbC0+Z2V0TWV0YUFmdGVyTGFzdERlcXVldWVkKDApOworICAgICAgICAgICAgc3A8QUJ1ZmZlcj4gYnVmZmVyOworICAgICAgICAgICAgaWYgKG1ldGEgPT0gTlVMTCkgeworICAgICAgICAgICAgICAgIHJldHVybiBVTktOT1dOX0VSUk9SOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaW50MzJfdCBzeW5jOworICAgICAgICAgICAgaWYgKG1ldGEtPmZpbmRJbnQzMigiaXNTeW5jIiwgJnN5bmMpICYmIHN5bmMpIHsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGVyciA9IGltcGwtPmRlcXVldWVBY2Nlc3NVbml0KCZidWZmZXIpOworICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgICAgIHJldHVybiBlcnI7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBmZWVkVW50aWxCdWZmZXJBdmFpbGFibGUoaW1wbCk7CisgICAgICAgIH0KKyAgICB9CisKKyAgICByZXR1cm4gT0s7Cit9CisKK3N0YXR1c190IE1QRUcyVFNFeHRyYWN0b3I6OnF1ZXVlRGlzY29udGludWl0eUZvclNlZWsoaW50NjRfdCBhY3R1YWxTZWVrVGltZVVzKSB7CisgICAgLy8gU2lnbmFsIGRpc2NvbnRpbnVpdHkKKyAgICBzcDxBTWVzc2FnZT4gZXh0cmEobmV3IEFNZXNzYWdlKTsKKyAgICBleHRyYS0+c2V0SW50NjQoSVN0cmVhbUxpc3RlbmVyOjprS2V5TWVkaWFUaW1lVXMsIGFjdHVhbFNlZWtUaW1lVXMpOworICAgIG1QYXJzZXItPnNpZ25hbERpc2NvbnRpbnVpdHkoQVRTUGFyc2VyOjpESVNDT05USU5VSVRZX1RJTUUsIGV4dHJhKTsKKworICAgIC8vIEFmdGVyIGRpc2NvbnRpbnVpdHksIGltcGwgc2hvdWxkIG9ubHkgaGF2ZSBkaXNjb250aW51aXRpZXMKKyAgICAvLyB3aXRoIHRoZSBsYXN0IGJlaW5nIHdoYXQgd2UgcXVldWVkLiBEZXF1ZXVlIHRoZW0gYWxsIGhlcmUuCisgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBtU291cmNlSW1wbHMuc2l6ZSgpOyArK2kpIHsKKyAgICAgICAgY29uc3Qgc3A8QW5vdGhlclBhY2tldFNvdXJjZT4gJmltcGwgPSBtU291cmNlSW1wbHMuaXRlbUF0KGkpOworICAgICAgICBzcDxBQnVmZmVyPiBidWZmZXI7CisgICAgICAgIHN0YXR1c190IGVycjsKKyAgICAgICAgd2hpbGUgKGltcGwtPmhhc0J1ZmZlckF2YWlsYWJsZSgmZXJyKSkgeworICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgICAgIHJldHVybiBlcnI7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBlcnIgPSBpbXBsLT5kZXF1ZXVlQWNjZXNzVW5pdCgmYnVmZmVyKTsKKyAgICAgICAgICAgIC8vIElmIHRoZSBzb3VyY2UgY29udGFpbnMgYW55dGhpbmcgYnV0IGRpc2NvbnRpbnVpdHksIHRoYXQncworICAgICAgICAgICAgLy8gYSBwcm9ncmFtbWluZyBtaXN0YWtlLgorICAgICAgICAgICAgQ0hFQ0soZXJyID09IElORk9fRElTQ09OVElOVUlUWSk7CisgICAgICAgIH0KKyAgIC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3luY1BvaW50c1NpemUgLSAxKTsKKyAgICAgICAgICAgIC8vIERlcXVldWUgYnVmZmVycyBiZWZvcmUgc3luYyBwb2ludCBpbiBvcmRlciB0byBhdm9pZCB0b28gbXVjaAorICAgICAgICAgICAgLy8gY2FjaGUgYnVpbGRpbmcgdXAuCisgICAgICAgICAgICBzcDxBQnVmZmVyPiBidWZmZXI7CisgICAgICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IG1Tb3VyY2VJbXBscy5zaXplKCk7ICsraSkgeworICAgICAgICAgICAgICAgIGNvbnN0IHNwPEFub3RoZXJQYWNrZXRTb3VyY2U+ICZpbXBsID0gbVNvdXJjZUltcGxzW2ldOworICAgICAgICAgICAgICAgIGludDY0X3QgdGltZVVzOworICAgICAgICAgICAgICAgIHdoaWxlICgoZXJyID0gaW1wbC0+bmV4dEJ1ZmZlclRpbWUoJnRpbWVVcykpID09IE9LKSB7CisgICAgICAgICAgICAgICAgICAgIGlmICh0aW1lVXMgPCBzeW5jVGltZVVzKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpbXBsLT5kZXF1ZXVlQWNjZXNzVW5pdCgmYnVmZmVyKTsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGlmIChlcnIgIT0gT0sgJiYgZXJyICE9IC1FV09VTERCTE9DSykgeworICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXJyOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBpZiAoZmVlZE1vcmUoKSAhPSBPSykgeworICAgICAgICAgICAgcmV0dXJuIEVSUk9SX0VORF9PRl9TVFJFQU07CisgICAgICAgIH0KKyAgICB9CisKKyAgICByZXR1cm4gT0s7Cit9CisKK3N0YXR1c190IE1QRUcyVFNFeHRyYWN0b3I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lKCkpOworICAgICAgICBpZiAoY29uc3VtZXIgPT0gTlVMTCkgeworICAgICAgICAgICAgcmV0dXJuOworICAgICAgICB9CisgICAgICAgIEJ1ZmZlckl0ZW0gYmk7CisgICAgICAgIHN0YXR1c190IGVyciA9IGNvbnN1bWVyLT5hY3F1aXJlQnVmZmVyKCZiaSwgMCk7CisgICAgICAgIGlmIChlcnIgIT0gT0spIHsKKyAgICAgICAgICAgIEFMT0dFKCJQZXJzaXN0ZW50UHJveHlMaXN0ZW5lcjogYWNxdWlyZUJ1ZmZlciBmYWlsZWQgKCVkKSIsIGVycik7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKworICAgICAgICBlcnIgPSBjb25zdW1lci0+ZGV0YWNoQnVmZmVyKGJpLm1CdWYpOworICAgICAgICBpZiAoZXJyICE9IE9LKSB7CisgICAgICAgICAgICBBTE9HRSgiUGVyc2lzdGVudFByb3h5TGlzdGVuZXI6IGRldGFjaEJ1ZmZlciBmYWlsZWQgKCVkKSIsIGVycik7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKworICAgICAgICBlcnIgPSBjb25zdW1lci0+YXR0YWNoQnVmZmVyKCZiaS5tQnVmLCBiaS5tR3JhcGhpY0J1ZmZlcik7CisgICAgICAgIGlmIChlcnIgIT0gT0spIHsKKyAgICAgICAgICAgIEFMT0dFKCJQZXJzaXN0ZW50UHJveHlMaXN0ZW5lcjogYXR0YWNoQnVmZmVyIGZhaWxlZCAoJWQpIiwgZXJyKTsKKyAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgfQorCisgICAgICAgIGVyciA9IGNvbnN1bWVyLT5yZWxlYXNlQnVmZmVyKGJpLm1CdWYsIDAsCisgICAgICAgICAgICAgICAgRUdMX05PX0RJU1BMQVksIEVHTF9OT19TWU5DX0tIUiwgYmkubUZlbmNlKTsKKyAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgQUxPR0UoIlBlcnNpc3RlbnRQcm94eUxpc3R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VhfVklERU9fUkVOREVSRVZFTlRUWVBFICpyZW5kZXJEYXRhID0gKE9NWF9WSURFT19SRU5ERVJFVkVOVFRZUEUgKilwRXZlbnREYXRhOworICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IG5EYXRhMTsgKytpKSB7CisgICAgICAgICAgICBvbXhfbWVzc2FnZSBtc2c7CisgICAgICAgICAgICBtc2cudHlwZSA9IG9teF9tZXNzYWdlOjpGUkFNRV9SRU5ERVJFRDsKKyAgICAgICAgICAgIG1zZy5ub2RlID0gbm9kZTsKKyAgICAgICAgICAgIG1zZy5mZW5jZUZkID0gLTE7CisgICAgICAgICAgICBtc2cudS5yZW5kZXJfZGF0YS50aW1lc3RhbXAgPSByZW5kZXJEYXRhW2ldLm5NZWRpYVRpbWVVczsKKyAgICAgICAgICAgIG1zZy51LnJlbmRlcl9kYXRhLm5hbm9UaW1lID0gcmVuZGVyRGF0YVtpXS5uU3lzdGVtVGltZU5zOworCisgICAgICAgICAgICBkaXNwYXRjaGVyLT5wb3N0KG1zZywgZmFsc2UgLyogcmVhbFRpbWUgKi8pOworICAgICAgICB9CisgICAgICAgIHJldHVybiBPTVhfRXJyb3JOb25lOworICAgIH0KKwogICAgIG9teF9tZXNzYWdlIG1zZzsKICAgICBtc2cudHlwZSA9IG9teF9tZXNzYWdlOjpFVkVOVDsKICAgICBtc2cubm9kZSA9IG5vZGU7CisgICAgbXNnLmZlbmNlRmQgPSAtMTsKICAgICBtc2cudS5ldmVudF9kYXRhLmV2ZW50ID0gZUV2ZW50OwogICAgIG1zZy51LmV2ZW50X2RhdGEuZGF0YTEgPSBuRGF0YTE7CiAgICAgbXNnLnUuZXZlbnRfZGF0YS5kYXRhMiA9IG5EYXRhMjsKIAotICAgIGZpbmREaXNwYXRjaGVyKG5vZGUpLT5wb3N0KG1zZyk7CisgICAgZGlzcGF0Y2hlci0+cG9zdChtc2csIHRydWUgLyogcmVhbFRpbWUgKi8pOwogCiAgICAgcmV0dXJuIE9NWF9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RmQgPSAtMTsKKyAgICAgICAgICAgIHN0YXR1c190IGVyciA9IGZlbmNlLT53YWl0KElPTVg6OmtGZW5jZVRpbWVvdXRNcyk7CisgICAgICAgICAgICBpZiAoZXJyICE9IE9LKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIlRpbWVkIG91dCB3YWl0aW5nIG9uIGlucHV0IGZlbmNlIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIE5VTEw7CisgICAgICAgICAgICB9CisgICAgICAgIH0KICAgICB9IGVsc2UgewogICAgICAgICAvLyBUT0RPOiByZW1vdmUgdGhpcyBwYXJ0LiAgQ2hlY2sgaWYgYW55b25lIHVzZXMgdGhpcy4KIAotICAgICAgICBpZiAoc3JjU2l6ZSA8IHNpemVvZihPTVhfVTMyKSArIHNpemVvZihidWZmZXJfaGFuZGxlX3QpKSB7Ci0gICAgICAgICAgICBBTE9HRSgiTWV0YWRhdGEgaXMgdG9vIHNtYWxsICglenUgdnMgJXp1KSIsIHNyY1NpemUsIHNpemVvZihPTVhfVTMyKSArIHNpemVvZihidWZmZXJfaGFuZGxlX3QpKTsKKyAgICAgICAgaWYgKHNyY1NpemUgPCBzaXplb2YoVmlkZW9HcmFsbG9jTWV0YWRhdGEpKSB7CisgICAgICAgICAgICBBTE9HRSgiTWV0YWRhdGEgaXMgdG9vIHNtYWxsICglenUgdnMgJXp1KSIsIHNyY1NpemUsIHNpemVvZihWaWRlb0dyYWxsb2NNZXRhZGF0YSkpOwogICAgICAgICAgICAgcmV0dXJuIE5VTEw7CiAgICAgICAgIH0KIAotICAgICAgICBoYW5kbGUgPSAqKGJ1ZmZlcl9oYW5kbGVfdCAqKShzcmMgKyBzaXplb2YoT01YX1UzMikpOworICAgICAgICBWaWRlb0dyYWxsb2NNZXRhZGF0YSAmZ3JhbGxvY01ldGEgPSAqKFZpZGVvR3JhbGxvY01ldGFkYXRhICopKHNyYyk7CisgICAgICAgIGhhbmRsZSA9IGdyYWxsb2NNZXRhLnBIYW5kbGU7Ci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SAgICAgICAgICAgIG91dC0+YXBwZW5kKHVybCk7Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBjb25zdCBjaGFyICpzbGFzaFBvcyA9IHN0cnJjaHIoYmFzZVVSTCwgJy8nKTsKLQotICAgICAgICAgICAgaWYgKHNsYXNoUG9zID4gJmJhc2VVUkxbNl0pIHsKLSAgICAgICAgICAgICAgICBvdXQtPnNldFRvKGJhc2VVUkwsIHNsYXNoUG9zIC0gYmFzZVVSTCk7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIG91dC0+c2V0VG8oYmFzZVVSTCk7Ci0gICAgICAgICAgICB9Ci0KKyAgICAgICAgb3V0LT5zZXRUbyhiYXNlVVJMKTsKKyAgICAgICAgaWYgKGJhc2VVUkxbbiAtIDFdICE9ICcvJykgewogICAgICAgICAgICAgb3V0LT5hcHBlbmQoIi8iKTsKLSAgICAgICAgICAgIG91dC0+YXBwZW5kKHVybCk7CiAgICAgICAgIH0KKyAgICAgICAgb3V0LT5hcHBlbmQodXJsKTsKIAogICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICB9CkBAIC0xNzQ3LDcgKzE3MzcsNyBAQAogICAgICAgICB9CiAKICAgICAgICAgaWYgKCFtQWxsVHJhY2tzSGF2ZVRpbWUpIHsKLSAgICAgICAgICAgIGJvb2wgYWxsVHJhY2tzSGF2ZVRpbWUgPSB0cnVlOworICAgICAgICAgICAgYm9vbCBhbGxUcmFja3NIYXZlVGltZSA9IChtVHJhY2tzLnNpemUoKSA+IDApOwogICAgICAgICAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBtVHJhY2tzLnNpemUoKTsgKytpKSB7CiAgICAgICAgICAgICAgICAgVHJhY2tJbmZvICp0cmFjayA9ICZtVHJhY2tzLmVkaXRJdGVtQXQoaSk7CiAgICAgICAgICAgICAgICAgaWYgKHRyYWNrLT5tTlRQQW5jaG9yVXMgPCAwKSB7CmRpZmYgLS1naXQgYS9tZWRp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aHJlYWRCYXNlOjpNSVhFUikgewogICAgICAgICAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBtUGxheWJhY2tUaHJlYWRzLnNpemUoKTsgaSsrKSB7Ci0gICAgICAgICAgICAgICAgaWYgKG1QbGF5YmFja1RocmVhZHMudmFsdWVBdChpKS0+dHlwZSgpID09IFRocmVhZEJhc2U6OkRVUExJQ0FUSU5HKSB7CisgICAgICAgICAgICAgICAgaWYgKG1QbGF5YmFja1RocmVhZHMudmFsdWVBdChpKS0+aXNEdXBsaWNhdGluZygpKSB7CiAgICAgICAgICAgICAgICAgICAgIER1cGxpY2F0aW5nVGhyZWFkICpkdXBUaHJlYWQgPQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIChEdXBsaWNhdGluZ1RocmVhZCAqKW1QbGF5YmFja1RocmVhZHMudmFsdWVBdChpKS5nZXQoKTsKICAgICAgICAgICAgICAgICAgICAgZHVwVGhyZWFkLT5yZW1vdmVPdXRwdXRUcmFjaygoTWl4ZXJUaHJlYWQgKil0aHJlYWQuZ2V0KCkpOwotCiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC0xOTI3LDcgKzE5NTUsNyBAQAogICAgIC8vIFRoZSB0aHJlYWQgZW50aXR5IChhY3RpdmUgdW5pdCBvZiBleGVjdXRpb24pIGlzIG5vIGxvbmdlciBydW5uaW5nIGhlcmUsCiAgICAgLy8gYnV0IHRoZSBUaHJlYWRCYXNlIGNvbnRhaW5lciBzdGlsbCBleGlzdHMuCiAKLSAgICBpZiAodGhyZWFkLT50eXBlKCkgIT0gVGhyZWFkQmFzZTo6RFVQTElDQVRJTkcpIHsKKyAgICBpZiAoIXRocmVhZC0+aXNEdXBsaWNhdGluZygpKSB7CiAgICAgICAgIGNsb3NlT3V0cHV0RmluaXNoKHRocmVhZCk7CiAgICAgfQogCkBAIC0yMTEzLDcgKzIxNDEsOCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0U3RyZWFtLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICppbnB1dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmltYXJ5T3V0cHV0RGV2aWNlX2woKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXZpY2VzCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV2aWNlcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtU3lzdGVtUmVhZHkKICNpZmRlZiBURUVfU0lOSwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICwgdGVlU2luawogI2VuZGlmCkBAIC0yMzc1LDYgKzI0MDQsOSBAQAogewogICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgbVBsYXliYWNrVGhyZWFkcy5zaXplKCk7IGkrKykgewogICAgICAgICBQbGF5YmFja1RocmVhZCAqdGhyZWFkID0gbVBsYXliYWNrVGhyZWFkcy52YWx1ZUF0KGkpLmdldCgpOworICAgICAgICBpZih0aHJlYWQtPmlzRHVwbGljYXRpbmcoKSkgeworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KICAgICAgICAgQXVkaW9TdHJlYW1PdXQgKm91dHB1dCA9IHRocmVhZC0+Z2V0T3V0cHV0KCk7CiAgICAgICAgIGlmIChvdXRwdXQgIT0gTlVMTCAmJiBvdXRwdXQtPmF1ZGlvSHdEZXYgPT0gbVByaW1hcnlIYXJkd2FyZURldikgewogICAgICAgICAgICAgcmV0dXJuIHRocmVhZDsKQEAgLTI2ODksNyArMjcyMSw3IEBACiAgICAgLy8gQ2hlY2sgd2hldGhlciB0aGUgZGVzdGluYXRpb24gdGhyZWFkIGhhcyBhIGNoYW5uZWwgY291bnQgb2YgRkNDXzIsIHdoaWNoIGlzCiAgICAgLy8gY3VycmVudGx5IHJlcXVpcmVkIGZvciAobW9zdCkgZWZmZWN0cy4gUHJldmVudCBtb3ZpbmcgdGhlIGVm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gICAgICAgIGNvbnN0IGludDMyX3QgaW5jID0gKChpbnRWb2x1bWUgPDwgMTYpIC0gKnBJbnRQcmV2Vm9sdW1lKSAvIHJhbXA7CisKKyAgICAgICAgaWYgKGluYyAhPSAwKSB7IC8vIGluYyBtdXN0IG1ha2UgZm9yd2FyZCBwcm9ncmVzcworICAgICAgICAgICAgKnBJbnRWb2x1bWVJbmMgPSBpbmM7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICByYW1wID0gMDsgLy8gcmFtcCBub3QgYWxsb3dlZAorICAgICAgICB9CisgICAgfQorCisgICAgLy8gaWYgbm8gcmFtcCwgb3IgcmFtcCBub3QgYWxsb3dlZCwgdGhlbiBjbGVhciBmbG9hdCBhbmQgaW50ZWdlciBpbmNyZW1lbnRzCisgICAgaWYgKHJhbXAgPT0gMCkgewogICAgICAgICAqcFZvbHVtZUluYyA9IDA7CiAgICAgICAgICpwUHJldlZvbHVtZSA9IG5ld1ZvbHVtZTsKLSAgICAgICAgcmV0dXJuIHRydWU7Ci0gICAgfQotICAgIGlmIChyYW1wICE9IDApIHsKLSAgICAgICAgKnBJbnRWb2x1bWVJbmMgPSAoKGludFZvbHVtZSAtICpwSW50U2V0Vm9sdW1lKSA8PCAxNikgLyByYW1wOwotICAgICAgICAqcEludFByZXZWb2x1bWUgPSAoKnBJbnRWb2x1bWVJbmMgPT0gMCA/IGludFZvbHVtZSA6ICpwSW50U2V0Vm9sdW1lKSA8PCAxNjsKLSAgICB9IGVsc2UgewogICAgICAgICAqcEludFZvbHVtZUluYyA9IDA7CiAgICAgICAgICpwSW50UHJldlZvbHVtZSA9IGludFZvbHVtZSA8PCAxNjsKICAgICB9CisgICAgKnBTZXRWb2x1bWUgPSBuZXdWb2x1bWU7CiAgICAgKnBJbnRTZXRWb2x1bWUgPSBpbnRWb2x1bWU7CiAgICAgcmV0dXJuIHRydWU7CiB9CkBAIC03MDgsMTEgKzc3MywxMCBAQAogICAgICAgICAgICAgICAgIC8vIEZJWE1F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0gICAgICAgICAgICByZXR1cm47Ci0gICAgICAgIGNhc2UgQVVESU9fQ0hBTk5FTF9SRVBSRVNFTlRBVElPTl9JTkRFWDoKLSAgICAgICAgICAgIC8vIFRPRE86IG91dHB1dCBjaGFubmVsIGluZGV4IG1hc2sgbm90IGN1cnJlbnRseSBhbGxvd2VkCi0gICAgICAgICAgICAvLyBmYWxsIHRocm91Z2gKLSAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICB9Ci0gICAgICAgIGJyZWFrOwotICAgIGNhc2UgQVVESU9fQ0hBTk5FTF9SRVBSRVNFTlRBVElPTl9JTkRFWDoKLSAgICAgICAgc3dpdGNoIChvdXRwdXRSZXByZXNlbnRhdGlvbikgewotICAgICAgICBjYXNlIEFVRElPX0NIQU5ORUxfUkVQUkVTRU5UQVRJT05fUE9TSVRJT046Ci0gICAgICAgICAgICBtZW1jcHlfYnlfaW5kZXhfYXJyYXlfaW5pdGlhbGl6YXRpb25fc3JjX2luZGV4KG1JZHhBcnksIEFSUkFZX1NJWkUobUlkeEFyeSksCi0gICAgICAgICAgICAgICAgICAgIG91dHB1dEJpdHMsIGlucHV0Qml0cyk7Ci0gICAgICAgICAgICByZXR1cm47Ci0gICAgICAgIGNhc2UgQVVESU9fQ0hBTk5FTF9SRVBSRVNFTlRBVElPTl9JTkRFWDoKLSAgICAgICAgICAgIC8vIFRPRE86IG91dHB1dCBjaGFubmVsIGluZGV4IG1hc2sgbm90IGN1cnJlbnRseSBhbGxvd2VkCi0gICAgICAgICAgICAvLyBmYWxsIHRocm91Z2gKLSAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICB9Ci0gICAgICAgIGJyZWFrOwotICAgIGRlZmF1bHQ6Ci0gICAgICAgIGJyZWFrOwotICAgIH0KLSAgICBMT0dfQUxXQVlTX0ZBVEFMKCJpbnZhbGlkIGNoYW5uZWwgbWFzayBjb252ZXJzaW9uIGZyb20gJSN4I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CIsCisgICAgICAgIEFVRElPX0RFVklDRV9PVVRfQkxVRVRPT1RIX1NDT19DQVJLSVQsICAgICAgIkJMVUVUT09USF9TQ09fQ0FSS0lUIiwKKyAgICAgICAgQVVESU9fREVWSUNFX09VVF9CTFVFVE9PVEhfQTJEUCwgICAgICAgICAgICAiQkxVRVRPT1RIX0EyRFAiLAorICAgICAgICBBVURJT19ERVZJQ0VfT1VUX0JMVUVUT09USF9BMkRQX0hFQURQSE9ORVMsICJCTFVFVE9PVEhfQTJEUF9IRUFEUEhPTkVTIiwKKyAgICAgICAgQVVESU9fREVWSUNFX09VVF9CTFVFVE9PVEhfQTJEUF9TUEVBS0VSLCAgICAiQkxVRVRPT1RIX0EyRFBfU1BFQUtFUiIsCisgICAgICAgIEFVRElPX0RFVklDRV9PVVRfQVVYX0RJR0lUQUwsICAgICAgICJBVVhfRElHSVRBTCIsCisgICAgICAgIEFVRElPX0RFVklDRV9PVVRfSERNSSwgICAgICAgICAgICAgICJIRE1JIiwKKyAgICAgICAgQVVESU9fREVWSUNFX09VVF9BTkxHX0RPQ0tfSEVBRFNFVCwgIkFOTEdfRE9DS19IRUFEU0VUIiwKKyAgICAgICAgQVVESU9fREVWSUNFX09VVF9ER1RMX0RPQ0tfSEVBRFNFVCwgIkRHVExfRE9DS19IRUFEU0VUIiwKKyAgICAgICAgQVVESU9fREVWSUNFX09VVF9VU0JfQUNDRVNTT1JZLCAgICAgIlVTQl9BQ0NFU1NPUlkiLAorICAgICAgICBBVURJT19ERVZJQ0VfT1VUX1VTQl9ERVZJQ0UsICAgICAgICAiVVNCX0RFVklDRSIsCiAgICAgICAgIEFVRElPX0RFVklDRV9PVVRfVEVMRVBIT05ZX1RYLCAgICAgICJURUxFUEhPTllfVFgiLAorICAgICAgICBBVURJT19ERVZJQ0VfT1VUX0xJTkUsICAgICAgICAgICAgICAiTElORSIsCisgICAgICAgIEFVRElPX0RFVklDRV9PVVRfSERNSV9BUkMsICAgICAgICAgICJIRE1JX0FSQyIsCisgICAgICAgIEFVRElPX0RFVklDRV9PVVRfU1BESUYsICAgICAgICAgICAgICJTUERJRiIsCisgICAgICAgIEFVRElPX0RFVklDRV9PVVRfRk0sICAgICAgICAgICAgICAgICJGTSIsCisgICAgICAgIEFVRElPX0RFVklDRV9PVVRfQVVYX0xJTkUsICAgICAgICAgICJBVVhfTElORSIsCisgICAgICAgIEFVRElPX0RFVklDRV9PVVRfU1BFQUtFUl9TQUZFLCAgICAgICJTUEVBS0VSX1NBRkUiLAogICAgICAgICBBVURJT19ERVZJQ0VfTk9ORSwgICAgICAgICAgICAgICAgICAiTk9ORSIsICAgICAgICAgLy8gbXVzdCBiZSBsYXN0CiAgICAgfSwgbWFwcGluZ3NJbltdID0geworICAgICAgICBBVURJT19ERVZJQ0VfSU5fQ09NTVVOSUNBVElPTiwgICAgICAiQ09NTVVOSUNBVElPTiIsCisgICAgICAgIEFVRElPX0RFVklDRV9JTl9BTUJJRU5ULCAgICAgICAgICAgICJBTUJJRU5UIiwKICAgICAgICAgQVVESU9fREVWSUNFX0lOX0JVSUxUSU5fTUlDLCAgICAgICAgIkJVSUxUSU5fTUlDIiwKKyAgICAgICAgQVVESU9fREVWSUNFX0lOX0JMVUVUT09USF9TQ09fSEVBRFNFVCwgICJCTFVFVE9PVEhfU0NPX0hFQURTRVQiLAogICAgICAgICBBVURJT19ERVZJQ0VfSU5fV0lSRURfSEVBRFNFVCwgICAgICAiV0lSRURfSEVBRFNFVCIsCisgICAgICAgIEFVRElPX0RFVklDRV9JTl9BVVhfRElHSVRBTCwgICAgICAgICJBVVhfRElHSVRBTCIsCiAgICAgICAgIEFVRElPX0RFVklDRV9JTl9WT0lDRV9DQUxMLCAgICAgICAgICJWT0lDRV9DQUxMIiwKKyAgICAgICAgQVVESU9fREVWSUNFX0lOX1RFTEVQSE9OWV9SWCwgICAgICAgIlRFTEVQSE9OWV9SWCIsCisgICAgICAgIEFVRElPX0RFVklDRV9JTl9CQUNLX01JQywgICAgICAgICAgICJCQUNLX01JQyIsCiAgICAgICAgIEFVRElPX0RFVklDRV9JTl9SRU1PVEVfU1VCTUlYLCAgICAgICJSRU1PVEVfU1VCTUlYIiwKKyAgICAgICAgQVVESU9fREVWSUNFX0lOX0FOTEdfRE9DS19IRUFEU0VULCAgIkFOTEdfRE9DS19IRUFEU0VUIiwKKyAgICAgICAgQVVESU9fREVWSUNFX0lOX0RHVExfRE9DS19IRUFEU0VULCAgIkRHVExfRE9DS19IRUFEU0VUIiwKKyAgICAgICAgQVVESU9fREVWSUNFX0lOX1VTQl9BQ0NFU1NPUlksICAgICAgIlVTQl9BQ0NFU1NPUlkiLAorICAgICAgICBBVURJT19ERVZJQ0VfSU5fVVNCX0RFVklDRSwgICAgICAgICAiVVNCX0RFVklDRSIsCisgICAgICAgIEFVRElPX0RFVklDRV9JTl9GTV9UVU5FUiwgICAgICAgICAgICJGTV9UVU5FUiIsCisgICAgICAgIEFVRElPX0RFVklDRV9JTl9UVl9UVU5FUiwgICAgICAgICAgICJUVl9UVU5FUiIsCisgICAgICAgIEFVRElPX0RFVklDRV9JTl9MSU5FLCAgICAgICAgICAgICAgICJMSU5FIiwKKyAgICAgICAgQVVESU9fREVWSUNFX0lOX1NQRElGLCAgICAgICAgICAgICAgIlNQRElGIiwKKyAgICAgICAgQVVESU9fREVWSUNFX0lOX0JMVUVUT09USF9BMkRQLCAgICAgIkJMVUVUT09USF9BMkRQIiwKKyAgICAgICAgQVVESU9fREVWSUNFX0lOX0xPT1BCQUNLLCAgICAgICAgICAgIkxPT1BCQUNLIiwKICAgICAgICAgQVVESU9fREVWSUNFX05PTkUsICAgICAgICAgICAgICAgICAgIk5PTkUiLCAgICAgICAgIC8vIG11c3QgYmUgbGFzdAogICAgIH07CiAgICAgU3RyaW5nOCByZXN1bHQ7CkBAIC00ODcsNyArNTIxLDcgQEAKIH0KIAogQXVkaW9GbGluZ2VyOjpUaHJlYWRCYXNlOjpUaHJlYWRCYXNlKGNvbnN0IHNwPEF1ZGlvRmxpbmdlc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SUNFX1VQTElOSykgcy5hcHBlbmQoInZvaWNlLXVwbGluaywgIik7Ci0gICAgICAgIGlmIChtYXNrICYgQVVESU9fQ0hBTk5FTF9JTl9WT0lDRV9ETkxJTkspIHMuYXBwZW5kKCJ2b2ljZS1kbmxpbmssICIpOwotICAgICAgICBpZiAobWFzayAmIH5BVURJT19DSEFOTkVMX0lOX0FMTCkgcy5hcHBlbmQoInVua25vd24sICAiKTsKKyAgICBjb25zdCBhdWRpb19jaGFubmVsX3JlcHJlc2VudGF0aW9uX3QgcmVwcmVzZW50YXRpb24gPQorICAgICAgICAgICAgYXVkaW9fY2hhbm5lbF9tYXNrX2dldF9yZXByZXNlbnRhdGlvbihtYXNrKTsKKworICAgIHN3aXRjaCAocmVwcmVzZW50YXRpb24pIHsKKyAgICBjYXNlIEFVRElPX0NIQU5ORUxfUkVQUkVTRU5UQVRJT05fUE9TSVRJT046IHsKKyAgICAgICAgaWYgKG91dHB1dCkgeworICAgICAgICAgICAgaWYgKG1hc2sgJiBBVURJT19DSEFOTkVMX09VVF9GUk9OVF9MRUZUKSBzLmFwcGVuZCgiZnJvbnQtbGVmdCwgIik7CisgICAgICAgICAgICBpZiAobWFzayAmIEFVRElPX0NIQU5ORUxfT1VUX0ZST05UX1JJR0hUKSBzLmFwcGVuZCgiZnJvbnQtcmlnaHQsICIpOworICAgICAgICAgICAgaWYgKG1hc2sgJiBBVURJT19DSEFOTkVMX09VVF9GUk9OVF9DRU5URVIpIHMuYXBwZW5kKCJmcm9udC1jZW50ZXIsICIpOworICAgICAgICAgICAgaWYgKG1hc2sgJiBBVURJT19DSEFOTkVMX09VVF9MT1dfRlJFUVVFTkNZKSBzLmFwcGVuZCgibG93IGZyZXEsICIpOworICAgICAgICAgICAgaWYgKG1hc2sgJiBBVURJT19DSEFOTkVMX09VVF9CQUNLX0xFRlQpIHMuYXBwZW5kKCJiYWNrLWxlZnQsICIpOworICAgICAgICAgICAgaWYgKG1hc2sgJiBBVURJT19DSEFOTkVMX09VVF9CQUNLX1JJR0hUKSBzLmFwcGVuZCgiYmFjay1yaWdodCwgIik7CisgICAgICAgICAgICBpZiAobWFzayAmIEFVRElPX0NIQU5ORUxfT1VUX0ZST05UX0xFRlRfT0ZfQ0VOVEVSKSBzLmFwcGVuZCgiZnJvbnQtbGVmdC1vZi1jZW50ZXIsICIpOworICAgICAgICAgICAgaWYgKG1hc2sgJiBBVURJT19DSEFOTkVMX09VVF9GUk9OVF9SSUdIVF9PRl9DRU5URVIpIHMuYXBwZW5kKCJmcm9udC1yaWdodC1vZi1jZW50ZXIsICIpOworICAgICAgICAgICAgaWYgKG1hc2sgJiBBVURJT19DSEFOTkVMX09VVF9CQUNLX0NFTlRFUikgcy5hcHBlbmQoImJhY2stY2VudGVyLCAiKTsKKyAgICAgICAgICAgIGlmIChtYXNrICYgQVVESU9fQ0hBTk5FTF9PVVRfU0lERV9MRUZUKSBzLmFwcGVuZCgic2lkZS1sZWZ0LCAiKTsKKyAgICAgICAgICAgIGlmIChtYXNrICYgQVVESU9fQ0hBTk5FTF9PVVRfU0lERV9SSUdIVCkgcy5hcHBlbmQoInNpZGUtcmlnaHQsICIpOworICAgICAgICAgICAgaWYgKG1hc2sgJiBBVURJT19DSEFOTkVMX09VVF9UT1BfQ0VOVEVSKSBzLmFwcGVuZCgidG9wLWNlbnRlciAsIik7CisgICAgICAgICAgICBpZiAobWFzayAmIEFVRElPX0NIQU5ORUxfT1VUX1RPUF9GUk9OVF9MRUZUKSBzLmFwcGVuZCgidG9wLWZyb250LWxlZnQsICIpOworICAgICAgICAgICAgaWYgKG1hc2sgJiBBVURJT19DSEFOTkVMX09VVF9UT1BfRlJPTlRfQ0VOVEVSKSBzLmFwcGVuZCgidG9wLWZyb250LWNlbnRlciwgIik7CisgICAgICAgICAgICBpZiAobWFzayAmIEFVRElPX0NIQU5ORUxfT1VUX1RPUF9GUk9OVF9SSUdIVCkgcy5hcHBlbmQoInRvcC1mcm9udC1yaWdodCwgIik7CisgICAgICAgICAgICBp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vICAgICAgUGxheWJhY2sKQEAgLTEzNDUsOCArMTQxOCw5IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb1N0cmVhbU91dCogb3V0cHV0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3QgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19kZXZpY2VzX3QgZGV2aWNlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZV90IHR5cGUpCi0gICAgOiAgIFRocmVhZEJhc2UoYXVkaW9GbGluZ2VyLCBpZCwgZGV2aWNlLCBBVURJT19ERVZJQ0VfTk9ORSwgdHlwZSksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlX3QgdHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgc3lzdGVtUmVhZHkpCisgICAgOiAgIFRocmVhZEJhc2UoYXVkaW9GbGluZ2VyLCBpZCwgZGV2aWNlLCBBVURJT19ERVZJQ0VfTk9ORSwgdHlwZSwgc3lzdGVtUmVhZHkpLAogICAgICAgICBtTm9ybWFsRnJhbWVDb3VudCgwKSwgbVNpbmtCdWZmZXIoTlVMTCksCiAgICAgICAgIG1NaXhlckJ1ZmZlckVuYWJsZWQoQXVkaW9GbGluZ2VyOjprRW5hYmxlRXh0ZW5kZWRQcmVjaXNpb24pLAogICAgICAgICBtTWl4ZXJCdWZmZXIoTlVMTCksCkBAIC0xMzY1LDcgKzE0MzksNyBAQAogICAgICAgICBtTGFzdFdyaXRlVGltZSgwKSwgbU51bVdyaXRlcygwKSwgbU51bURlbGF5ZWRXcml0ZXMoMCksIG1JbldyaXRlKGZhbHNlKSwKICAgICAgICAgbU1peGVyU3RhdHVzKE1JWEVSX0lETEUpLAogICAgICAgICBtTWl4ZXJTdGF0dXNJZ25vcmluZ0Zhc3RUcmFja3MoTUlYRVJfSURMRSksCi0gICAgICAgIHN0YW5kYnlEZWxheShBdWRpb0ZsaW5nZXI6Om1TdGFuZGJ5VGltZUluTnNlY3MpLAorICAgICAgICBtU3RhbmRieURlbGF5TnMoQXVkaW9GbGluZ2VyOjptU3RhbmRieVRpbWVJbk5zZWNzKSwKICAgICAgICAgbUJ5dGVzUmVtYWluaW5nKDApLAogICAgICAgICBtQ3VycmVudFdyaXRlTGVuZ3RoKDApLAogICAgICAgICBtVXNlQXN5bmNXcml0ZShmYWxzZSksCkBAIC0xNTcxLDEwICsxNjQ1LDEyIEBACiAgICAgICAgICAgICApICYmCiAgICAgICAgICAgICAvLyBQQ00gZGF0YQogICAgICAgICAgICAgYXVkaW9faXNfbGluZWFyX3BjbShmb3JtYXQpICYmCi0gICAgICAgICAgICAvLyBpZGVudGljYWwgY2hhbm5lbCBtYXNrIHRvIHNpbmssIG9yIG1vbm8gaW4gYW5kIHN0ZXJlbyBzaW5rCisgICAgICAgICAgICAvLyBUT0RPOiBleHRyYWN0IGFzIGEgZGF0YSBsaWJyYXJ5IGZ1bmN0aW9uIHRoYXQgY2hlY2tzIHRoYXQgYSBjb21wdXRhdGlvbmFsbHkKKyAgICAgICAgICAgIC8vIGV4cGVuc2l2ZSBkb3dubWl4ZXIgaXMgbm90IHJlcXVpcmVkOiBpc0Zhc3RPdXRwdXRDaGFubmVsQ29udmVyc2lvbigpCiAgICAgICAgICAgICAoY2hhbm5lbE1hc2sgPT0gbUNoYW5uZWxNYXNrIHx8Ci0gICAgICAgICAgICAgICAgICAgIChjaGFubmVsTWFzayA9PSBBVURJT19DSEFOTkVMX09VVF9NT05PICYmCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNoYW5uZWxNYXNrID09IEFVRElPX0NIQU5ORUxfT1VUX1NURVJFTykpICYmCisgICAgICAgICAgICAgICAgICAgIG1DaGFubmVsTWFzayAhPSBB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UikgewogICAgICAgICBzbGVlcFRpbWVTaGlmdCA9IDA7CkBAIC0yNjc3LDE5ICsyNzU4LDI5IEBACiAgICAgICAgICAgICAgICAgaWYgKGV4aXRQZW5kaW5nKCkpIHsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIHJlbGVhc2VXYWtlTG9ja19sKCk7CisgICAgICAgICAgICAgICAgYm9vbCByZWxlYXNlZCA9IGZhbHNlOworICAgICAgICAgICAgICAgIC8vIFRoZSBmb2xsb3dpbmcgd29ya3MgYXJvdW5kIGEgYnVnIGluIHRoZSBvZmZsb2FkIGRyaXZlci4gSWRlYWxseSB3ZSB3b3VsZCByZWxlYXNlCisgICAgICAgICAgICAgICAgLy8gdGhlIHdha2UgbG9jayBldmVyeSB0aW1lLCBidXQgdGhhdCBjYXVzZXMgdGhlIGxhc3Qgb2ZmbG9hZCBidWZmZXIocykgdG8gYmUKKyAgICAgICAgICAgICAgICAvLyBkcm9wcGVkIHdoaWxlIHRoZSBkZXZpY2UgaXMgb24gYmF0dGVyeSwgc28gd2UgbmVlZCB0byBob2xkIGEgd2FrZSBsb2NrIGR1cmluZworICAgICAgICAgICAgICAgIC8vIHRoZSBkcmFpbiBwaGFzZS4KKyAgICAgICAgICAgICAgICBpZiAobUJ5dGVzUmVtYWluaW5nICYmICEobURyYWluU2VxdWVuY2UgJiAxKSkgeworICAgICAgICAgICAgICAgICAgICByZWxlYXNlV2FrZUxvY2tfbCgpOworICAgICAgICAgICAgICAgICAgICByZWxlYXNlZCA9IHRydWU7CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIG1XYWtlTG9ja1VpZHMuY2xlYXIoKTsKICAgICAgICAgICAgICAgICBtQWN0aXZlVHJhY2tzR2VuZXJhdGlvbisrOwogICAgICAgICAgICAgICAgIEFMT0dWKCJ3YWl0IGFzeW5jIGNvbXBsZXRpb24iKTsKICAgICAgICAgICAgICAgICBtV2FpdFdvcmtDVi53YWl0KG1Mb2NrKTsKICAgICAgICAgICAgICAgICBBTE9HVigiYXN5bmMgY29tcGxldGlvbi93YWtlIik7Ci0gICAgICAgICAgICAgICAgYWNxdWlyZVdha2VMb2NrX2woKTsKLSAgICAgICAgICAgICAgICBzdGFuZGJ5VGltZSA9IHN5c3RlbVRpbWUoKSArIHN0YW5kYnlEZWxheTsKLSAgICAgICAgICAgICAgICBzbGVlcFRpbWUgPSAwOworICAgICAgICAgICAgICAgIGlmIChyZWxlYXNlZCkgeworICAgICAgICAgICAgICAgICAgICBhY3F1aXJlV2FrZUxvY2tfbCgpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBtU3RhbmRieVRpbWVOcyA9IHN5c3RlbVRpbWUoKSArIG1TdGFuZGJ5RGVsYXlOczsKKyAgICAgICAgICAgICAgICBtU2xlZXBUaW1lVXMgPSAwOwogCiAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBpZiAoKCFtQWN0aXZlVHJhY2tzLnNpemUoKSAmJiBzeXN0ZW1UaW1lKCkgPiBzdGFuZGJ5VGltZSkgfHwKKyAgICAgICAgICAgIGlmICgoIW1BY3RpdmVUcmFja3Muc2l6ZSgpICYmIHN5c3RlbVRpbWUoKSA+IG1TdGFuZGJ5VGltZU5zKSB8fAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1N1c3BlbmRlZCgpKSB7CiAgICAgICAgICAgICAgICAgLy8gcHV0IGF1ZGlvIGhhcmR3YXJlIGludG8gc3RhbmRieSBhZnRlciBzaG9ydCBkZWxheQogICAgICAgICAgICAgICAgIGlmIChzaG91bGRTdGFuZGJ5X2woKSkgewpAQCAtMjcyNCw4ICsyODE1LDggQEAKICAgICAgICAgICAgICAgICAgICAgbUJ5dGVzUmVtYWluaW5nID0gMDsKICAgICAgICAgICAgICAgICAgICAgY2hlY2tTaWxlbnRNb2RlX2woKTsKIAotICAgICAgICAgICAgICAgICAgICBzdGFuZGJ5VGltZSA9IHN5c3RlbVRpbWUoKSArIHN0YW5kYnlEZWxheTsKLSAgICAgICAgICAgICAgICAgICAgc2xlZXBUaW1lID0gaWRsZVNsZWVwVGltZTsKKyAgICAgICAgICAgICAgICAgICAgbVN0YW5kYnlUaW1lTnMgPSBzeXN0ZW1UaW1lKCkgKyBtU3RhbmRieURlbGF5TnM7CisgICAgICAgICAgICAgICAgICAgIG1TbGVlcFRpbWVVcyA9IG1JZGxlU2xlZXBUaW1lVXM7CiAgICAgICAgICAgICAgICAgICAgIGlmIChtVHlwZSA9PSBNSVhFUikgewogICAgICAgICAgICAgICAgICAgICAgICAgc2xlZXBUaW1lU2hpZnQgPSAwOwogICAgICAgICAgICAgICAgICAgICB9CkBAIC0yNzU2LDE1ICsyODQ3LDE1IEBACiAgICAgICAgICAgICAgICAgdGhyZWFkTG9vcF9taXgoKTsKICAgICAgICAgICAgIH0gZWxzZSBpZiAoKG1NaXhlclN0YXR1cyAhPSBNSVhFUl9EUkFJTl9UUkFDSykKICAgICAgICAgICAgICAgICAgICAgICAgICYmIChtTWl4ZXJTdGF0dXMgIT0gTUlYRVJfRFJBSU5fQUxMKSkgewotICAgICAgICAgICAgICAgIC8vIHRocmVhZExvb3Bfc2xlZXBUaW1lIHNldHMgc2xlZXBUaW1lIHRvIDAgaWYgZGF0YQorICAgICAgICAgICAgICAgIC8vIHRocmVhZExvb3Bfc2xlZXBUaW1lIHNldHMgbVNsZWVwVGltZVVzIHRvIDAgaWYgZGF0YQogICAgICAgICAgICAgICAgIC8vIG11c3QgYmUgd3JpdHRlbiB0byBIQUwKICAgICAgICAgICAgICAgICB0aHJlYWRMb29wX3NsZWVwVGltZSgpOwotICAgICAgICAgICAgICAgIGlmIChzbGVlcFRpbWUgPT0gMCkgeworICAgICAgICAgICAgICAgIGlmIChtU2xlZXBUaW1lVXMgPT0gMCkgewogICAgICAgICAgICAgICAgICAgICBtQ3VycmVudFdyaXRlTGVuZ3RoID0gbVN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SAwIG1lYW5zIHdlIG11c3Qgd3JpdGUgdG8gYXVkaW8gaGFyZHdhcmUKKyAgICAgICAgICAgIGlmIChtU2xlZXBUaW1lVXMgPT0gMCkgeworICAgICAgICAgICAgICAgIHNzaXplX3QgcmV0ID0gMDsKICAgICAgICAgICAgICAgICBpZiAobUJ5dGVzUmVtYWluaW5nKSB7Ci0gICAgICAgICAgICAgICAgICAgIHNzaXplX3QgcmV0ID0gdGhyZWFkTG9vcF93cml0ZSgpOworICAgICAgICAgICAgICAgICAgICByZXQgPSB0aHJlYWRMb29wX3dyaXRlKCk7CiAgICAgICAgICAgICAgICAgICAgIGlmIChyZXQgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBtQnl0ZXNSZW1haW5pbmcgPSAwOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewpAQCAtMjgzNCwxMSArMjkyNiwxMSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgKG1NaXhlclN0YXR1cyA9PSBNSVhFUl9EUkFJTl9BTEwpKSB7CiAgICAgICAgICAgICAgICAgICAgIHRocmVhZExvb3BfZHJhaW4oKTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgaWYgKG1UeXBlID09IE1JWEVSKSB7CisgICAgICAgICAgICAgICAgaWYgKG1UeXBlID09IE1JWEVSICYmICFtU3RhbmRieSkgewogICAgICAgICAgICAgICAgICAgICAvLyB3cml0ZSBibG9ja2VkIGRldGVjdGlvbgogICAgICAgICAgICAgICAgICAgICBuc2Vjc190IG5vdyA9IHN5c3RlbVRpbWUoKTsKICAgICAgICAgICAgICAgICAgICAgbnNlY3NfdCBkZWx0YSA9IG5vdyAtIG1MYXN0V3JpdGVUaW1lOwotICAgICAgICAgICAgICAgICAgICBpZiAoIW1TdGFuZGJ5ICYmIGRlbHRhID4gbWF4UGVyaW9kKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChkZWx0YSA+IG1heFBlcmlvZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgbU51bURlbGF5ZWRXcml0ZXMrKzsKICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgobm93IC0gbGFzdFdhcm5pbmcpID4ga1dhcm5pbmdUaHJvdHRsZU5zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQVRSQUNFX05BTUUoInVuZGVycnVuIik7CkBAIC0yODQ3LDExICsyOTM5LDM2IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFdhcm5pbmcgPSBub3c7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgICAgICBpZiAobVRocmVhZFRocm90dGxlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgbU1peGVyU3RhdHVzID09IE1JWEVSX1RSQUNLU19SRUFEWSAvLyB3ZSBhcmUgbWl4aW5nIChhY3RpdmUgdHJhY2tzKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICYmIHJldCA+IDApIHsgICAgICAgICAgICAgICAgICAgICAgICAgLy8gd2Ugd3JvdGUgc29tZXRoaW5nCisgICAgICAgICAgICAgICAgICAgICAgICAvLyBMaW1pdCBNaXhlclRocmVhZCBkYXRhIHByb2Nlc3NpbmcgdG8gbm8gbW9yZSB0aGFuIHR3aWNlIHRoZQorICAgICAgICAgICAgICAgICAgICAgICAgLy8gZXhwZWN0ZWQgcHJvY2Vzc2luZyByYXRlLgorICAgICAgICAgICAgICAgICAgICAgICAgLy8KKyAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRoaXMgaGVscHMgcHJldmVudCB1bmRlcnJ1bnMgd2l0aCBOdVBsYXllciBhbmQgb3RoZXIgYXBwbGljYXRpb25zCisgICAgICAgICAgICAgICAgICAgICAgICAvLyB3aGljaCBtYXkgc2V0IHVwIGJ1ZmZlcnMgdGhhdCBhcmUgY2xvc2UgdG8gdGhlIG1pbmltdW0gc2l6ZSwgb3IgdXNlCisgICAgICAgICAgICAgICAgICAgICAgICAvLyBkZWVwIGJ1ZmZlcnMsIGFuZCByZWx5IG9uIGEgZG91YmxlLWJ1ZmZlcmluZyBzbGVlcCBzdHJhdGVneSB0byBmaWxsLgorICAgICAgICAgICAgICAgICAgICAgICAgLy8KKyAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRoZSB0aHJvdHRsZSBzbW9vdGhzIG91dCBzdWRkZW4gbGFyZ2UgZGF0YSBkcmFpbnMgZnJvbSB0aGUgZGV2aWNlLAorICAgICAgICAgICAgICAgICAgICAgICAgLy8gZS5nLiB3aGVuIGl0IGNvbWVzIG91dCBvZiBzdGFuZGJ5LCB3aGljaCBvZnRlbiBjYXVzZXMgcHJvYmxlbXMgd2l0aAorICAgICAgICAgICAgICAgICAgICAgICAgLy8gKDEpIG1peGVyIHRocmVhZHMgd2l0aG91dCBhIGZhc3QgbWl4ZXIgKHdoaWNoIGhhcyBpdHMgb3duIHdhcm0tdXApCisgICAgICAgICAgICAgICAgICAgICAgICAvLyAoMikgbWluaW11bSBidWZmZXIgc2l6ZWQgdHJhY2tzIChldmVuIGlmIHRoZSB0cmFjayBpcyBmdWxsLAorICAgICAgICAgICAgICAgICAgICAgICAgLy8gICAgIHRoZSBhcHAgd29uJ3QgZmlsbCBmYXN0IGVub3VnaCB0byBoYW5kbGUgdGhlIHN1ZGRlbiBkcmF3KS4KKworICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50MzJfdCBkZWx0YU1zID0gZGVsdGEgLyAxMDAwMDAwOworICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50MzJfdCB0aHJvdHRsZU1zID0gbUhhbGZCdWZmZXJNcyAtIGRlbHRhTXM7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKHNpZ25lZCltSGFsZkJ1ZmZlck1zID49IHRocm90dGxlTXMgJiYgdGhyb3R0bGVNcyA+IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2xlZXAodGhyb3R0bGVNcyAqIDEwMDApOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dEKCJtaXhlciglcCkgdGhyb3R0bGU6IHJldCglemQpIGRlbHRhTXMoJWQpIHJlcXVpcmVzIHNsZWVwICVkIG1zIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMsIHJldCwgZGVsdGFNcywgdGhyb3R0bGVNcyk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgQVRSQUNFX0JFR0lOKCJzbGVlcCIpOwotICAgICAgICAgICAgICAgIHVzbGVlcChzbGVlcFRpbWUpOworICAgICAgICAgICAgICAgIHVzbGVlcChtU2xlZXBUaW1lVXMpOwogICAgICAgICAgICAgICAgIEFUUkFDRV9FTkQoKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQpAQCAtMzAwMiw2ICszMTE5LDcgQEAKICAgICAgICAgbUVmZmVjdENoYWluc1tpXS0+c2V0RGV2aWNlX2wodHlwZSk7CiAgICAgfQogICAgIG1PdXREZXZpY2UgPSB0eXBlOworICAgIG1QYXRjaCA9ICpwYXRjaDsKIAogICAgIGlmIChtT3V0cHV0LT5hdWRpb0h3RGV2LT52ZXJzaW9uKCkgPj0gQVVESU9fREVWSUNFX0FQSV9WRVJTSU9OXzNfMCkgewogICAgICAgICBhdWRpb19od19kZXZpY2VfdCAqaHdEZXZpY2UgPSBtT3V0cHV0LT5hdWRpb0h3RGV2LT5od0RldmljZSgpOwpAQCAtMzAyOCw2ICszMTQ2LDcgQEAKICAgICAgICAgICAgICAgICBwYXJhbS50b1N0cmluZygpLnN0cmluZygpKTsKICAgICAgICAgKmhhbmRsZSA9IEFVRElPX1BBVENIX0hBTkRMRV9OT05FOwogICAgIH0KKyAgICBzZW5kSW9Db25maWdFdmVudF9sKEFVRElPX09VVFBVVF9DT05GSUdfQ0hBTkdFRCk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wKICAgICAgICAgQXVkaW9TdHJlYW1PdXQqIG91dHB1dCwgYXVkaW9faW9faGFuZGxlX3QgaWQsIHVpbnQzMl90IGRldmljZSwKLSAgICAgICAgVGhyZWFkQmFzZTo6dHlwZV90IHR5cGUpCi0gICAgOiAgIFBsYXliYWNrVGhyZWFkKGF1ZGlvRmxpbmdlciwgb3V0cHV0LCBpZCwgZGV2aWNlLCB0eXBlKQorICAgICAgICBUaHJlYWRCYXNlOjp0eXBlX3QgdHlwZSwgYm9vbCBzeXN0ZW1SZWFkeSkKKyAgICA6ICAgUGxheWJhY2tUaHJlYWQoYXVkaW9GbGluZ2VyLCBvdXRwdXQsIGlkLCBkZXZpY2UsIHR5cGUsIHN5c3RlbVJlYWR5KQogICAgICAgICAvLyBtTGVmdFZvbEZsb2F0LCBtUmlnaHRWb2xGbG9hdAogewogfQpAQCAtNDQyOSw3ICs0NTQyLDcgQEAKICAgICAgICAgICAgICAgICB0cmFjay0+bVJldHJ5Q291bnQgPSBrTWF4VHJhY2tSZXRyaWVzRGlyZWN0OwogICAgICAgICAgICAgICAgIG1BY3RpdmVUcmFjayA9IHQ7CiAgICAgICAgICAgICAgICAgbWl4ZXJTdGF0dXMgPSBNSVhFUl9UUkFDS1NfUkVBRFk7Ci0gICAgICAgICAgICAgICAgaWYgKHVzZXNId0F2U3luYygpICYmIG1Id1BhdXNlZCkgeworICAgICAgICAgICAgICAgIGlmIChtSHdQYXVzZWQpIHsKICAgICAgICAgICAgICAgICAgICAgZG9Id1Jlc3VtZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgIG1Id1BhdXNlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgIH0KQEAgLTQ0ODEsNyArNDU5NCw3IEBACiAgICAgICAgICAgICAgICAgICAgIGFuZHJvaWRfYXRvbWljX29yKENCTEtfRElTQUJMRUQsICZjYmxrLT5tRmxhZ3MpOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobGFzdCkgewogICAgICAgICAgICAgICAgICAgICBtaXhlclN0YXR1cyA9IE1JWEVSX1RSQUNLU19FTkFCTEVEOwotICAgICAgICAgICAgICAgICAgICBpZiAodXNlc0h3QXZTeW5jKCkgJiYgIW1Id1BhdXNlZCAmJiAhbVN0YW5kYnkpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1Id1N1cHBvcnRzUGF1c2UgJiYgIW1Id1BhdXNlZCAmJiAhbVN0YW5kYnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGRvSHdQYXVzZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICBtSHdQYXVzZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICB9CkBAIC00NTM5LDggKzQ2NTIsOCBAQAogICAgICAgICBtQWN0aXZlVHJhY2stPnJlbGVhc2VCdWZmZXIoJmJ1ZmZlcik7CiAgICAgfQogICAgIG1DdXJyZW50V3JpdGVMZW5ndGggPSBjdXJCdWYgLSAoaW50OF90ICopbVNpbmtCdWZmZXI7Ci0gICAgc2xlZXBUaW1lID0gMDsKLSAgICBzdGFuZGJ5VGltZSA9IHN5c3RlbVRpbWUoKSArIHN0YW5kYnlEZWxheTsKKyAgICBtU2xlZXBUaW1lVXMgPSAwOworICAgIG1TdGFuZGJ5VGltZU5zID0gc3lzdGVtVGltZSgpICsgbVN0YW5kYnlEZWxheU5zOwogICAgIG1BY3RpdmVUcmFjay5jbGVhcigpOwogfQogCkBAIC00NTQ4LDE4ICs0NjYxLDE4IEBACiB7CiAgICAgLy8gZG8gbm90IHdyaXRlIHRvIEhBTCB3aGVuIHBhdXNlZAogICAgIGlmIChtSHdQYXVzZWQgfHwgKHVzZXNId0F2U3luYygpICYmIG1TdGFuZGJ5KSkgewotICAgICAgICBzbGVlcFRpbWUgPSBpZGxlU2xlZXBUaW1lOworICAgICAgICBtU2xlZXBUaW1lVXMgPSBtSWRsZVNsZWVwVGltZVVzOwogICAgICAgICByZXR1cm47CiAgICAgfQotICAgIGlmIChzbGVlcFRpbWU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IGRldmljZSkKLSAgICA6ICAgRGlyZWN0T3V0cHV0VGhyZWFkKGF1ZGlvRmxpbmdlciwgb3V0cHV0LCBpZCwgZGV2aWNlLCBPRkZMT0FEKSwKKyAgICAgICAgQXVkaW9TdHJlYW1PdXQqIG91dHB1dCwgYXVkaW9faW9faGFuZGxlX3QgaWQsIHVpbnQzMl90IGRldmljZSwgYm9vbCBzeXN0ZW1SZWFkeSkKKyAgICA6ICAgRGlyZWN0T3V0cHV0VGhyZWFkKGF1ZGlvRmxpbmdlciwgb3V0cHV0LCBpZCwgZGV2aWNlLCBPRkZMT0FELCBzeXN0ZW1SZWFkeSksCiAgICAgICAgIG1QYXVzZWRCeXRlc1JlbWFpbmluZygwKQogewogICAgIC8vRklYTUU6IG1TdGFuZGJ5IHNob3VsZCBiZSBzZXQgdG8gdHJ1ZSBieSBUaHJlYWRCYXNlIGNvbnN0cnVjdG9yCkBAIC00ODg0LDcgKzQ5OTcsNyBAQAogICAgICAgICBpZiAodHJhY2stPmlzUGF1c2luZygpKSB7CiAgICAgICAgICAgICB0cmFjay0+c2V0UGF1c2VkKCk7CiAgICAgICAgICAgICBpZiAobGFzdCkgewotICAgICAgICAgICAgICAgIGlmICghbUh3UGF1c2VkKSB7CisgICAgICAgICAgICAgICAgaWYgKG1Id1N1cHBvcnRzUGF1c2UgJiYgIW1Id1BhdXNlZCkgewogICAgICAgICAgICAgICAgICAgICBkb0h3UGF1c2UgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICBtSHdQYXVzZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgIH0KQEAgLTQ5MjAsNyArNTAzMyw3IEBACiAgICAgICAgICAgICAgICAgICAgIC8vIHJlc3VtZSBhbiBpbnRlcnJ1cHRlZCB3cml0ZQogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAvLyBlbmFibGUgd3JpdGUgdG8gYXVkaW8gSEFMCi0gICAgICAgICAgICAgICAgc2xlZXBUaW1lID0gMDsKKyAgICAgICAgICAgICAgICBtU2xlZXBUaW1lVXMgPSAwOwogCiAgICAgICAgICAgICAgICAgLy8gRG8gbm90IGhhbmRsZSBuZXcgZGF0YSBpbiB0aGlzIGl0ZXJhdGlvbiBldmVuIGlmIHRyYWNrLT5mcmFtZXNSZWFkeSgpCiAgICAgICAgICAgICAgICAgbWl4ZXJTdGF0dXMgPSBNSVhFUl9UUkFDS1NfRU5BQkxFRDsKQEAgLTQ5ODAsOCArNTA5Myw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBkbyBub3QgbW9kaWZ5IGRyYWluIHNlcXVlbmNlIGlmIHdlIGFyZSBhbHJlYWR5IGRyYWluaW5nLiBUaGlzIGhhcHBlbnMKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHdoZW4gcmVzdW1pbmcgZnJvbSBwYXVzZSBhZnRlciBkcmFpbi4KICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgobURyYWluU2VxdWVuY2UgJiAxKSA9PSAwKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2xlZXBUaW1lID0gMDsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFuZGJ5VGltZSA9IHN5c3RlbVRpbWUoKSArIHN0YW5kYnlEZWxheTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtU2xlZXBUaW1lVXMgPSAwOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1TdGFuZGJ5VGltZU5zID0gc3lzdGVtVGltZSgpICsgbVN0YW5kYnlEZWxheU5zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1peGVyU3RhdHVzID0gTUlYRVJfRFJBSU5fVFJBQ0s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbURyYWluU2VxdWVuY2UgKz0gMjsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KQEAgLTUwOTYsOSArNTIwOSw5IEBACiAvLyAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tL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gbVN0YW5kYnlEZWxheU5zOwogfQogCiB2b2lkIEF1ZGlvRmxpbmdlcjo6RHVwbGljYXRpbmdUaHJlYWQ6OnRocmVhZExvb3Bfc2xlZXBUaW1lKCkKIHsKLSAgICBpZiAoc2xlZXBUaW1lID09IDApIHsKKyAgICBpZiAobVNsZWVwVGltZVVzID09IDApIHsKICAgICAgICAgaWYgKG1NaXhlclN0YXR1cyA9PSBNSVhFUl9UUkFDS1NfRU5BQkxFRCkgewotICAgICAgICAgICAgc2xlZXBUaW1lID0gYWN0aXZlU2xlZXBUaW1lOworICAgICAgICAgICAgbVNsZWVwVGltZVVzID0gbUFjdGl2ZVNsZWVwVGltZVVzOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgc2xlZXBUaW1lID0gaWRsZVNsZWVwVGltZTsKKyAgICAgICAgICAgIG1TbGVlcFRpbWVVcyA9IG1JZGxlU2xlZXBUaW1lVXM7CiAgICAgICAgIH0KICAgICB9IGVsc2UgaWYgKG1CeXRlc1dyaXR0ZW4gIT0gMCkgewogICAgICAgICBpZiAobU1peGVyU3RhdHVzID09IE1JWEVSX1RSQUNLU19FTkFCTEVEKSB7CkBAIC01MTQ1LDcgKzUyNTgsNyBAQAogICAgICAgICAgICAgLy8gZmx1c2ggcmVtYWluaW5nIG92ZXJmbG93IGJ1ZmZlcnMgaW4gb3V0cHV0IHRyYWNrcwogICAgICAgICAgICAgd3JpdGVGcmFtZXMgPSAwOwogICAgICAgICB9Ci0gICAgICAgIHNsZWVwVGltZSA9IDA7CisgICAgICAgIG1TbGVlcFRpbWVVcyA9IDA7CiAgICAgfQogfQogCkBAIC01MjExLDEwICs1MzI0LDEzIEBACiAgICAgICAgICAgICBtT3V0cHV0VHJhY2tzW2ldLT5kZXN0cm95KCk7CiAgICAgICAgICAgICBtT3V0cHV0VHJhY2tzLnJlbW92ZUF0KGkpOwogICAgICAgICAgICAgdXBkYXRlV2FpdFRpbWVfbCgpOworICAgICAgICAgICAgaWYgKHRocmVhZC0+Z2V0T3V0cHV0KCkgPT0gbU91dHB1dCkgeworICAgICAgICAgICAgICAgIG1PdXRwdXQgPSBOVUxMOworICAgICAgICAgICAgfQogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CiAgICAgfQotICAgIEFMT0dWKCJyZW1vdmVPdXRwdXRUcmFjaygpOiB1bmtvbnduIHRocmVhZDogJXAiLCB0aHJlYWQpOworICAgIEFMT0dWKCJyZW1vdmVPdXRwdXRUcmFjaygpOiB1bmtub3duIHRocmVhZDogJXAiLCB0aHJlYWQpOwogfQogCiAvLyBjYWxsZXIgbXVzdCBob2xkIG1Mb2NrCkBAIC01Mjc1LDEyICs1MzkxLDEzIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvU3RyZWFtSW4gKmlucHV0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19pb19oYW5kbGVfdCBpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fZGV2aWNlc190IG91dERldmljZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fZGV2aWNlc190IGluRGV2aWNlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2RldmljZXNfdCBpbkRldmljZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBzeXN0ZW1SZWFkeQogI2lmZGVmIFRFRV9TSU5LCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICwgY29uc3Qgc3A8TkJBSU9fU2luaz4mIHRlZVNpbmsKICNlbmRpZgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApIDoKLSAgICBUaHJlYWRCYXNlKGF1ZGlvRmxpbmdlciwgaWQsIG91dERldmljZSwgaW5EZXZpY2UsIFJFQ09SRCksCisgICA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ubmVsX21hc2tfZm9yX2luZGV4X2Fzc2lnbm1lbnRfZnJvbV9jb3VudChtQ2hhbm5lbENvdW50KTsKLSAgICB9CiAKICAgICBBdWRpb1BhcmFtZXRlciBwYXJhbSA9IEF1ZGlvUGFyYW1ldGVyKGtleVZhbHVlUGFpcik7CiAgICAgaW50IHZhbHVlOwpAQCAtNjY5MSw5ICs2ODAzLDcgQEAKICAgICAgICAgICAgICAgICAobUlucHV0LT5zdHJlYW0tPmNvbW1vbi5nZXRfc2FtcGxlX3JhdGUoJm1JbnB1dC0+c3RyZWFtLT5jb21tb24pCiAgICAgICAgICAgICAgICAgICAgICAgICA8PSAoQVVESU9fUkVTQU1QTEVSX0RPV05fUkFUSU9fTUFYICogc2FtcGxpbmdSYXRlKSkgJiYKICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX2NvdW50X2Zyb21faW5fbWFzaygKLSAgICAgICAgICAgICAgICAgICAgICAgIG1JbnB1dC0+c3RyZWFtLT5jb21tb24uZ2V0X2NoYW5uZWxzKCZtSW5wdXQtPnN0cmVhbS0+Y29tbW9uKSkgPD0gRkNDXzIgJiYKLSAgICAgICAgICAgICAgICAoY2hhbm5lbE1hc2sgPT0gQVVESU9fQ0hBTk5FTF9JTl9NT05PIHx8Ci0gICAgICAgICAgICAgICAgICAgICAgICBjaGFubmVsTWFzayA9PSBBVURJT19DSEFOTkVMX0lOX1NURVJFTykpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1JbnB1dC0+c3RyZWFtLT5jb21tb24uZ2V0X2NoYW5uZWxzKCZtSW5wdXQtPnN0cmVhbS0+Y29tbW9uKSkgPD0gRkNDXzgpIHsKICAgICAgICAgICAgICAgICBzdGF0dXMgPSBOT19FUlJPUjsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gTk9fRVJST1IpIHsKQEAgLTY3MjcsNiArNjgzNyw3IEBACiAgICAgc3dpdGNoIChldmVudCkgewogICAgIGNhc2UgQVVESU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ICAgICAgICAgYm9vbCBpc0R1cGxpY2F0aW5nKCkgY29uc3QgeyByZXR1cm4gKG1UeXBlID09IERVUExJQ0FUSU5HKTsgfQorCiAgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3QgaWQoKSBjb25zdCB7IHJldHVybiBtSWQ7fQogCiAgICAgICAgICAgICAgICAgLy8gZHluYW1pYyBleHRlcm5hbGx5LXZpc2libGUKQEAgLTI1Niw2ICsyNjIsNyBAQAogICAgICAgICAgICAgICAgIHN0YXR1c190ICAgIHNlbmRDb25maWdFdmVudF9sKHNwPENvbmZpZ0V2ZW50PiYgZXZlbnQpOwogICAgICAgICAgICAgICAgIHZvaWQgICAgICAgIHNlbmRJb0NvbmZpZ0V2ZW50KGF1ZGlvX2lvX2NvbmZpZ19ldmVudCBldmVudCk7CiAgICAgICAgICAgICAgICAgdm9pZCAgICAgICAgc2VuZElvQ29uZmlnRXZlbnRfbChhdWRpb19pb19jb25maWdfZXZlbnQgZXZlbnQpOworICAgICAgICAgICAgICAgIHZvaWQgICAgICAgIHNlbmRQcmlvQ29uZmlnRXZlbnQocGlkX3QgcGlkLCBwaWRfdCB0aWQsIGludDMyX3QgcHJpbyk7CiAgICAgICAgICAgICAgICAgdm9pZCAgICAgICAgc2VuZFByaW9Db25maWdFdmVudF9sKHBpZF90IHBpZCwgcGlkX3QgdGlkLCBpbnQzMl90IHByaW8pOwogICAgICAgICAgICAgICAgIHN0YXR1c190ICAgIHNlbmRTZXRQYXJhbWV0ZXJDb25maWdFdmVudF9sKGNvbnN0IFN0cmluZzgmIGtleVZhbHVlUGFpcik7CiAgICAgICAgICAgICAgICAgc3RhdHVzX3QgICAgc2VuZENyZWF0ZUF1ZGlvUGF0Y2hDb25maWdFdmVudChjb25zdCBzdHJ1Y3QgYXVkaW9fcGF0Y2ggKnBhdGNoLApAQCAtMzU3LDYgKzM2NCw4IEBACiAKICAgICAgICAgICAgICAgICB2aXJ0dWFsIHNwPElNZW1vcnk+IHBpcGVNZW1vcnkoKSBjb25zdCB7IHJldHVybiAwOyB9CiAKKyAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQgc3lzdGVtUmVhZHkoKTsKKwogICAgIG11dGFibGUgICAgIE11dGV4ICAgICAgICAgICAgICAgICAgIG1Mb2NrOwogCiBwcm90ZWN0ZWQ6CkBAIC00MTYsNiArNDI1LDcgQEAKICAgICAgICAgICAgICAgICBzaXplX3QgICAgICAgICAgICAgICAgICBtQnVmZmVyU2l6ZTsgICAgICAgLy8gSEFMIGJ1ZmZlciBzaXplIGZvciByZWFkKCkgb3Igd3JpdGUoKQogCiAgICAgICAgICAgICAgICAgVmVjdG9yPCBzcDxDb25maWdFdmVudD4gPiAgICAgbUNvbmZpZ0V2ZW50czsKKyAgICAgICAgICAgICAgICBWZWN0b3I8IHNwPENvbmZpZ0V2ZW50PiA+ICAgICBtUGVuZGluZ0NvbmZpZ0V2ZW50czsgLy8gZXZlbnRzIGF3YWl0aW5nIHN5c3RlbSByZWFkeQogCiAgICAgICAgICAgICAgICAgLy8gVGhlc2UgZmllbGRzIGFyZSB3cml0dGVuIGFuZCByZWFkIGJ5IHRocmVhZCBpdHNlbGYgd2l0aG91dCBsb2NrIG9yIGJhcnJpZXIsCiAgICAgICAgICAgICAgICAgLy8gYW5kIHJlYWQgYnkgb3RoZXIgdGhyZWFkcyB3aXRob3V0IGxvY2sgb3IgYmFycmllciB2aWEgc3RhbmRieSgpLCBvdXREZXZpY2UoKQpAQCAtNDI2LDYgKzQzNiw3IEBACiAgICAgICAgICAgICAgICAgYm9vbCAgICAgICAgICAgICAgICAgICAgbVN0YW5kYnk7ICAgICAvLyBXaGV0aGVyIHRocmVhZCBpcyBjdXJyZW50bHkgaW4gc3RhbmRieS4KICAgICAgICAgICAgICAgICBhdWRpb19kZXZpY2VzX3QgICAgICAgICBtT3V0RGV2aWNlOyAgIC8vIG91dHB1dCBkZXZpY2UKICAgICAgICAgICAgICAgICBhdWRpb19kZXZpY2VzX3QgICAgICAgICBtSW5EZXZpY2U7ICAgIC8vIGlucHV0IGRldmljZQorICAgICAgICAgICAgICAgIHN0cnVjdCBhdWRpb19wYXRjaCAgICAgIG1QYXRjaDsKICAgICAgICAgICAgICAgICBhdWRpb19zb3VyY2VfdCAgICAgICAgICBtQXVkaW9Tb3VyY2U7CiAKICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19pb19oYW5kbGVfdCBtSWQ7CkBAIC00NDIsNiArNDUzLDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtU3VzcGVuZGVkU2Vzc2lvbnM7CiAgICAgICAgICAgICAgICAgc3RhdGljIGNvbnN0IHNpemVfdCAgICAga0xvZ1NpemUgPSA0ICogMTAyNDsKICAgICAgICAgICAgICAgICBzcDxOQkxvZzo6V3JpdGVyPiAgICAgICBtTkJMb2dXcml0ZXI7CisgICAgICAgICAgICAgICAgYm9vbCAgICAgICAgICAgICAgICAgICAgbVN5c3RlbVJlYWR5OwogfTsKIAogLy8gLS0tIFBsYXliYWNrVGhyZWFkIC0tLQpAQCAtNDY3LDcgKzQ3OSw3IEBACiAgICAgc3RhdGljIGNvbnN0IGludDhfdCBrTWF4VHJhY2tSZXRyaWVzT2ZmbG9hZCA9IDIwOwogCiAgICAgUGxheWJhY2tUaHJlYWQoY29uc3Qgc3A8QXVkaW9GbGluZ2VyPiYgYXVkaW9GbGluZ2VyLCBBdWRpb1N0cmVhbU91dCogb3V0cHV0LAotICAgICAgICAgICAgICAgICAgIGF1ZGlvX2lvX2hhbmRsZV90IGlkLCBhdWRpb19kZXZpY2VzX3QgZGV2aWNlLCB0eXBlX3QgdHlwZSk7CisgICAgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3QgaWQsIGF1ZGlvX2RldmljZXNfdCBkZXZpY2UsIHR5cGVfdCB0eXBlLCBib29sIHN5c3RlbVJlYWR5KTsKICAgICB2aXJ0dWFsICAgICAgICAgICAgIH5QbGF5YmFja1RocmVhZCgpOwogCiAgICAgICAgICAgICAgICAgdm9pZCAgICAgICAgZHVtcChpbnQgZmQsIGNvbnN0IFZlY3RvcjxTdHJpbmcxNj4mIGFyZ3MpOwpAQCAtNjAxLDYgKzYxMyw5IEBACiAgICAgLy8gdXBkYXRlZCBieSByZWFkT3V0cHV0UGFyYW1ldGVyc19sKCkKICAgICBzaXplX3QgICAgICAgICAgICAgICAgICAgICAgICAgIG1Ob3JtYWxGcmFtZUNvdW50OyAgLy8gbm9ybWFsIG1peGVyIGFuZCBlZmZlY3RzCiAKKyAgICBib29sICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1UaHJlYWRUaHJvdHRsZTsgICAgIC8vIHRocm90dGxlIHRoZSB0aHJlYWQgcHJvY2Vzc2luZworICAgIHVpbnQzMl90ICAgICAgICAgICAgICAgICAgICAgICAgbUhhbGZCdWZmZXJNczsgICAgICAgLy8gaGFsZiB0aGUgYnVmZmVyIHNpemUgaW4gbWlsbGlzZWNvbmRzCisKICAgICB2b2lkKiAgICAgICAgICAgICAgICAgICAgICAgICAgIG1TaW5rQnVmZmVyOyAgICAgICAgIC8vIGZyYW1lIHNpemUgYWxpZ25lZCBzaW5rIGJ1ZmZlcgogCiAgICAgLy8gVE9ETzoKQEAgLTc0MywxNCArNzU4LDE0IEBACiAgICAgYm9vbCAgICAgICAgICAgICAgICAgICAgICAgICAgICBtSW5Xcml0ZTsKIAogICAgIC8vIEZJWE1FIHJlbmFtZSB0aGVzZSBmb3JtZXIgbG9jYWwgdmFyaWFibGVzIG9mIHRocmVhZExvb3AgdG8gc3RhbmRhcmQgIm0iIG5hbWVzCi0gICAgbnNlY3NfdCAgICAgICAgICAgICAgICAgICAgICAgICBzdGFuZGJ5VGltZTsKKyAgICBuc2Vjc190ICAgICAgICAgICAgICAgICAgICAgICAgIG1TdGFuZGJ5VGltZU5zOwogICAgIHNpemVfdCAgICAgICAgICAgICAgICAgICAgICAgICAgbVNpbmtCdWZmZXJTaXplOwogCiAgICAgLy8gY2FjaGVkIGNvcGllcyBvZiBhY3RpdmVTbGVlcFRpbWVVcygpIGFuZCBpZGxlU2xlZXBUaW1lVXMoKSBtYWRlIGJ5IGNhY2hlUGFyYW1ldGVyc19sKCkKLSAgICB1aW50MzJfdCAgICAgICAgICAgICAgICAgICAgICAgIGFjdGl2ZVNsZWVwVGltZTsKLSAgICB1aW50MzJfdCAgICAgICAgICAgICAgICAgICAgICAgIGlkbGVTbGVlcFRpbWU7CisgICAgdWludDMyX3QgICAgICAgICAgICAgICAgICAgICAgICBtQWN0aXZlU2xlZXBUaW1lVXM7CisgICAgdWludDMyX3QgICAgICAgICAgICAgICAgICAgICAgICBtSWRsZVNsZWVwVGltZVVzOwogCi0gICAgdWludDMyX3QgICAgICAgICAgICAgICAgICAgICAgICBzbGVlcFRpbWU7CisgICAgdWludDMyX3QgICAgICAgICAgICAgICAgICAgICAgICBtU2xlZXBUaW1lVXM7CiAKICAgICAvLyBtaXhlciBzdGF0dXMgcmV0dXJuZWQgYnkgcHJlcGFyZVRyYWNrc19sKCkKICAgICBtaXhlcl9zdGF0ZSAgICAgICAgICAgICAgICAgICAgIG1NaXhlclN0YXR1czsgLy8gY3VycmVudCBjeWNsZQpAQCAtNzYzLDcgKzc3OCw3IEBACiAgICAgdWludDMyX3QgICAgICAgICAgICAgICAgICAgICAgICBzbGVlcFRpbWVTaGlmdDsKIAogICAgIC8vIHNhbWUgYXMgQXVkaW9GbGluZ2VyOjptU3RhbmRieVRpbWVJbk5zZWNzIGV4Y2VwdCBmb3IgRElSRUNUIHdoaWNoIHVzZXMgYSBzaG9ydGVyIHZhbHVlCi0gICAgbnNlY3NfdCAgICAgICAgICAgICAgICAgICAgICAgICBzdGFuZGJ5RGVsYXk7CisgICAgbnNlY3NfdCAgICAgICAgICAgICAgICAgICAgICAgICBtU3RhbmRieURlbGF5TnM7CiAKICAgICAvLyBNSVhFUiBvbmx5CiAgICAgbnNlY3NfdCAgICAgICAgICAgICAgICAgICAgICAgICBtYXhQZXJpb2Q7CkBAIC04Mz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gICAgICAgICAgICAgICBhdWRpb19pb19oYW5kbGVfdCBpZCwgYm9vbCBzeXN0ZW1SZWFkeSk7CiAgICAgdmlydHVhbCAgICAgICAgICAgICAgICAgfkR1cGxpY2F0aW5nVGhyZWFkKCk7CiAKICAgICAvLyBUaHJlYWQgdmlydHVhbHMKQEAgLTExNzQsNyArMTE5MSw4IEBACiAgICAgICAgICAgICAgICAgICAgIEF1ZGlvU3RyZWFtSW4gKmlucHV0LAogICAgICAgICAgICAgICAgICAgICBhdWRpb19pb19oYW5kbGVfdCBpZCwKICAgICAgICAgICAgICAgICAgICAgYXVkaW9fZGV2aWNlc190IG91dERldmljZSwKLSAgICAgICAgICAgICAgICAgICAgYXVkaW9fZGV2aWNlc190IGluRGV2aWNlCisgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2RldmljZXNfdCBpbkRldmljZSwKKyAgICAgICAgICAgICAgICAgICAgYm9vbCBzeXN0ZW1SZWFkeQogI2lmZGVmIFRFRV9TSU5LCiAgICAgICAgICAgICAgICAgICAgICwgY29uc3Qgc3A8TkJBSU9fU2luaz4mIHRlZVNpbmsKICNlbmRpZgpAQCAtMTI5MSw2ICsxMzA5LDcgQEAKICAgICAgICAgICAgIC8vIG9uZS10aW1lIGluaXRpYWxpemF0aW9uLCBubyBsb2NrcyByZXF1aXJlZAogICAgICAgICAgICAgc3A8RmFzdENhcHR1cmU+ICAgICAgICAgICAgICAgICAgICAgbUZhc3RDYXB0dXJlOyAgIC8vIG5vbi0wIGlmIHRoZXJlIGlzIGFsc28KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhIGZhc3QgY2FwdHVyZQorCiAgICAgICAgICAgICAvLyBGSVhNRSBhdWRpbyB3YXRjaGRvZyB0aHJlYWQKIAogICAgICAgICAgICAgLy8gY29udGVudHMgYXJlIG5vdCBndWFyYW50ZWVkIHRvIGJlIGNvbnNpc3RlbnQsIG5vIGxvY2tzIHJ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GlmIChjaGFubmVsTWFzayA9PSAwKSB7IC8vIGlmIG5vdCBmb3VuZCwgY2hlY2sgdGhlIGNoYW5uZWwgaW5kZXggdGFibGUKKyAgICAgICAgICAgIGNoYW5uZWxNYXNrID0gKGF1ZGlvX2NoYW5uZWxfbWFza190KQorICAgICAgICAgICAgICAgICAgICAgIENvbmZpZ1BhcnNpbmdVdGlsczo6c3RyaW5nVG9FbnVtKHNJbmRleENoYW5uZWxzTmFtZVRvRW51bVRhYmxlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQVJSQVlfU0laRShzSW5kZXhDaGFubmVsc05hbWVUb0VudW1UYWJsZSksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIpOworICAgICAgICB9CiAgICAgICAgIGlmIChjaGFubmVsTWFzayAhPSAwKSB7CiAgICAgICAgICAgICBtQ2hhbm5lbE1hc2tzLmFkZChjaGFubmVsTWFzayk7CiAgICAgICAgIH0KQEAgLTYwNSw5ICs2MTEsMTMgQEAKIAogICAgIC8vIEZvciBtaXhlZCBvdXRwdXQgYW5kIGlucHV0cywgdXNlIG1heCBtaXhlciBzYW1wbGluZyByYXRlcy4gRG8gbm90CiAgICAgLy8gbGltaXQgc2FtcGxpbmcgcmF0ZSBvdGhlcndpc2UKKyAgICAvLyBGb3IgaW5wdXRzLCBhbHNvIHNlZSBjaGVja0NvbXBhdGlibGVTYW1wbGluZ1JhdGUoKS4KICAgICBpZiAobVR5cGUgIT0gQVVESU9fUE9SVF9UWVBFX01JWCkgewogICAgICAgICBtYXhSYXRlID0gVUlOVF9NQVg7CiAgICAgfQorICAgIC8vIFRPRE86IHNob3VsZCBtU2FtcGxpbmdSYXRlc1tdIGJlIG9yZGVyZWQgaW4gdGVybXMgb2Ygb3VyIHByZWZlcmVuY2UKKyAgICAvLyBhbmQgd2UgcmV0dXJuIHRoZSBmaXJzdCAoYW5kIGhlbmNlIG1vc3QgcHJlZmVycmVkKSBtYXRjaD8gIFRoaXMgaXMgb2Yg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91dHB1dERldmljZXMubG9hZERldmljZXNGcm9tTmFtZSgoY2hhciAqKW5vZGUtPnZhbHVlLAorICAgICAgICAgICAgYXZhaWxhYmxlT3V0cHV0RGV2aWNlcy5sb2FkRGV2aWNlc0Zyb21UYWcoKGNoYXIgKilub2RlLT52YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVjbGFyZWREZXZpY2VzKTsKICAgICAgICAgICAgIEFMT0dWKCJsb2FkR2xvYmFsQ29uZmlnKCkgQXR0YWNoZWQgT3V0cHV0IERldmljZXMgJTA4eCIsCiAgICAgICAgICAgICAgICAgICBhdmFpbGFibGVPdXRwdXREZXZpY2VzLnR5cGVzKCkpOwpAQCAtMjI4LDEzICsyMjgsMTMgQEAKICAgICAgICAgICAgICAgICAgICAgQVJSQVlfU0laRShzRGV2aWNlVHlwZVRvRW51bVRhYmxlKSwKICAgICAgICAgICAgICAgICAgICAgKGNoYXIgKilub2RlLT52YWx1ZSk7CiAgICAgICAgICAgICBpZiAoZGV2aWNlICE9IEFVRElPX0RFVklDRV9OT05FKSB7Ci0gICAgICAgICAgICAgICAgZGVmYXVsdE91dHB1dERldmljZSA9IG5ldyBEZXZpY2VEZXNjcmlwdG9yKFN0cmluZzgoImRlZmF1bHQtb3V0cHV0IiksIGRldmljZSk7CisgICAgICAgICAgICAgICAgZGVmYXVsdE91dHB1dERldmljZSA9IG5ldyBEZXZpY2VEZXNjcmlwdG9yKGRldmljZSk7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIEFMT0dXKCJsb2FkR2xvYmFsQ29uZmlnKCkgZGVmYXVsdCBkZXZpY2Ugbm90IHNwZWNpZmllZCIpOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgQUxPR1YoImxvYWRHbG9iYWxDb25maWcoKSBtRGVmYXVsdE91dHB1dERldmljZSAlMDh4IiwgZGVmYXVsdE91dHB1dERldmljZS0+dHlwZSgpKTs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ICB9CiB9CiAKLXZvaWQgRGV2aWNlVmVjdG9yOjpsb2FkRGV2aWNlc0Zyb21OYW1lKGNoYXIgKm5hbWUsCit2b2lkIERldmljZVZlY3Rvcjo6bG9hZERldmljZXNGcm9tVGFnKGNoYXIgKnRhZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IERldmljZVZlY3RvciYgZGVjbGFyZWREZXZpY2VzKQogewotICAgIGNoYXIgKmRldk5hbWUgPSBzdHJ0b2sobmFtZSwgInwiKTsKLSAgICB3aGlsZSAoZGV2TmFtZSAhPSBOVUxMKSB7Ci0gICAgICAgIGlmIChzdHJsZW4oZGV2TmFtZSkgIT0gMCkgeworICAgIGNoYXIgKmRldlRhZyA9IHN0cnRvayh0YWcsICJ8Iik7CisgICAgd2hpbGUgKGRldlRhZyAhPSBOVUxMKSB7CisgICAgICAgIGlmIChzdHJsZW4oZGV2VGFnKSAhPSAwKSB7CiAgICAgICAgICAgICBhdWRpb19kZXZpY2VzX3QgdHlwZSA9IENvbmZpZ1BhcnNpbmdVdGlsczo6c3RyaW5nVG9FbnVtKHNEZXZpY2VUeXBlVG9FbnVtVGFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBUlJBWV9TSVpFKHNEZXZpY2VUeXBlVG9FbnVtVGFibGUpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV2TmFtZSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXZUYWcpOwogICAgICAgICAgICAgaWYgKHR5cGUgIT0gQVVESU9fREVWSUNFX05PTkUpIHsKLSAgICAgICAgICAgICAgICBkZXZOYW1lID0gKGNoYXIgKilDb25maWdQYXJzaW5nVXRpbHM6OmVudW1Ub1N0cmluZyhzRGV2aWNlTmFtZVRvRW51bVRhYmxlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBUlJBWV9TSVpFKHNEZXZpY2VOYW1lVG9FbnVtVGFibGUpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlKTsKLSAgICAgICAgICAgICAgICBzcDxEZXZpY2VEZXNjcmlwdG9yPiBkZXYgPSBuZXcgRGV2aWNlRGVzY3JpcHRvcihTdHJpbmc4KGRldk5hbWUpLCB0eXBlKTsKKyAgICAgICAgICAgICAgICBzcDxEZXZpY2VEZXNjcmlwdG9yPiBkZXYgPSBuZXcgRGV2aWNlRGVzY3JpcHRvcih0eXBlKTsKICAgICAgICAgICAgICAgICBpZiAodHlwZSA9PSBBVURJT19ERVZJQ0VfSU5fUkVNT1RFX1NVQk1JWCB8fAogICAgICAgICAgICAgICAgICAgICAgICAgdHlwZSA9PSBBVURJT19ERVZJQ0VfT1VUX1JFTU9URV9TVUJNSVggKSB7CiAgICAgICAgICAgICAgICAgICAgIGRldi0+bUFkZHJlc3MgPSBTdHJpbmc4KCIwIik7CkBAIC0xNjcsMTMgKzE2MiwxMyBAQAogICAgICAgICAgICAgICAgIGFkZChkZXYpOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBzcDxEZXZpY2VEZXNjcmlwdG9yPiBkZXZpY2VEZXNjID0KLSAgICAgICAgICAgICAgICAgICAgICAgIGRlY2xhcmVkRGV2aWNlcy5nZXREZXZpY2VGcm9tTmFtZShTdHJpbmc4KGRldk5hbWUpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGRlY2xhcmVkRGV2aWNlcy5nZXREZXZpY2VGcm9tVGFnKFN0cmluZzgoZGV2VGFnKSk7CiAgICAgICAgICAgICAgICAgaWYgKGRldmljZURlc2MgIT0gMCkgewogICAgICAgICAgICAgICAgICAgICBhZGQoZGV2aWNlRGVzYyk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICAgfQotICAgICAgICAgZGV2TmFtZSA9IHN0cnRvayhOVUxMLCAifCIpOworICA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0+dmFsdWUsCisgICAgICAgICAgICBwcm9maWxlLT5tU3VwcG9ydGVkRGV2aWNlcy5sb2FkRGV2aWNlc0Zyb21UYWcoKGNoYXIgKilub2RlLT52YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbURlY2xhcmVkRGV2aWNlcyk7CiAgICAgICAgIH0gZWxzZSBpZiAoc3RyY21wKG5vZGUtPm5hbWUsIEZMQUdTX1RBRykgPT0gMCkgewogICAgICAgICAgICAgcHJvZmlsZS0+bUZsYWdzID0gQ29uZmlnUGFyc2luZ1V0aWxzOjpwYXJzZU91dHB1dEZsYWdOYW1lcygoY2hhciAqKW5vZGUtPnZhbHVlKTsKQEAgLTE1NCw3ICsxNTQsOCBAQAogICAgICAgICBBTE9HVygibG9hZERldmljZSgpIGJhZCB0eXBlICUwOHgiLCB0eXBlKTsKICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKICAgICB9Ci0gICAgc3A8RGV2aWNlRGVzY3JpcHRvcj4gZGV2aWNlRGVzYyA9IG5ldyBEZXZpY2VEZXNjcmlwdG9yKFN0cmluZzgocm9vdC0+bmFtZSksIHR5cGUpOworICAgIHNwPERldmljZURlc2NyaXB0b3I+IGRldmljZURlc2MgPSBuZXcgRGV2aWNlRGVzY3JpcHRvcih0eXBlKTsKKyAgICBkZXZpY2VEZXNjLT5tVGFnID0gU3RyaW5nOChyb290LT5uYW1lKTsKIAogICAgIG5vZGUgPSByb290LT5maXJzdF9jaGlsZDsKICAgICB3aGlsZSAobm9kZSkgewpAQCAtMTcyLDggKzE3Myw4IEBACiAgICAgICAgIG5vZGUgPSBub2RlLT5uZXh0OwogICAgIH0KIAotICAgIEFMT0dWKCJsb2FkRGV2aWNlKCkgYWRkaW5nIGRldmljZSBuYW1lICVzIHR5cGUgJTA4eCBhZGRyZXNzICVzIiwKLSAgICAgICAgICBkZXZpY2VEZXNjLT5tTmFtZS5zdHJpbmcoKSwgd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ICAgICAgICAgICByeERldmljZSA9IG1QcmltYXJ5T3V0cHV0LT5kZXZpY2UoKTsKKyAgICAgICAgfQogCi0gICAgaWYgKHN0YXRlID09IEFVRElPX01PREVfSU5fQ0FMTCkgewotICAgICAgICB1cGRhdGVDYWxsUm91dGluZyhyeERldmljZSwgZGVsYXlNcyk7Ci0gICAgfSBlbHNlIGlmIChvbGRTdGF0ZSA9PSBBVURJT19NT0RFX0lOX0NBTEwpIHsKLSAgICAgICAgaWYgKG1DYWxsUnhQYXRjaCAhPSAwKSB7Ci0gICAgICAgICAgICBtcENsaWVudEludGVyZmFjZS0+cmVsZWFzZUF1ZGlvUGF0Y2gobUNhbGxSeFBhdGNoLT5tQWZQYXRjaEhhbmRsZSwgMCk7Ci0gICAgICAgICAgICBtQ2FsbFJ4UGF0Y2guY2xlYXIoKTsKKyAgICAgICAgaWYgKHN0YXRlID09IEFVRElPX01PREVfSU5fQ0FMTCkgeworICAgICAgICAgICAgdXBkYXRlQ2FsbFJvdXRpbmcocnhEZXZpY2UsIGRlbGF5TXMpOworICAgICAgICB9IGVsc2UgaWYgKG9sZFN0YXRlID09IEFVRElPX01PREVfSU5fQ0FMTCkgeworICAgICAgICAgICAgaWYgKG1DYWxsUnhQYXRjaCAhPSAwKSB7CisgICAgICAgICAgICAgICAgbXBDbGllbnRJbnRlcmZhY2UtPnJlbGVhc2VBdWRpb1BhdGNoKG1DYWxsUnhQYXRjaC0+bUFmUGF0Y2hIYW5kbGUsIDApOworICAgICAgICAgICAgICAgIG1DYWxsUnhQYXRjaC5jbGVhcigpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKG1DYWxsVHhQYXRjaCAhPSAwKSB7CisgICAgICAgICAgICAgICAgbXBDbGllbnRJbnRlcmZhY2UtPnJlbGVhc2VBdWRpb1BhdGNoKG1DYWxsVHhQYXRjaC0+bUFmUGF0Y2hIYW5kbGUsIDApOworICAgICAgICAgICAgICAgIG1DYWxsVHhQYXRjaC5jbGVhcigpOworICAg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ZSgpID09IEFVRElPX01PREVfSU5fQ0FMTCAmJiBoYXNQcmltYXJ5T3V0cHV0KCkpIHsKICAgICAgICAgYXVkaW9fZGV2aWNlc190IG5ld0RldmljZSA9IGdldE5ld091dHB1dERldmljZShtUHJpbWFyeU91dHB1dCwgdHJ1ZSAvKmZyb21DYWNoZSovKTsKICAgICAgICAgdXBkYXRlQ2FsbFJvdXRpbmcobmV3RGV2aWNlKTsKICAgICB9CkBAIC01NzksMjQgKzU4Miw0MyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fY2hhbm5lbF9tYXNrX3QgY2hhbm5lbE1hc2ssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCBmbGFncykKIHsKKyAgICAvLyBvbmx5IHJldGFpbiBmbGFncyB0aGF0IHdpbGwgZHJpdmUgdGhlIGRpcmVjdCBvdXRwdXQgcHJvZmlsZSBzZWxlY3Rpb24KKyAgICAvLyBpZiBleHBsaWNpdGx5IHJlcXVlc3RlZAorICAgIHN0YXRpYyBjb25zdCB1aW50MzJfdCBrUmVsZXZhbnRGbGFncyA9CisgICAgICAgICAgICAoQVVESU9fT1VUUFVUX0ZMQUdfSFdfQVZfU1lOQyB8IEFVRElPX09VVFBVVF9GTEFHX0NPTVBSRVNTX09GRkxPQUQpOworICAgIGZsYWdzID0KKyAgICAgICAgKGF1ZGlvX291dHB1dF9mbGFnc190KSgoZmxhZ3MgJiBrUmVsZXZhbnRGbGFncykgfCBBVURJT19PVVRQVVRfRkxBR19ESVJFQ1QpOworCisgICAgc3A8SU9Qcm9maWxlPiBwcm9maWxlOworCiAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBtSHdNb2R1bGVzLnNpemUoKTsgaSsrKSB7CiAgICAgICAgIGlmIChtSHdNb2R1bGVzW2ldLT5tSGFuZGxlID09IDApIHsKICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICB9CiAgICAgICAgIGZvciAoc2l6ZV90IGogPSAwOyBqIDwgbUh3TW9kdWxlc1tpXS0+bU91dHB1dFByb2ZpbGVzLnNpemUoKTsgaisrKSB7Ci0gICAgICAgICAgICBzcDxJT1Byb2ZpbGU+IHByb2ZpbGUgPSBtSHdNb2R1bGVzW2ldLT5tT3V0cHV0UHJvZmlsZXNbal07Ci0gICAgICAgICAgICBib29sIGZvdW5kID0gcHJvZmlsZS0+aXNDb21wYXRpYmxlUHJvZmlsZShkZXZpY2UsIFN0cmluZzgoIiIpLAorICAgICAgICAgICAgc3A8SU9Qcm9maWxlPiBjdXJQcm9maWxlID0gbUh3TW9kdWxlc1tpXS0+bU91dHB1dFByb2ZpbGVzW2pdOworICAgICAgICAgICAgaWYgKCFjdXJQcm9maWxlLT5pc0NvbXBhdGlibGVQcm9maWxlKGRldmljZSwgU3RyaW5nOCgiIiksCiAgICAgICAgICAgICAgICAgICAgIHNhbXBsaW5nUmF0ZSwgTlVMTCAvKnVwZGF0ZWRTYW1wbGluZ1JhdGUqLywKICAgICAgICAgICAgICAgICAgICAgZm9ybWF0LCBOVUxMIC8qdXBkYXRlZEZvcm1hdCovLAogICAgICAgICAgICAgICAgICAgICBjaGFubmVsTWFzaywgTlVMTCAvKnVwZGF0ZWRDaGFubmVsTWFzayovLAotICAgICAgICAgICAgICAgICAgICBmbGFncyAmIEFVRElPX09VVFBVVF9GTEFHX0NPTVBSRVNTX09GRkxPQUQgPwotICAgICAgICAgICAgICAgICAgICAgICAgQVVESU9fT1VUUFVUX0ZMQUdfQ09NUFJFU1NfT0ZGTE9BRCA6IEFVRElPX09VVFBVVF9GTEFHX0RJUkVDVCk7Ci0gICAgICAgICAgICBpZiAoZm91bmQgJiYgKG1BdmFpbGFibGVPdXRwdXREZXZpY2VzLnR5cGVzKCkgJiBwcm9maWxlLT5tU3VwcG9ydGVkRGV2aWNlcy50eXBlcygpKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBwcm9maWxlOworICAgICAgICAgICAgICAgICAgICBmbGFncykpIHsKKyAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIC8vIHJlamVjdCBwcm9maWxlcyBub3QgY29ycmVzcG9uZGluZyB0byBhIGRldmljZSBjdXJyZW50bHkgYXZhaWxhYmxlCisgICAgICAgICAgICBpZiAoKG1BdmFpbGFibGVPdXRwdXREZXZpY2VzLnR5cGVzKCkgJiBjdXJQcm9maWxlLT5tU3VwcG9ydGVkRGV2aWNlcy50eXBlcygpKSA9PSAwKSB7CisgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICAvLyBpZiBzZXZlcmFsIHByb2ZpbGVzIGFyZSBjb21wYXRpYmxlLCBnaXZlIHByaW9yaXR5IHRvIG9uZSB3aXRoIG9mZmxvYWQgY2FwYWJpbGl0eQorICAgICAgICAgICAgaWYgKHByb2ZpbGUgIT0gMCAmJiAoKGN1clByb2ZpbGUtPm1GbGFncyAmIEFVRElPX09VVFBVVF9GTEFHX0NPTVBSRVNTX09GRkxPQUQpID09IDApKSB7CisgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBwcm9maWxlID0gY3VyUHJvZmlsZTsKKyAgICAgICAgICAgIGlmICgocHJvZmlsZS0+bUZsYWdzICYgQVVESU9fT1VUUFVUX0ZMQUdfQ09NUFJFU1NfT0ZGTE9BRCkgIT0gMCkgeworICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQotICAgIHJldHVybiAwOworICAgIHJldHVybiBwcm9maWxlOwogfQogCiBhdWRpb19pb19oYW5kbGVfdCBBdWRpb1BvbGljeU1hbmFnZXI6OmdldE91dHB1dChhdWRpb19zdHJlYW1fdHlwZV90IHN0cmVhbSwKQEAgLTc2OCw2ICs3O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XREZXZpY2UsIG1TcGVha2VyRHJjRW5hYmxlZCkgIT0gTk9fRVJST1IpIHsKQEAgLTI4OTMsNyArMjkzMyw3IEBACiAKIHN0YXR1c190IEF1ZGlvUG9saWN5TWFuYWdlcjo6aW5pdENoZWNrKCkKIHsKLSAgICByZXR1cm4gKG1QcmltYXJ5T3V0cHV0ID09IDApID8gTk9fSU5JVCA6IE5PX0VSUk9SOworICAgIHJldHVybiBoYXNQcmltYXJ5T3V0cHV0KCkgPyBOT19FUlJPUiA6IE5PX0lOSVQ7CiB9CiAKICNpZmRlZiBBVURJT19QT0xJQ1lfVEVTVApAQCAtMzI2OCw3ICszMzA4LDggQEAKICAgICAgICAgICAgICAgICAgICAgICAgIHBvbGljeU1peC0+c2V0T3V0cHV0KGRlc2MpOwogICAgICAgICAgICAgICAgICAgICAgICAgZGVzYy0+bVBvbGljeU1peCA9IHBvbGljeU1peC0+Z2V0TWl4KCk7CiAKLSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICgoZGVzYy0+bUZsYWdzICYgQVVESU9fT1VUUFVUX0ZMQUdfRElSRUNUKSA9PSAwKSB7CisgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKChkZXNjLT5tRmxhZ3MgJiBBVURJT19PVVRQVVRfRkxBR19ESVJFQ1QpID09IDApICYmCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNQcmltYXJ5T3V0cHV0KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG5vIGR1cGxpY2F0ZWQgb3V0cHV0IGZvciBkaXJlY3Qgb3V0cHV0cyBhbmQKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG91dHB1dHMgdXNlZCBieSBkeW5hbWljIHBvbGljeSBtaXhlcwogICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3QgZHVwbGljYXRlZE91dHB1dCA9IEFVRElPX0lPX0hBTkRMRV9OT05FOwpAQCAtNDU0NCw3ICs0NTg1LDggQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBkZWxheU1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fZGV2aWNlc190IGRldmljZSkKIHsKLSAgICBBTE9HVlYoInNldFN0cmF0ZWd5TXV0ZSgpIHN0cmF0ZWd5ICVkLCBtdXRlICVkLCBvdXRwdXQgJWQiLCBzdHJhdGVneSwgb24sIG91dHB1dCk7CisgICAgQUxPR1ZWKCJzZXRTdHJhdGVneU11dGUoKSBzdHJhdGVneSAlZCwgbXV0ZSAlZCwgb3V0cHV0IElEICVkIiwKKyAgICAgICAgICAgc3RyYXRlZ3ksIG9uLCBvdXRwdXREZXNjLT5nZXRJZCgpKTsKICAgICBmb3IgKGludCBzdHJlYW0gPSAwOyBzdHJlYW0gPCBBVURJT19TVFJFQU1fQ05UOyBzdHJlYW0rKykgewogICAgICAgICBpZiAoc3RyZWFtID09IEFVRElPX1NUUkVBTV9QQVRDSCkgewogICAgICAgICAgICAgY29udGludWU7CkBAIC00NTk3LDYgKzQ2MzksMTAgQEAKIHZvaWQgQXVkaW9Qb2xpY3lNYW5hZ2VyOjpoYW5kbGVJbmNhbGxTb25pZmljYXRpb24oYXVkaW9fc3RyZWFtX3R5cGVfdCBzdHJlYW0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIHN0YXJ0aW5nLCBib29sIHN0YXRlQ2hhbmdlKQogeworICAgIGlmKCFoYXNQcmltYXJ5T3V0cHV0KCkpIHsKKyAgICAgICAgcmV0dXJuOworICAgIH0KKwogICAgIC8vIGlmIHRoZSBzdHJlYW0gcGVydGFpbnMgdG8gc29uaWZpY2F0aW9uIHN0cmF0ZWd5IGFuZCB3ZSBhcmUgaW4gY2FsbCB3ZSBtdXN0CiAgICAgLy8gbXV0ZSB0aGUgc3RyZWFtIGlmIGl0IGlzIGxvdyB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mF1bHQvQXVkaW9Qb2xpY3lNYW5hZ2VyLmgKQEAgLTU1MywxMCArNTUzLDE2IEBACiAKICAgICAgICAgYXVkaW9fZGV2aWNlc190IGF2YWlsYWJsZVByaW1hcnlPdXRwdXREZXZpY2VzKCkgY29uc3QKICAgICAgICAgeworICAgICAgICAgICAgaWYgKCFoYXNQcmltYXJ5T3V0cHV0KCkpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gQVVESU9fREVWSUNFX05PTkU7CisgICAgICAgICAgICB9CiAgICAgICAgICAgICByZXR1cm4gbVByaW1hcnlPdXRwdXQtPnN1cHBvcnRlZERldmljZXMoKSAmIG1BdmFpbGFibGVPdXRwdXREZXZpY2VzLnR5cGVzKCk7CiAgICAgICAgIH0KICAgICAgICAgYXVkaW9fZGV2aWNlc190IGF2YWlsYWJsZVByaW1hcnlJbnB1dERldmljZXMoKSBjb25zdAogICAgICAgICB7CisgICAgICAgICAgICBpZiAoIWhhc1ByaW1hcnlPdXRwdXQoKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBBVURJT19ERVZJQ0VfTk9ORTsKKyAgICAgICAgICAgIH0KICAgICAgICAgICAgIHJldHVybiBtQXZhaWxhYmxlSW5wdXREZXZpY2VzLmdldERldmljZXNGcm9tSHdNb2R1bGUobVByaW1hcnlPdXRwdXQtPmdldE1vZHVsZUhhbmRsZSgpKTsKICAgICAgICAgfQogCkBAIC01NzYsNiArNTgyLDggQEAKICAgICAgICAgdm9pZCBjbGVhclNlc3Npb25Sb3V0ZXModWlkX3QgdWlkKTsKICAgICAgICAgdm9pZCBjaGVja1N0cmF0ZWd5Um91dGUocm91dGluZ19zdHJhdGVneSBzdHJhdGVneSwgYXVkaW9faW9faGFuZGxlX3Qgb3VwdHV0VG9Ta2lwKTsKIAorICAgICAgICBzdGF0dXNfdCBoYXNQcmltYXJ5T3V0cHV0KCkgY29uc3QgeyByZXR1cm4gbVByaW1hcnlPdXRwdXQgIT0gMDsgfQorCiAgICAgICAgIHVpZF90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ld1VpZCA9IGl0ZXItPnNlY29uZC5maXJzdDsKKyAgICAgICAgICAgIEJhdHRlcnlOb3RpZmllciYgbm90aWZpZXIoQmF0dGVyeU5vdGlmaWVyOjpnZXRJbnN0YW5jZSgpKTsKKyAgICAgICAgICAgIGlmIChvbGRVaWQgIT0gbmV3VWlkKSB7CisgICAgICAgICAgICAgICAgLy8gSWYgdGhlIFVJRCBoYXMgY2hhbmdlZCwgbG9nIHRoZSBzdGF0dXMgYW5kIHVwZGF0ZSBjdXJyZW50IFVJRCBpbiBtVG9yY2hVaWRNYXAKKyAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09IElDYW1lcmFTZXJ2aWNlTGlzdGVuZXI6OlRPUkNIX1NUQVRVU19BVkFJTEFCTEVfT04pIHsKKyAgICAgICAgICAgICAgICAgICAgbm90aWZpZXIubm90ZUZsYXNobGlnaHRPZmYoY2FtZXJhSWQsIG9sZFVpZCk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGlmIChuZXdTdGF0dXMgPT0gSUNhbWVyYVNlcnZpY2VMaXN0ZW5lcjo6VE9SQ0hfU1RBVFVTX0FWQUlMQUJMRV9PTikgeworICAgICAgICAgICAgICAgICAgICBub3RpZmllci5ub3RlRmxhc2hsaWdodE9uKGNhbWVyYUlkLCBuZXdVaWQpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpdGVyLT5zZWNvbmQuc2Vjb25kID0gbmV3VWlkOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAvLyBJZiB0aGUgVUlEIGhhcyBub3QgY2hhbmdlZCwgbG9nIHRoZSBzdGF0dXMKKyAgICAgICAgICAgICAgICBpZiAobmV3U3RhdHVzID09IElDYW1lcmFTZXJ2aWNlTGlzdGVuZXI6OlRPUkNIX1NUQVRVU19BVkFJTEFCTEVfT04pIHsKKyAgICAgICAgICAgICAgICAgICAgbm90aWZpZXIubm90ZUZsYXNobGlnaHRPbihjYW1lcm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91cyAiCi0gICAgICAgICAgICAgICAgImRldmljZSB1c2VyICVkLCBjdXJyZW50IGRldmljZSB1c2VyICVkKSIsIGNhbGxpbmdQaWQsIGNsaWVudFVzZXJJZCwgbUxhc3RVc2VySWQpOworICAgIGlmIChjYWxsaW5nUGlkICE9IGdldHBpZCgpICYmIChtQWxsb3dlZFVzZXJzLmZpbmQoY2xpZW50VXNlcklkKSA9PSBtQWxsb3dlZFVzZXJzLmVuZCgpKSkgeworICAgICAgICBBTE9HRSgiQ2FtZXJhU2VydmljZTo6Y29ubmVjdCBYIChQSUQgJWQpIHJlamVjdGVkIChjYW5ub3QgY29ubmVjdCBmcm9tICIKKyAgICAgICAgICAgICAgICAiZGV2aWNlIHVzZXIgJWQsIGN1cnJlbnRseSBhbGxvd2VkIGRldmljZSB1c2VyczogJXMpIiwgY2FsbGluZ1BpZCwgY2xpZW50VXNlcklkLAorICAgICAgICAgICAgICAgIHRvU3RyaW5nKG1BbGxvd2VkVXNlcnMpLnN0cmluZygpKTsKICAgICAgICAgcmV0dXJuIFBFUk1JU1NJT05fREVOSUVEOwogICAgIH0KIApAQCAtOTY3LDYgKzEwMDUsMTAgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICIoUElEICUiIFBSSWQzMiAiLCBwcmlvcml0eSAlIiBQUklkMzIgIikiLCBpLT5nZXRLZXkoKS5zdHJpbmcoKSwKICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZzh7aS0+Z2V0VmFsdWUoKS0+Z2V0UGFja2FnZU5hbWUoKX0uc3RyaW5nKCksIGktPmdldE93bmVySWQoKSwKICAgICAgICAgICAgICAgICAgICAgICAgIGktPmdldFByaW9yaXR5KCkpOworICAgICAgICAgICAgICAgIEFMT0dFKCIgICBDb25mbGljdHMgd2l0aDogRGV2aWNlICVzLCBjbGllbnQgcGFja2FnZSAlcyAoUElEICUiCisgICAgICAgICAgICAgICAgICAgICAgICBQUklkMzIgIiwgcHJpb3JpdHkgJSIgUFJJZDMyICIpIiwg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ICAgIH0KKwogICAgIHN0YXR1c190IHJlcyA9IG1GbGFzaGxpZ2h0LT5zZXRUb3JjaE1vZGUoaWQsIGVuYWJsZWQpOworCiAgICAgaWYgKHJlcykgewogICAgICAgICBBTE9HRSgiJXM6IHNldHRpbmcgdG9yY2ggbW9kZSBvZiBjYW1lcmEgJXMgdG8gJWQgZmFpbGVkLiAlcyAoJWQpIiwKICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIGlkLnN0cmluZygpLCBlbmFibGVkLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKQEAgLTEyMTUsMjkgKzEyNTcsMjcgQEAKICAgICAgICAgLy8gdXBkYXRlIHRoZSBsaW5rIHRvIGNsaWVudCdzIGRlYXRoCiAgICAgICAgIE11dGV4OjpBdXRvbG9jayBhbChtVG9yY2hDbGllbnRNYXBNdXRleCk7CiAgICAgICAgIHNzaXplX3QgaW5kZXggPSBtVG9yY2hDbGllbnRNYXAuaW5kZXhPZktleShpZCk7CisgICAgICAgIEJhdHRlcnlOb3RpZmllciYgbm90aWZpZXIoQmF0dGVyeU5vdGlmaWVyOjpnZXRJbnN0YW5jZSgpKTsKICAgICAgICAgaWYgKGVuYWJsZWQpIHsKICAgICAgICAgICAgIGlmIChpbmRleCA9PSBOQU1FX05PVF9GT1VORCkgewogICAgICAgICAgICAgICAgIG1Ub3JjaENsaWVudE1hcC5hZGQoaWQsIGNsaWVudEJpbmRlcik7CiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIGNvbnN0IHNwPElCaW5kZXI+IG9sZEJpbmRlciA9IG1Ub3JjaENsaWVudE1hcC52YWx1ZUF0KGluZGV4KTsKLSAgICAgICAgICAgICAgICBvbGRCaW5kZXItPnVubGlua1RvRGVhdGgodGhpcyk7Ci0KKyAgICAgICAgICAgICAgICBtVG9yY2hDbGllbnRNYXAudmFsdWVBdChpbmRleCktPnVubGlua1RvRGVhdGgodGhpcyk7CiAgICAgICAgICAgICAgICAgbVRvcmNoQ2xpZW50TWFwLnJlcGxhY2VWYWx1ZUF0KGluZGV4LCBjbGllbnRCaW5kZXIpOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgY2xpZW50QmluZGVyLT5saW5rVG9EZWF0aCh0aGlzKTsKICAgICAgICAgfSBlbHNlIGlmIChpbmRleCAhPSBOQU1FX05PVF9GT1VORCkgewotICAgICAgICAgICAgc3A8SUJpbmRlcj4gb2xkQmluZGVyID0gbVRvcmNoQ2xpZW50TWFwLnZhbHVlQXQoaW5kZXgpOwotICAgICAgICAgICAgb2xkQmluZGVyLT51bmxpbmtUb0RlYXRoKHRoaXMpOworICAgICAgICAgICAgbVRvcmNoQ2xpZW50TWFwLnZhbHVlQXQoaW5kZXgpLT51bmxpbmtUb0RlYXRoKHRoaXMpOwogICAgICAgICB9CiAgICAgfQogCiAgICAgcmV0dXJuIE9LOwogfQogCi12b2lkIENhbWVyYVNlcnZpY2U6Om5vdGlmeVN5c3RlbUV2ZW50KGludCBldmVudElkLCBpbnQgYXJnMCkgewordm9pZCBDYW1lcmFTZXJ2aWNlOjpub3RpZnlTeXN0ZW1FdmVudChpbnQzMl90IGV2ZW50SWQsIGNvbnN0IGludDMyX3QqIGFyZ3MsIHNpemVfdCBsZW5ndGgpIHsKICAgICBzd2l0Y2goZXZlbnRJZCkgewogICAgICAgICBjYXNlIElDYW1lcmFTZXJ2aWNlOjpVU0VSX1NXSVRDSEVEOiB7Ci0gICAgICAgICAgICBkb1VzZXJTd2l0Y2goLypuZXdVc2VySWQqL2FyZzApOworICAgICAgICAgICAgZG9Vc2VyU3dpdGNoKC8qbmV3VXNlcklkcyovYXJncywgLypsZW5ndGgqL2xlbmd0aCk7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgICAgICBjYXNlIElDYW1lcmFTZXJ2aWNlOjpOT19FVkVOVDoKQEAgLTEyNDksOCArMTI4OSw3IEBACiAgICAgfQogfQogCi1zdGF0dXNfdCBDYW1lcmFTZXJ2aWNlOjphZGRM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gICAgICBjYXNlIEJuQ2FtZXJhU2VydmljZTo6Q09OTkVDVF9MRUdBQ1k6IHsKKyAgICAgICAgICAgIGlmIChwaWQgIT0gc2VsZlBpZCkgeworICAgICAgICAgICAgICAgIC8vIHdlJ3JlIGNhbGxlZCBmcm9tIGEgZGlmZmVyZW50IHByb2Nlc3MsIGRvIHRoZSByZWFsIGNoZWNrCisgICAgICAgICAgICAgICAgaWYgKCFjaGVja0NhbGxpbmdQZXJtaXNzaW9uKAorICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nMTYoImFuZHJvaWQucGVybWlzc2lvbi5DQU1FUkEiKSkpIHsKKyAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50IHVpZCA9IGdldENhbGxpbmdVaWQoKTsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoIlBlcm1pc3Npb24gRGVuaWFsOiAiCisgICAgICAgICAgICAgICAgICAgICAgICAgImNhbid0IHVzZSB0aGUgY2FtZXJhIHBpZD0lZCwgdWlkPSVkIiwgcGlkLCB1aWQpOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gUEVSTUlTU0lPTl9ERU5JRUQ7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KICAgICAgICAgY2FzZSBCbkNhbWVyYVNlcnZpY2U6Ok5PVElGWV9TWVNURU1fRVZFTlQ6IHsKICAgICAgICAgICAgIGlmIChwaWQgIT0gc2VsZlBpZCkgewogICAgICAgICAgICAgICAgIC8vIEVuc3VyZSB3ZSdyZSBiZWluZyBjYWxsZWQgYnkgc3lzdGVtX3NlcnZlciwgb3Igc2ltaWxhciBwcm9jZXNzIHdpdGgKQEAgLTE2MTcsMzggKzE2OTEsNiBAQAogICAgIHJldHVybiBCbkNhbWVyYVNlcnZpY2U6Om9uVHJhbnNhY3QoY29kZSwgZGF0YSwgcmVwbHksIGZsYWdzKTsKIH0KIAotc3RhdHVzX3QgQ2FtZXJhU2Vyd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AgY29uc3Qgc3A8SUJpbmRlcj4mIHJlbW90ZUNhbGxiYWNrLAotICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzE2JiBvcFBhY2thZ2VOYW1lLAorICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzE2JiBjbGllbnRQYWNrYWdlTmFtZSwKICAgICAgICAgICAgICAgICBpbnQgY2FtZXJhSWQsCiAgICAgICAgICAgICAgICAgaW50IGNhbWVyYUZhY2luZywKICAgICAgICAgICAgICAgICBpbnQgY2xpZW50UGlkLApAQCAtMjQyLDcgKzIyNyw3IEBACiAgICAgICAgIHNwPENhbWVyYVNlcnZpY2U+ICAgICAgICAgICAgICAgbUNhbWVyYVNlcnZpY2U7ICAvLyBpbW11dGFibGUgYWZ0ZXIgY29uc3RydWN0b3IKICAgICAgICAgaW50ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ2FtZXJhSWQ7ICAgICAgIC8vIGltbXV0YWJsZSBhZnRlciBjb25zdHJ1Y3RvcgogICAgICAgICBpbnQgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1DYW1lcmFGYWNpbmc7ICAgLy8gaW1tdXRhYmxlIGFmdGVyIGNvbnN0cnVjdG9yCi0gICAgICAgIGNvbnN0IFN0cmluZzE2ICAgICAgICAgICAgICAgICAgbU9wUGFja2FnZU5hbWU7CisgICAgICAgIGNvbnN0IFN0cmluZzE2ICAgICAgICAgICAgICAgICAgbUNsaWVudFBhY2thZ2VOYW1lOwogICAgICAgICBwaWRfdCAgICAgICAgICAgICAgICAgICAgICAgICAgIG1DbGllbnRQaWQ7CiAgICAgICAgIHVpZF90ICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNsaWVudFVpZDsgICAgICAvLyBpbW11dGFibGUgYWZ0ZXIgY29uc3RydWN0b3IKICAgICAgICAgcGlkX3QgICAgICAgICAgICAgICAgICAgICAgICAgICBtU2VydmljZVBpZDsgICAgIC8vIGltbXV0YWJsZSBhZnRlciBjb25zdHJ1Y3RvcgpAQCAtMzA5LDcgKzI5NCw3IEBACiAgICAgICAgIC8vIEludGVyZmFjZSB1c2VkIGJ5IENhbWVyYVNlcnZpY2UKICAgICAgICAgQ2xpZW50KGNvbnN0IHNwPENhbWVyYVNlcnZpY2U+JiBjYW1lcmFTZXJ2aWNlLAogICAgICAgICAgICAgICAgIGNvbnN0IHNwPElDYW1lcmFDbGllbnQ+JiBjYW1lcmFDbGllbnQsCi0gICAgICAgICAgICAgICAgY29uc3QgU3RyaW5nMTYmIG9wUGFja2FnZU5hbWUsCisgICAgICAgICAgICAgICAgY29uc3QgU3RyaW5nMTYmIGNsaWVudFBhY2thZ2VOYW1lLAogICAgICAgICAgICAgICAgIGludCBjYW1lcmFJZCwKICAgICAgICAgICAgICAgICBpbnQgY2FtZXJhRmFjaW5nLAogICAgICAgICAgICAgICAgIGludCBjbGllbnRQaWQsCkBAIC0zNDMsNiArMzI4LDIwIEBACiAKICAgICB9OyAvLyBjbGFzcyBDbGllbnQKIAorICAgIC8qKgorICAgICAqIEEgbGlzdGVuZXIgY2xhc3MgdGhhdCBpbXBsZW1lbnRzIHRoZSBMSVNURU5FUiBpbnRlcmZhY2UgZm9yIHVzZSB3aXRoIGEgQ2xpZW50TWFuYWdlciwgYW5kCisgICAgICogaW1wbGVtZW50cyB0aGUgZm9sbG93aW5nIG1ldGhvZHM6CisgICAgICogICAgdm9pZCBvbkNsaWVudFJlbW92ZWQoY29uc3QgQ2xpZW50RGVzY3JpcHRvcjxLRVksIFZBTFVFPiYgZGVzY3JpcHRvcik7CisgICAgICogICAgdm9pZCBvbkNsaWVudEFkZGVkKGNvbnN0IENsaWVudERlc2NyaXB0b3I8S0VZLCBWQUxVRT4mIGRlc2NyaXB0b3IpOworICAgICAqLworICAgIGNsYXNzIENsaWVudEV2ZW50TGlzdGVuZXIgeworICAgIHB1YmxpYzoKKyAgICAgICAgdm9pZCBvbkNsaWVudEFkZGVkKGNvbnN0IHJlc291cmNlX3BvbGljeTo6Q2xpZW50RGVzY3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JsZShjb25zdCBDYXB0dXJlUmVzdWx0ICZyZXN1bHQpIHsKICAgICBBVFJBQ0VfQ0FMTCgpOwogICAgIEFMT0dWKCIlczogTmV3IHJlc3VsdCBhdmFpbGFibGUuIiwgX19GVU5DVElPTl9fKTsKQEAgLTMzNSw2ICszNDcsMTEgQEAKICAgICB9IGVsc2UgewogICAgICAgICBuZXh0U3RhdGUgPSBTVEFOREFSRF9TVEFSVDsKICAgICB9CisgICAgeworICAgICAgICBNdXRleDo6QXV0b2xvY2sgbChtSW5wdXRNdXRleCk7CisgICAgICAgIG1TaHV0dGVyQ2FwdHVyZUlkID0gbUNhcHR1cmVJZDsKKyAgICAgICAgbUhhbE5vdGlmaWVkU2h1dHRlciA9IGZhbHNlOworICAgIH0KICAgICBtU2h1dHRlck5vdGlmaWVkID0gZmFsc2U7CiAKICAgICByZXR1cm4gbmV4dFN0YXRlOwpAQCAtNTQxLDYgKzU1OCw3IEBACiAgICAgICAgICAgICByZXR1cm4gRE9ORTsKICAgICAgICAgfQogICAgIH0KKwogICAgIC8vIFRPRE86IENhcHR1cmUgc2hvdWxkIGJlIGF0b21pYyB3aXRoIHNldFN0cmVhbWluZ1JlcXVlc3QgaGVyZQogICAgIHJlcyA9IGNsaWVudC0+Z2V0Q2FtZXJhRGV2aWNlKCktPmNhcHR1cmUoY2FwdHVyZUNvcHkpOwogICAgIGlmIChyZXMgIT0gT0spIHsKQEAgLTU2MCw2ICs1NzgsMzEgQEAKICAgICBBVFJBQ0VfQ0FMTCgpOwogICAgIE11dGV4OjpBdXRvbG9jayBsKG1JbnB1dE11dGV4KTsKIAorCisgICAgLy8gV2FpdCBmb3Igc2h1dHRlciBjYWxsYmFjaworICAgIHdoaWxlICghbUhhbE5vdGlmaWVkU2h1dHRlcikgeworICAgICAgICBpZiAobVRpbWVvdXRDb3VudCA8PSAwKSB7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICByZXMgPSBtU2h1dHRlck5vdGlmeVNpZ25hbC53YWl0UmVsYXRpdmUobUlucHV0TXV0ZXgsIGtXYWl0RHVyYXRpb24pOworICAgICAgICBpZiAocmVzID09IFRJTUVEX09VVCkgeworICAgICAgICAgICAgbVRpbWVvdXRDb3VudC0tOworICAgICAgICAgICAgcmV0dXJuIFNUQU5EQVJEX0NBUFRVUkVfV0FJVDsKKyAgICAgICAgfQorICAgIH0KKworICAgIGlmIChtSGFsTm90aWZpZWRTaHV0dGVyKSB7CisgICAgICAgIGlmICghbVNodXR0ZXJOb3RpZmllZCkgeworICAgICAgICAgICAgU2hhcmVkUGFyYW1ldGVyczo6TG9jayBsKGNsaWVudC0+Z2V0UGFyYW1ldGVycygpKTsKKyAgICAgICAgICAgIC8qIHdhcm5pbmc6IHRoaXMgYWxzbyBsb2NrcyBhIFNoYXJlZENhbWVyYUNhbGxiYWNrcyAqLworICAgICAgICAgICAgc2h1dHRlck5vdGlmeUxvY2tlZChsLm1QYXJhbWV0ZXJzLCBjbGllbnQsIG1Nc2dUeXBlKTsKKyAgICAgICAgICAgIG1TaHV0dGVyTm90aWZpZWQgPSB0cnVlOworICAgICAgICB9CisgICAgfSBlbHNlIGlmIChtVGltZW91dENvdW50IDw9IDApIHsKKyAgICAgICAgQUxPR1coIlRpbWVkIG91dCB3YWl0aW5nIGZvciBzaHV0dGVyIG5vdGlmaWNhdGlvbiIpOworICAgICAgICByZXR1cm4gRE9ORTsKKyAgICB9CisKICAgICAvLyBXYWl0IGZvciBuZXcgbWV0YWRhdGEgcmVzdWx0IChtTmV3RnJhbWUpCiAgICAgd2hpbGUgKCFtTmV3RnJhbWVSZWNlaXZlZCkgewogICAgICAgICByZXMgPSBtTmV3RnJhbWVTaWduYWwud2FpdFJlbGF0aXZlKG1JbnB1dE11dGV4LCBrV2FpdER1cmF0aW9uKTsKQEAgLTU2OSwxNSArNjEyLDYgQEAKICAgICAgICAgfQogICAgIH0KIAotICAgIC8vIEFwcHJveGltYXRpb24gb2YgdGhlIHNodXR0ZXIgYmVpbmcgY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gZ3JhbGxvYyB1c2FnZTogJTA4WCIsIF9fRlVOQ1RJT05fXywgbUlkLAorICAgICAgICAgICAgbVJlY29yZGluZ0dyYWxsb2NVc2FnZSk7CisKKyAgICBpZiAocHJldkdyYWxsb2NVc2FnZSAhPSBtUmVjb3JkaW5nR3JhbGxvY1VzYWdlKSB7CisgICAgICAgIEFMT0dWKCIlczogQ2FtZXJhICVkOiBSZXNldHRpbmcgcmVjb3JkaW5nIGNvbnN1bWVyIGZvciBuZXcgdXNhZ2UiLAorICAgICAgICAgICAgX19GVU5DVElPTl9fLCBtSWQpOworCisgICAgICAgIGlmIChpc1N0cmVhbUFjdGl2ZShtQWN0aXZlU3RyZWFtSWRzLCBtUmVjb3JkaW5nU3RyZWFtSWQpKSB7CisgICAgICAgICAgICBBTE9HRSgiJXM6IENhbWVyYSAlZDogQ2hhbmdpbmcgcmVjb3JkaW5nIGZvcm1hdCB3aGVuICIKKyAgICAgICAgICAgICAgICAgICAgInJlY29yZGluZyBzdHJlYW0gaXMgYWxyZWFkeSBhY3RpdmUhIiwgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgICAgICAgICBtSWQpOworICAgICAgICAgICAgcmV0dXJuIElOVkFMSURfT1BFUkFUSU9OOworICAgICAgICB9CisKKyAgICAgICAgcmVsZWFzZUFsbFJlY29yZGluZ0ZyYW1lc0xvY2tlZCgpOworCisgICAgICAgIG1SZWNvcmRpbmdDb25zdW1lci5jbGVhcigpOworICAgIH0KKworICAgIHJldHVybiBPSzsKK30KKwogc3RhdHVzX3QgU3RyZWFtaW5nUHJvY2Vzc29yOjp1cGRhdGVSZWNvcmRpbmdSZXF1ZXN0KGNvbnN0IFBhcmFtZXRlcnMgJnBhcmFtcykgewogICAgIEFUUkFDRV9DQUxMKCk7CiAgICAgc3RhdHVzX3QgcmVzOwpAQCAtMzQwLDkgKzM4NCwxMCBAQAogICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CiAgICAgfQogCi0gICAgdWludDMyX3QgY3VycmVudFdpZHRoLCBjdXJyZW50SGVpZ2h0OworICAgIHVpbnQzMl90IGN1cnJlbnRXaWR0aCwgY3VycmVudEhlaWdodCwgY3VycmVudEZvcm1hdDsKKyAgICBhbmRyb2lkX2RhdGFzcGFjZSBjdXJyZW50RGF0YVNwYWNlOwogICAgIHJlcyA9IGRldmljZS0+Z2V0U3RyZWFtSW5mbyhtUmVjb3JkaW5nU3RyZWFtSWQsCi0gICAgICAgICAgICAmY3VycmVudFdpZHRoLCAmY3VycmVudEhlaWdodCwgMCk7CisgICAgICAgICAgICAmY3VycmVudFdpZHRoLCAmY3VycmVudEhlaWdodCwgJmN1cnJlbnRGb3JtYXQsICZjdXJyZW50RGF0YVNwYWNlKTsKICAgICBpZiAocmVzICE9IE9LKSB7CiAgICAgICAgIEFMT0dFKCIlczogQ2FtZXJhICVkOiBFcnJvciBxdWVyeWluZyByZWNvcmRpbmcgb3V0cHV0IHN0cmVhbSBpbmZvOiAiCiAgICAgICAgICAgICAgICAgIiVzICglZCkiLCBfX0ZVTkNUSU9OX18sIG1JZCwKQEAgLTM1MCw4ICszOTUsMTEgQEAKICAgICAgICAgcmV0dXJuIHJlczsKICAgICB9CiAKLSAgICBpZiAobVJlY29yZGluZ0NvbnN1bWVyID09IDAgfHwgY3VycmVudFdpZHRoICE9ICh1aW50MzJfdClwYXJhbXMudmlkZW9XaWR0aCB8fAotICAgICAgICAgICAgY3VycmVudEhlaWdodCAhPSAodWludDMyX3QpcGFyYW1zLnZpZGVvSGVpZ2h0KSB7CisgICAgaWYgKG1SZWNvcmRpbmdDb25zdW1lciA9PSAwIHx8CisgICAgICAgICAgICBjdXJyZW50V2lkdGggIT0gKHVpbnQzMl90KXBhcmFtcy52aWRlb1dpZHRoIHx8CisgICAgICAgICAgICBjdXJyZW50SGVpZ2h0ICE9ICh1aW50MzJfdClwYXJhbXMudmlkZW9IZWlnaHQgfHwKKyAgICAgICAgICAgIGN1cnJlbnRGb3JtYXQgIT0gKHVpbnQz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SBjdXJyZW50RGF0YVNwYWNlOwogICAgICAgICByZXMgPSBkZXZpY2UtPmdldFN0cmVhbUluZm8obVJlY29yZGluZ1N0cmVhbUlkLAotICAgICAgICAgICAgICAgICZjdXJyZW50V2lkdGgsICZjdXJyZW50SGVpZ2h0LCAwKTsKKyAgICAgICAgICAgICAgICAmY3VycmVudFdpZHRoLCAmY3VycmVudEhlaWdodCwKKyAgICAgICAgICAgICAgICAmY3VycmVudEZvcm1hdCwgJmN1cnJlbnREYXRhU3BhY2UpOwogICAgICAgICBpZiAocmVzICE9IE9LKSB7CiAgICAgICAgICAgICBBTE9HRSgiJXM6IENhbWVyYSAlZDogRXJyb3IgcXVlcnlpbmcgcmVjb3JkaW5nIG91dHB1dCBzdHJlYW0gaW5mbzogIgogICAgICAgICAgICAgICAgICAgICAiJXMgKCVkKSIsIF9fRlVOQ1RJT05fXywgbUlkLApAQCAtNDAxLDcgKzQ1MiwxMCBAQAogICAgICAgICAgICAgcmV0dXJuIHJlczsKICAgICAgICAgfQogICAgICAgICBpZiAoY3VycmVudFdpZHRoICE9ICh1aW50MzJfdClwYXJhbXMudmlkZW9XaWR0aCB8fAotICAgICAgICAgICAgICAgIGN1cnJlbnRIZWlnaHQgIT0gKHVpbnQzMl90KXBhcmFtcy52aWRlb0hlaWdodCB8fCBuZXdDb25zdW1lcikgeworICAgICAgICAgICAgICAgIGN1cnJlbnRIZWlnaHQgIT0gKHVpbnQzMl90KXBhcmFtcy52aWRlb0hlaWdodCB8fAorICAgICAgICAgICAgICAgIGN1cnJlbnRGb3JtYXQgIT0gKHVpbnQzMl90KW1SZWNvcmRpbmdGb3JtYXQgfHwKKyAgICAgICAgICAgICAgICBjdXJyZW50RGF0YVNwYWNlICE9IG1SZWNvcmRpbmdEYXRhU3BhY2UgfHwKKyAgICAgICAgICAgICAgICBuZXdDb25zdW1lcikgewogICAgICAgICAgICAgLy8gVE9ETzogU2hvdWxkIHdhaXQgdG8gYmUgc3VyZSBwcmV2aW91cyByZWN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A9IDA7IGkgPCBlbnRyeS5jb3VudDsgaSsrKSB7CisgICAgICAgICAgICAgICAgaWYgKGVudHJ5LmRhdGEuaTMyW2ldID09IEFORFJPSURfU0hBRElOR19NT0RFKSB7CisgICAgICAgICAgICAgICAgICAgIGxlbnNTaGFkaW5nTW9kZVN1cHBvcnRlZCA9IHRydWU7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBWZWN0b3I8dWludDhfdD4gbHNjTW9kZXM7CisgICAgICAgIFZlY3Rvcjx1aW50OF90PiBsc2NNYXBNb2RlczsKKyAgICAgICAgbHNjTW9kZXMucHVzaChBTkRST0lEX1NIQURJTkdfTU9ERV9GQVNUKTsKKyAgICAgICAgbHNjTW9kZXMucHVzaChBTkRST0lEX1NIQURJTkdfTU9ERV9ISUdIX1FVQUxJVFkpOworICAgICAgICBsc2NNYXBNb2Rlcy5wdXNoKEFORFJPSURfU1RBVElTVElDU19MRU5TX1NIQURJTkdfTUFQX01PREVfT0ZGKTsKKyAgICAgICAgaWYgKGxlbnNTaGFkaW5nTW9kZVN1cHBvcnRlZCkgeworICAgICAgICAgICAgbHNjTW9kZXMucHVzaChBTkRST0lEX1NIQURJTkdfTU9ERV9PRkYpOworICAgICAgICAgICAgbHNjTWFwTW9kZXMucHVzaChBTkRST0lEX1NUQVRJU1RJQ1NfTEVOU19TSEFESU5HX01BUF9NT0RFX09OKTsKKyAgICAgICAgfQorICAgICAgICBjaGFycy51cGRhdGUoQU5EUk9JRF9TSEFESU5HX0FWQUlMQUJMRV9NT0RFUywgbHNjTW9kZXMpOworICAgICAgICBjaGFycy51cGRhdGUoQU5EUk9JRF9TVEFUSVNUSUNTX0lORk9fQVZBSUxBQkxFX0xFTlNfU0hBRElOR19NQVBfTU9ERVMsIGxzY01hcE1vZGVzKTsKKworICAgICAgICBlbnRyeSA9IGNoYXJzLmZpbmQoQU5EUk9JRF9SRV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5jZSBIQUwzLjMKKyAgICAgICAgLy8gYWRkcyBiYXRjaCBzaXplIHRvIHRoaXMgYXJyYXkuCisgICAgICAgIGVudHJ5ID0gY2hhcnMuZmluZChBTkRST0lEX0NPTlRST0xfQVZBSUxBQkxFX0hJR0hfU1BFRURfVklERU9fQ09ORklHVVJBVElPTlMpOworICAgICAgICBpZiAoZW50cnkuY291bnQgPiAwKSB7CisgICAgICAgICAgICBWZWN0b3I8aW50MzJfdD4gaGlnaFNwZWVkQ29uZmlnOworICAgICAgICAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBlbnRyeS5jb3VudDsgaSArPSA0KSB7CisgICAgICAgICAgICAgICAgaGlnaFNwZWVkQ29uZmlnLmFkZChlbnRyeS5kYXRhLmkzMltpXSk7IC8vIHdpZHRoCisgICAgICAgICAgICAgICAgaGlnaFNwZWVkQ29uZmlnLmFkZChlbnRyeS5kYXRhLmkzMltpICsgMV0pOyAvLyBoZWlnaHQKKyAgICAgICAgICAgICAgICBoaWdoU3BlZWRDb25maWcuYWRkKGVudHJ5LmRhdGEuaTMyW2kgKyAyXSk7IC8vIGZwc19taW4KKyAgICAgICAgICAgICAgICBoaWdoU3BlZWRDb25maWcuYWRkKGVudHJ5LmRhdGEuaTMyW2kgKyAzXSk7IC8vIGZwc19tYXgKKyAgICAgICAgICAgICAgICBoaWdoU3BlZWRDb25maWcuYWRkKDEpOyAvLyBiYXRjaFNpemVfbWF4LiBkZWZhdWx0IHRvIDEgZm9yIEhBTDMuMgorICAgICAgICAgICAgfQorICAgICAgICAgICAgY2hhcnMudXBkYXRlKEFORFJPSURfQ09OVFJPTF9BVkFJTEFCTEVfSElHSF9TUEVFRF9WSURFT19DT05GSUdVUkFUSU9OUywKKyAgICAgICAgICAgICAgICAgICAgaGlnaFNwZWVkQ29uZmlnKTsKKyAgICAgICAgfQogICAgIH0KICAgICByZXR1cm47CiB9CmRpZmYgLS1naXQgYS9zZXJ2aWNlcy9jYW1lcmEvbGliY2FtZXJh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MT0dXKCIlczogJWQ6IGNvdWxkbid0IGdldCBpbnB1dCBidWZmZXIgd2hpbGUgY2xlYXJpbmcgdGhlIHJlcXVlc3QgIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICJsaXN0OiAlcyAoJWQpIiwgX19GVU5DVElPTl9fLCBfX0xJTkVfXywgc3RyZXJyb3IoLXJlcyksIHJlcyk7CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgcmVzID0gKCppdCktPm1JbnB1dFN0cmVhbS0+cmV0dXJuSW5wdXRCdWZmZXIoaW5wdXRCdWZmZXIpOworICAgICAgICAgICAgICAgICAgICBpZiAocmVzICE9IE9LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6ICVkOiBjb3VsZG4ndCByZXR1cm4gaW5wdXQgYnVmZmVyIHdoaWxlIGNsZWFyaW5nIHRoZSByZXF1ZXN0ICIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImxpc3Q6ICVzICglZCkiLCBfX0ZVTkNUSU9OX18sIF9fTElORV9fLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KICAgICAgICAgICAgIC8vIFNldCB0aGUgZnJhbWUgbnVtYmVyIHRoaXMgcmVxdWVzdCB3b3VsZCBoYXZlIGhhZCwgaWYgaXQKICAgICAgICAgICAgIC8vIGhhZCBiZWVuIHN1Ym1pdHRlZDsgdGhpcyBmcmFtZSBudW1iZXIgd2lsbCBub3QgYmUgcmV1c2VkLgogICAgICAgICAgICAgLy8gVGhlIHJlcXVlc3RJZCBhbmQgYnVyc3RJZCBmaWVsZHMgd2VyZSBzZXQgd2hlbiB0aGUgcmVxdWVzdCB3YXMKQEAgLTI3NTIsMjkgKzI3NzQsMTEgQEAKICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXyk7CiAgICAgfQogCi0gICA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CdWZmZXIoJm5leHRSZXF1ZXN0LT5tSW5wdXRCdWZmZXIpOworICAgICAgICAgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICAgICAgICAgIC8vIENhbid0IGdldCBpbnB1dCBidWZmZXIgZnJvbSBncmFsbG9jIHF1ZXVlIC0gdGhpcyBjb3VsZCBiZSBkdWUgdG8KKyAgICAgICAgICAgICAgICAvLyBkaXNjb25uZWN0ZWQgcXVldWUgb3Igb3RoZXIgcHJvZHVjZXIgbWlzYmVoYXZpb3IsIHNvIG5vdCBhIGZhdGFsCisgICAgICAgICAgICAgICAgLy8gZXJyb3IKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IENhbid0IGdldCBpbnB1dCBidWZmZXIsIHNraXBwaW5nIHJlcXVlc3Q6IgorICAgICAgICAgICAgICAgICAgICAgICAgIiAlcyAoJWQpIiwgX19GVU5DVElPTl9fLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKKyAgICAgICAgICAgICAgICBpZiAobUxpc3RlbmVyICE9IE5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgbUxpc3RlbmVyLT5ub3RpZnlFcnJvcigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBJQ2FtZXJhRGV2aWNlQ2FsbGJhY2tzOjpFUlJPUl9DQU1FUkFfUkVRVUVTVCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXh0UmVxdWVzdC0+bVJlc3VsdEV4dHJhcyk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIHJldHVybiBOVUxMOworICAgICAgICAgICAgfQorICAgICAgICB9CiAgICAgfQorICAgIG1OZXh0UmVxdWVzdCA9IG5leHRSZXF1ZXN0OworCiAgICAgcmV0dXJuIG5leHRSZXF1ZXN0OwogfQogCmRpZmYgLS1naXQgYS9zZXJ2aWNlcy9jYW1lcmEvbGliY2FtZXJhc2VydmljZS9kZXZpY2UzL0NhbWVyYTNEZXZpY2UuaCBiL3NlcnZpY2VzL2N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gICAgYm9vbCAgICAgICAgICAgICAgICAgICAgICAgbUlzQ29uc3RyYWluZWRIaWdoU3BlZWRDb25maWd1cmF0aW9uOworCiAgICAgLyoqKiogU2NvcGUgZm9yIG1Mb2NrICoqKiovCiAKICAgICBjYW1lcmEzX2RldmljZV90ICAgICAgICAgICptSGFsM0RldmljZTsKQEAgLTIzNCw2ICsyMzgsNyBAQAogICAgICAgcHVibGljOgogICAgICAgICBDYW1lcmFNZXRhZGF0YSAgICAgICAgICAgICAgICAgICAgICBtU2V0dGluZ3M7CiAgICAgICAgIHNwPGNhbWVyYTM6OkNhbWVyYTNTdHJlYW0+ICAgICAgICAgIG1JbnB1dFN0cmVhbTsKKyAgICAgICAgY2FtZXJhM19zdHJlYW1fYnVmZmVyX3QgICAgICAgICAgICAgbUlucHV0QnVmZmVyOwogICAgICAgICBWZWN0b3I8c3A8Y2FtZXJhMzo6Q2FtZXJhM091dHB1dFN0cmVhbUludGVyZmFjZT4gPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtT3V0cHV0U3RyZWFtczsKICAgICAgICAgQ2FwdHVyZVJlc3VsdEV4dHJhcyAgICAgICAgICAgICAgICAgbVJlc3VsdEV4dHJhczsKQEAgLTUwMSw2ICs1MDYsMTAgQEAKICAgICAgICAgQ29uZGl0aW9uICAgICAgICAgIG1SZXF1ZXN0U2lnbmFsOwogICAgICAgICBSZXF1ZXN0TGlzdCAgICAgICAgbVJlcXVlc3RRdWV1ZTsKICAgICAgICAgUmVxdWVzdExpc3QgICAgICAgIG1SZXBlYXRpbmdSZXF1ZXN0czsKKyAgICAgICAgLy8gVGhlIG5leHQgcmVxdWVzdCBiZWluZyBwcmVwcGVkIGZvciBzdWJtaXNzaW9uIHRvIHRoZSBIQUwsIG5vIGxvbmdlcgorICAgICAgICAvLyBvbiB0aGUgcmVxdWVzdCBxdWV1ZS4gUmVhZC1vbmx5IGV2ZW4gd2l0aCBtUmVxdWVzdExvY2sgaGVsZCwg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ICAgICAgIH0KLSAgICAgICAgICAgIHJldHVybiBmYWxzZTsKLSAgICAgICAgfSksIG1DbGllbnRzLmVuZCgpKTsKKyAgICBpZiAoaXRlciAhPSBldmljdGVkLmNlbmQoKSkgewogCisgICAgICAgIGlmIChtTGlzdGVuZXIgIT0gbnVsbHB0cikgbUxpc3RlbmVyLT5vbkNsaWVudFJlbW92ZWQoKippdGVyKTsKKworICAgICAgICAvLyBSZW1vdmUgZXZpY3RlZCBjbGllbnRzIGZyb20gbGlzdAorICAgICAgICBtQ2xpZW50cy5lcmFzZShzdGQ6OnJlbW92ZV9pZihtQ2xpZW50cy5iZWdpbigpLCBtQ2xpZW50cy5lbmQoKSwKKyAgICAgICAgICAgIFsmaXRlcl0gKHN0ZDo6c2hhcmVkX3B0cjxDbGllbnREZXNjcmlwdG9yPEtFWSwgVkFMVUU+PiYgY3VyQ2xpZW50UHRyKSB7CisgICAgICAgICAgICAgICAgaWYgKGN1ckNsaWVudFB0ci0+Z2V0S2V5KCkgPT0gKCppdGVyKS0+Z2V0S2V5KCkpIHsKKyAgICAgICAgICAgICAgICAgICAgaXRlcisrOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICAgICAgfSksIG1DbGllbnRzLmVuZCgpKTsKKyAgICB9CisKKyAgICBpZiAobUxpc3RlbmVyICE9IG51bGxwdHIpIG1MaXN0ZW5lci0+b25DbGllbnRBZGRlZCgqY2xpZW50KTsKICAgICBtQ2xpZW50cy5wdXNoX2JhY2soY2xpZW50KTsKICAgICBtUmVtb3ZlZENvbmRpdGlvbi5icm9hZGNhc3QoKTsKIAogICAgIHJldHVybiBldmljdGVkOwogfQogCi10ZW1wbGF0ZTxjbGFzcyBLRVksIGNsYXNzIFZBTFVFPgordGVtcGxhdGU8Y2xhc3MgS0VZLCBjbGFzcyBWQUxVRSwgY2xhc3MgTElTVEVORVI+C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mZlcik7CiAKLSAgICBzbnByaW50ZihidWZmZXIsIFNJWkUsICIgIFByb2Nlc3NlczpcbiIpOwotICAgIHJlc3VsdC5hcHBlbmQoYnVmZmVyKTsKKyAgICByZXN1bHQuYXBwZW5kKCIgIFByb2Nlc3NlczpcbiIpOwogICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgbU1hcC5zaXplKCk7ICsraSkgewogICAgICAgICBzbnByaW50ZihidWZmZXIsIFNJWkUsICIgICAgUGlkOiAlZFxuIiwgbU1hcC5rZXlBdChpKSk7CiAgICAgICAgIHJlc3VsdC5hcHBlbmQoYnVmZmVyKTsKIAogICAgICAgICBjb25zdCBSZXNvdXJjZUluZm9zICZpbmZvcyA9IG1NYXAudmFsdWVBdChpKTsKICAgICAgICAgZm9yIChzaXplX3QgaiA9IDA7IGogPCBpbmZvcy5zaXplKCk7ICsraikgewotICAgICAgICAgICAgc25wcmludGYoYnVmZmVyLCBTSVpFLCAiICAgICAgQ2xpZW50OlxuIik7Ci0gICAgICAgICAgICByZXN1bHQuYXBwZW5kKGJ1ZmZlcik7CisgICAgICAgICAgICByZXN1bHQuYXBwZW5kKCIgICAgICBDbGllbnQ6XG4iKTsKICAgICAgICAgICAgIHNucHJpbnRmKGJ1ZmZlciwgU0laRSwgIiAgICAgICAgSWQ6ICVsbGRcbiIsIChsb25nIGxvbmcpaW5mb3Nbal0uY2xpZW50SWQpOwogICAgICAgICAgICAgcmVzdWx0LmFwcGVuZChidWZmZXIpOwogCkBAIC0xMjAsMTQgKzExOSwxNSBAQAogICAgICAgICAgICAgcmVzdWx0LmFwcGVuZChidWZmZXIpOwogCiAgICAgICAgICAgICBWZWN0b3I8TWVkaWFSZXNvdXJjZT4gcmVzb3VyY2VzID0gaW5mb3Nbal0ucmVzb3VyY2VzOwotICAgICAgICAgICAgc25wcmludGYoYnVmZmVyLCBTSVpFLCAiICAgICAgICBSZXNvdXJjZXM6XG4iKTsKLSAgICAgICAgICAgIHJlc3VsdC5hcHBlb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gICAgICAgICAgU3RyaW5nOCgiZmFsc2UiKSkpOwogICAgICAgICBtU2VydmljZS0+Y29uZmlnKHBvbGljaWVzMSk7CiAgICAgICAgIEVYUEVDVF9UUlVFKG1TZXJ2aWNlLT5tU3VwcG9ydHNNdWx0aXBsZVNlY3VyZUNvZGVjcyk7CiAgICAgICAgIEVYUEVDVF9GQUxTRShtU2VydmljZS0+bVN1cHBvcnRzU2VjdXJlV2l0aE5vblNlY3VyZUNvZGVjKTsKIAogICAgICAgICBWZWN0b3I8TWVkaWFSZXNvdXJjZVBvbGljeT4gcG9saWNpZXMyOwotICAgICAgICBwb2xpY2llczIucHVzaF9iYWNrKE1lZGlhUmVzb3VyY2VQb2xpY3koU3RyaW5nOChrUG9saWN5U3VwcG9ydHNNdWx0aXBsZVNlY3VyZUNvZGVjcyksIDApKTsKICAgICAgICAgcG9saWNpZXMyLnB1c2hfYmFjaygKLSAgICAgICAgICAgICAgICBNZWRpYVJlc291cmNlUG9saWN5KFN0cmluZzgoa1BvbGljeVN1cHBvcnRzU2VjdXJlV2l0aE5vblNlY3VyZUNvZGVjKSwgMSkpOworICAgICAgICAgICAgICAgIE1lZGlhUmVzb3VyY2VQb2xpY3koCisgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmc4KGtQb2xpY3lTdXBwb3J0c011bHRpcGxlU2VjdXJlQ29kZWNzKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZzgoImZhbHNlIikpKTsKKyAgICAgICAgcG9saWNpZXMyLnB1c2hfYmFjaygKKyAgICAgICAgICAgICAgICBNZWRpYVJlc291cmNlUG9saWN5KAorICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nOChrUG9saWN5U3VwcG9ydHNTZWN1cmVXaXRoTm9uU2VjdXJlQ29kZWMpLAorICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nOCgidHJ1ZSIpKSk7CiAgICAgICAgIG1TZXJ2aWNlLT5jb25maWcocG9saWNpZXMyKTsKICAgICAgIC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