ZGlmZiAtLWdpdCBhL0FuZHJvaWQuYnAgYi9BbmRyb2lkLmJwCmluZGV4IDU1Njc4NGYuLjEwNDVkYzIgMTAwNjQ0Ci0tLSBhL0FuZHJvaWQuYnAKKysrIGIvQW5kcm9pZC5icApAQCAtMTcsNiArMTcsNyBAQAogICAgICAgICAiLSoiLAogICAgICAgICAiY2VydC0qIiwKICAgICAgICAgImNsYW5nLWFuYWx5emVyLXNlY3VyaXR5KiIsCisgICAgICAgICJhbmRyb2lkLSoiLAogICAgIF0sCiAgICAgdGlkeV9mbGFnczogWwogICAgICAgICAiLXdhcm5pbmdzLWFzLWVycm9ycz1jbGFuZy1hbmFseXplci1zZWN1cml0eSosY2VydC0qIiwKQEAgLTMxLDYgKzMyLDcgQEAKICAgICAgICAgImxpYmJvb3Rsb2FkZXJfbWVzc2FnZSIsCiAgICAgICAgICJsaWJmZWMiLAogICAgICAgICAibGliZmVjX3JzIiwKKyAgICAgICAgImxpYmZzX2F2YiIsCiAgICAgICAgICJsaWJmc19tZ3IiLAogICAgICAgICAibGlic2NyeXB0X3N0YXRpYyIsCiAgICAgICAgICJsaWJzcXVhc2hmc191dGlscyIsCkBAIC0zOSw2ICs0MSw3IEBACiAgICAgc2hhcmVkX2xpYnM6IFsKICAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUua2V5bWFzdGVyQDMuMCIsCiAgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmtleW1hc3RlckA0LjAiLAorICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5ib290QDEuMCIsCiAgICAgICAgICJsaWJiYXNlIiwKICAgICAgICAgImxpYmJpbmRlciIsCiAgICAgICAgICJsaWJjcnlwdG8iLApAQCAtNDcsNiArNTAsNyBAQAogICAgICAgICAibGliZGlza2NvbmZpZyIsCiAgICAgICAgICJsaWJleHQ0X3V0aWxzIiwKICAgICAgICAgImxpYmYyZnNfc3BhcnNlYmxvY2siLAorICAgICAgICAibGliZnNjcnlwdCIsCiAgICAgICAgICJsaWJoYXJkd2FyZSIsCiAgICAgICAgICJsaWJoYXJkd2FyZV9sZWdhY3kiLAogICAgICAgICAibGliaGlkbGJhc2UiLApAQCAtOTMsMTIgKzk3LDE0IEBACiAgICAgXSwKIAogICAgIHNyY3M6IFsKKyAgICAgICAgIkFwcEZ1c2VVdGlsLmNwcCIsCiAgICAgICAgICJCZW5jaG1hcmsuY3BwIiwKICAgICAgICAgIkNoZWNrRW5jcnlwdGlvbi5jcHAiLAorICAgICAgICAiQ2hlY2twb2ludC5jcHAiLAogICAgICAgICAiRGV2bWFwcGVyLmNwcCIsCiAgICAgICAgICJFbmNyeXB0SW5wbGFjZS5jcHAiLAotICAgICAgICAiRXh0NENyeXB0LmNwcCIsCiAgICAgICAgICJGaWxlRGV2aWNlVXRpbHMuY3BwIiwKKyAgICAgICAgIkZzQ3J5cHQuY3BwIiwKICAgICAgICAgIklkbGVNYWludC5jcHAiLAogICAgICAgICAiS2V5QnVmZmVyLmNwcCIsCiAgICAgICAgICJLZXlTdG9yYWdlLmNwcCIsCkBAIC0xMjYsMTkgKzEzMiwzMCBAQAogICAgICAgICAibW9kZWwvUHJpdmF0ZVZvbHVtZS5jcHAiLAogICAgICAgICAibW9kZWwvUHVibGljVm9sdW1lLmNwcCIsCiAgICAgICAgICJtb2RlbC9Wb2x1bWVCYXNlLmNwcCIsCi0gICAgICAgICJzZWNvbnRleHQuY3BwIiwKKyAgICAgICAgIm1vZGVsL1N0dWJWb2x1bWUuY3BwIiwKICAgICBdLAogICAgIHByb2R1Y3RfdmFyaWFibGVzOiB7CiAgICAgICAgIGFyYzogewogICAgICAgICAgICAgZXhjbHVkZV9zcmNzOiBbCisgICAgICAgICAgICAgICAgIkFwcEZ1c2VVdGlsLmNwcCIsCiAgICAgICAgICAgICAgICAgIm1vZGVsL09iYlZvbHVtZS5jcHAiLAogICAgICAgICAgICAgXSwKICAgICAgICAgICAgIHN0YXRpY19saWJzOiBbCiAgICAgICAgICAgICAgICAgImFyY19zZXJ2aWNlc19haWRsIiwKKyAgICAgICAgICAgICAgICAibGliYXJjYXBwZnVzZSIsCiAgICAgICAgICAgICAgICAgImxpYmFyY29iYnZvbHVtZSIsCiAgICAgICAgICAgICBdLAogICAgICAgICB9LAorICAgICAgICBkZWJ1Z2dhYmxlOiB7CisgICAgICAgICAgICBjcHBmbGFnczogWyItRF9fQU5EUk9JRF9ERUJVR0dBQkxFX18iXSwKKyAgICAgICAgfSwKICAgICB9LAorICAgIHNoYXJlZF9saWJzOiBbCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmhlYWx0aC5zdG9yYWdlQDEuMCIsCisgICAgXSwKKyAgICB3aG9sZV9zdGF0aWNfbGliczogWworICAgICAgICAiY29tLmFuZHJvaWQuc3lzcHJvcC5hcGV4IiwKKyAgICBdLAogfQogCiBjY19iaW5hcnkgewpAQCAtMTU0LDYgKzE3MSw3IEBACiAgICAgICAgIGFyYzogewogICAgICAgICAgICAgc3RhdGljX2xpYnM6IFsKICAgICAgICAgICAgICAgICAiYXJjX3NlcnZpY2VzX2FpZGwiLAorICAgICAgICAgICAgICAgICJsaWJhcmNhcHBmdXNlIiwKICAgICAgICAgICAgICAgICAibGliYXJjb2Jidm9sdW1lIiwKICAgICAgICAgICAgIF0sCiAgICAgICAgIH0sCkBAIC0xNjgsNiArMTg2LDExIEBACiAgICAgICAgICJ2b2xkX3ByZXBhcmVfc3ViZGlycyIsCiAgICAgICAgICJ3YWl0X2Zvcl9rZXltYXN0ZXIiLAogICAgIF0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5oZWFsdGguc3RvcmFnZUAxLjAiLAorICAgICAgICAibGliaGlkbHRyYW5zcG9ydCIsCisgICAgXSwKIH0KIAogY2NfYmluYXJ5IHsKZGlmZiAtLWdpdCBhL0FwcEZ1c2VVdGlsLmNwcCBiL0FwcEZ1c2VVdGlsLmNwcApuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAw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YgcGF0aCkgeworICAgIGNvbnN0IGF1dG8gb3B0cyA9IFN0cmluZ1ByaW50ZigKKyAgICAgICAgImZkPSVpLCIKKyAgICAgICAgInJvb3Rtb2RlPTQwMDAwLCIKKyAgICAgICAgImRlZmF1bHRfcGVybWlzc2lvbnMsIgorICAgICAgICAiYWxsb3dfb3RoZXIsIgorICAgICAgICAidXNlcl9pZD0wLGdyb3VwX2lkPTAsIgorICAgICAgICAiY29udGV4dD1cInU6b2JqZWN0X3I6YXBwX2Z1c2VfZmlsZTpzMFwiLCIKKyAgICAgICAgImZzY29udGV4dD11Om9iamVjdF9yOmFwcF9mdXNlZnM6czAiLAorICAgICAgICBkZXZpY2VfZmQpOworCisgICAgY29uc3QgaW50IHJlc3VsdCA9CisgICAgICAgIFRFTVBfRkFJTFVSRV9SRVRSWShtb3VudCgiL2Rldi9mdXNlIiwgcGF0aC5jX3N0cigpLCAiZnVzZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNU19OT1NVSUQgfCBNU19OT0RFViB8IE1TX05PRVhFQyB8IE1TX05PQVRJTUUsIG9wdHMuY19zdHIoKSkpOworICAgIGlmIChyZXN1bHQgIT0gMCkgeworICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIG1vdW50ICIgPDwgcGF0aDsKKyAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICB9CisKKyAgICByZXR1cm4gYW5kcm9pZDo6T0s7Cit9CisKK3N0YXRpYyBhbmRyb2lkOjpzdGF0dXNfdCBSdW5Db21tYW5kKGNvbnN0IHN0ZDo6c3RyaW5nJiBjb21tYW5kLCB1aWRfdCB1aWQsIGNvbnN0IHN0ZDo6c3RyaW5nJiBwYXRoLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGRldmljZV9mZCkgeworICAgIGlmIChERUJVR19BUFBGVVNFKSB7CisgICAgICAgIExPRyhERUJVRykgPDwgIlJ1biBhcHAgZnVzZSBjb21tYW5kICIgPDwgY29tbWFuZCA8PCAiIGZvciB0aGUgcGF0aCAiIDw8IHBhdGggPDwgIiBhbmQgdWlkICIKKyAgICAgICAgICAgICAgICAgICA8PCB1aWQ7CisgICAgfQorCisgICAgaWYgKGNvbW1hbmQgPT0gIm1vdW50IikgeworICAgICAgICByZXR1cm4gTW91bnQoZGV2aWNlX2ZkLCBwYXRoKTsKKyAgICB9IGVsc2UgaWYgKGNvbW1hbmQgPT0gInVubW91bnQiKSB7CisgICAgICAgIC8vIElmIGl0J3MganVzdCBhZnRlciBhbGwgRkQgb3BlbmVkIG9uIG1vdW50IHBvaW50IGFyZSBjbG9zZWQsIHVtb3VudDIgY2FuIGZhaWwgd2l0aAorICAgICAgICAvLyBFQlVTWS4gVG8gYXZvaWQgdGhlIGNhc2UsIHNwZWNpZnkgTU5UX0RFVEFDSC4KKyAgICAgICAgaWYgKHVtb3VudDIocGF0aC5jX3N0cigpLCBVTU9VTlRfTk9GT0xMT1cgfCBNTlRfREVUQUNIKSAhPSAwICYmIGVycm5vICE9IEVJTlZBTCAmJgorICAgICAgICAgICAgZXJybm8gIT0gRU5PRU5UKSB7CisgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIHVubW91bnQgZGlyZWN0b3J5LiI7CisgICAgICAgICAgICByZXR1cm4gLWVycm5vOworICAgICAgICB9CisgICAgICAgIGlmIChybWRpcihwYXRoLmNfc3RyKCkpICE9IDApIHsKKyAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gcmVtb3ZlIHRoZSBtb3VudCBkaXJlY3RvcnkuIjsKKyAgICAgICAgICAgIHJldHVybiAtZXJybm87CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIGFuZHJvaWQ6Ok9LOworICAgIH0gZWxzZSB7CisgICAgICAgIExPRyhFUlJPUikgPDwgIlVua25vd24gYXBwZnVzZSBjb21tYW5kICIgPDwgY29tbWFuZDsKKyAgICAgICAgcmV0dXJuIC1FU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RlX2ZpbGVuYW1lKSkgeworICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIHdyaXRlIHRvIGZpbGUgIiA8PCBzdGF0ZV9maWxlbmFtZTsKKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKworICAgIHJldHVybiB0cnVlOworfQorCit9ICAvLyBuYW1lc3BhY2UKKworU3RhdHVzIGNwX3N1cHBvcnRzQ2hlY2twb2ludChib29sJiByZXN1bHQpIHsKKyAgICByZXN1bHQgPSBmYWxzZTsKKworICAgIGZvciAoY29uc3QgYXV0byYgZW50cnkgOiBmc3RhYl9kZWZhdWx0KSB7CisgICAgICAgIGlmIChlbnRyeS5mc19tZ3JfZmxhZ3MuY2hlY2twb2ludF9ibGsgfHwgZW50cnkuZnNfbWdyX2ZsYWdzLmNoZWNrcG9pbnRfZnMpIHsKKyAgICAgICAgICAgIHJlc3VsdCA9IHRydWU7CisgICAgICAgICAgICByZXR1cm4gU3RhdHVzOjpvaygpOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiBTdGF0dXM6Om9rKCk7Cit9CisKK1N0YXR1cyBjcF9zdXBwb3J0c0Jsb2NrQ2hlY2twb2ludChib29sJiByZXN1bHQpIHsKKyAgICByZXN1bHQgPSBmYWxzZTsKKworICAgIGZvciAoY29uc3QgYXV0byYgZW50cnkgOiBmc3RhYl9kZWZhdWx0KSB7CisgICAgICAgIGlmIChlbnRyeS5mc19tZ3JfZmxhZ3MuY2hlY2twb2ludF9ibGspIHsKKyAgICAgICAgICAgIHJlc3VsdCA9IHRydWU7CisgICAgICAgICAgICByZXR1cm4gU3RhdHVzOjpvaygpOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiBTdGF0dXM6Om9rKCk7Cit9CisKK1N0YXR1cyBjcF9zdXBwb3J0c0ZpbGVDaGVja3BvaW50KGJvb2wmIHJlc3VsdCkgeworICAgIHJlc3VsdCA9IGZhbHNlOworCisgICAgZm9yIChjb25zdCBhdXRvJiBlbnRyeSA6IGZzdGFiX2RlZmF1bHQpIHsKKyAgICAgICAgaWYgKGVudHJ5LmZzX21ncl9mbGFncy5jaGVja3BvaW50X2ZzKSB7CisgICAgICAgICAgICByZXN1bHQgPSB0cnVlOworICAgICAgICAgICAgcmV0dXJuIFN0YXR1czo6b2soKTsKKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gU3RhdHVzOjpvaygpOworfQorCitTdGF0dXMgY3Bfc3RhcnRDaGVja3BvaW50KGludCByZXRyeSkgeworICAgIGlmIChyZXRyeSA8IC0xKSByZXR1cm4gU3RhdHVzOjpmcm9tRXhjZXB0aW9uQ29kZShFSU5WQUwsICJSZXRyeSBjb3VudCBtdXN0IGJlIG1vcmUgdGhhbiAtMSIpOworICAgIHN0ZDo6c3RyaW5nIGNvbnRlbnQgPSBzdGQ6OnRvX3N0cmluZyhyZXRyeSArIDEpOworICAgIGlmIChyZXRyeSA9PSAtMSkgeworICAgICAgICBzcDxJQm9vdENvbnRyb2w+IG1vZHVsZSA9IElCb290Q29udHJvbDo6Z2V0U2VydmljZSgpOworICAgICAgICBpZiAobW9kdWxlKSB7CisgICAgICAgICAgICBzdGQ6OnN0cmluZyBzdWZmaXg7CisgICAgICAgICAgICBhdXRvIGNiID0gWyZzdWZmaXhdKGhpZGxfc3RyaW5nIHMpIHsgc3VmZml4ID0gczsgfTsKKyAgICAgICAgICAgIGlmIChtb2R1bGUtPmdldFN1ZmZpeChtb2R1bGUtPmdldEN1cnJlbnRTbG90KCksIGNiKS5pc09rKCkpIGNvbnRlbnQgKz0gIiAiICsgc3VmZml4OworICAgICAgICB9CisgICAgfQorICAgIGlmICghYW5kcm9pZDo6YmFzZTo6V3JpdGVTdHJpbmdUb0ZpbGUoY29udGVudCwga01ldGFkYXRhQ1BGaWxlKSkKKyAgICAgICAgcmV0dXJuIFN0YXR1czo6ZnJvbUV4Y2VwdGlvbkNvZGUoZXJybm8sICJGYWlsZWQgdG8gd3JpdGUgY2hlY2twb2ludCBmaWxlI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2hpbmcgZnN0YWIgZW50cmllcyB0byBzZWUKKyAgICAvLyB0aGUgb3JpZ2luYWwgZmxhZ3MKKyAgICBzdGQ6OnN0cmluZyBlcnJfc3RyOworCisgICAgRnN0YWIgbW91bnRzOworICAgIGlmICghUmVhZEZzdGFiRnJvbUZpbGUoIi9wcm9jL21vdW50cyIsICZtb3VudHMpKSB7CisgICAgICAgIHJldHVybiBTdGF0dXM6OmZyb21FeGNlcHRpb25Db2RlKEVJTlZBTCwgIkZhaWxlZCB0byBnZXQgL3Byb2MvbW91bnRzIik7CisgICAgfQorCisgICAgLy8gV2FsayBtb3VudGVkIGZpbGUgc3lzdGVtcworICAgIGZvciAoY29uc3QgYXV0byYgbW91bnRfcmVjIDogbW91bnRzKSB7CisgICAgICAgIGNvbnN0IGF1dG8gZnN0YWJfcmVjID0gR2V0RW50cnlGb3JNb3VudFBvaW50KCZmc3RhYl9kZWZhdWx0LCBtb3VudF9yZWMubW91bnRfcG9pbnQpOworICAgICAgICBpZiAoIWZzdGFiX3JlYykgY29udGludWU7CisKKyAgICAgICAgaWYgKGZzdGFiX3JlYy0+ZnNfbWdyX2ZsYWdzLmNoZWNrcG9pbnRfZnMpIHsKKyAgICAgICAgICAgIGlmIChmc3RhYl9yZWMtPmZzX3R5cGUgPT0gImYyZnMiKSB7CisgICAgICAgICAgICAgICAgc3RkOjpzdHJpbmcgb3B0aW9ucyA9IG1vdW50X3JlYy5mc19vcHRpb25zICsgIixjaGVja3BvaW50PWVuYWJsZSI7CisgICAgICAgICAgICAgICAgaWYgKG1vdW50KG1vdW50X3JlYy5ibGtfZGV2aWNlLmNfc3RyKCksIG1vdW50X3JlYy5tb3VudF9wb2ludC5jX3N0cigpLCAibm9uZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgIE1TX1JFTU9VTlQgfCBmc3RhYl9yZWMtPmZsYWdzLCBvcHRpb25zLmNfc3RyKCkpKSB7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiBTdGF0dXM6OmZyb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TkRST0lEX1JCX1JFU1RBUlQyLCAwLCBtZXNzYWdlLmNfc3RyKCkpOworfQorCitib29sIGNwX25lZWRzUm9sbGJhY2soKSB7CisgICAgc3RkOjpzdHJpbmcgY29udGVudDsKKyAgICBib29sIHJldDsKKworICAgIHJldCA9IGFuZHJvaWQ6OmJhc2U6OlJlYWRGaWxlVG9TdHJpbmcoa01ldGFkYXRhQ1BGaWxlLCAmY29udGVudCk7CisgICAgaWYgKHJldCkgeworICAgICAgICBpZiAoY29udGVudCA9PSAiMCIpIHJldHVybiB0cnVlOworICAgICAgICBpZiAoY29udGVudC5zdWJzdHIoMCwgMykgPT0gIi0xICIpIHsKKyAgICAgICAgICAgIHN0ZDo6c3RyaW5nIG9sZFN1ZmZpeCA9IGNvbnRlbnQuc3Vic3RyKDMpOworICAgICAgICAgICAgc3A8SUJvb3RDb250cm9sPiBtb2R1bGUgPSBJQm9vdENvbnRyb2w6OmdldFNlcnZpY2UoKTsKKyAgICAgICAgICAgIHN0ZDo6c3RyaW5nIG5ld1N1ZmZpeDsKKworICAgICAgICAgICAgaWYgKG1vZHVsZSkgeworICAgICAgICAgICAgICAgIGF1dG8gY2IgPSBbJm5ld1N1ZmZpeF0oaGlkbF9zdHJpbmcgcykgeyBuZXdTdWZmaXggPSBzOyB9OworICAgICAgICAgICAgICAgIG1vZHVsZS0+Z2V0U3VmZml4KG1vZHVsZS0+Z2V0Q3VycmVudFNsb3QoKSwgY2IpOworICAgICAgICAgICAgICAgIGlmIChvbGRTdWZmaXggPT0gbmV3U3VmZml4KSByZXR1cm4gdHJ1ZTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gZmFsc2U7Cit9CisKK2Jvb2wgY3BfbmVlZHNDaGVja3BvaW50KCkgeworICAgIGJvb2wgcmV0OworICAgIHN0ZDo6c3RyaW5nIGNvbnRlbnQ7CisgICAgc3A8SUJvb3RDb250cm9sPiBtb2R1bGUgPSBJQm9vdENvbnRyb2w6O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VfZmlsZW5hbWUgPSBzdGQ6OnN0cmluZygiL3N5cy8iKSArIGJsa19kZXZpY2Uuc3Vic3RyKDUpICsgIi9ib3cvZnJlZSI7CisgICAgICAgICAgICBzdGQ6OnN0cmluZyBjb250ZW50OworICAgICAgICAgICAgcmV0ID0gYW5kcm9pZDo6YmFzZTo6UmVhZEZpbGVUb1N0cmluZyhzaXplX2ZpbGVuYW1lLCAmY29udGVudCk7CisgICAgICAgICAgICBpZiAocmV0KSB7CisgICAgICAgICAgICAgICAgZnJlZV9ieXRlcyA9IHN0ZDo6c3RydG91bChjb250ZW50LmNfc3RyKCksIE5VTEwsIDEwKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBpZiAoZnJlZV9ieXRlcyA8IG1pbl9mcmVlX2J5dGVzKSB7CisgICAgICAgICAgICBpZiAoY29tbWl0X29uX2Z1bGwpIHsKKyAgICAgICAgICAgICAgICBMT0coSU5GTykgPDwgIkxvdyBzcGFjZSBmb3IgY2hlY2twb2ludGluZy4gQ29tbWl0aW5nIGNoYW5nZXMiOworICAgICAgICAgICAgICAgIGNwX2NvbW1pdENoYW5nZXMoKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgTE9HKElORk8pIDw8ICJMb3cgc3BhY2UgZm9yIGNoZWNrcG9pbnRpbmcuIFJlYm9vdGluZyI7CisgICAgICAgICAgICAgICAgY3BfYWJvcnRDaGFuZ2VzKCJjaGVja3BvaW50LGxvd19zcGFjZSIsIGZhbHNlKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBuYW5vc2xlZXAoJnJlcSwgTlVMTCk7CisgICAgfQorfQorCit9ICAvLyBuYW1lc3BhY2UKKworU3RhdHVzIGNwX3ByZXBhcmVDaGVja3BvaW50KCkgeworICAgIGlmICghaXNDaGVja3BvaW50aW5nKSB7CisgICAgICAgIHJldHVybiBTdGF0dXM6Om9rKCk7CisgICAgfQorCisgICAgRnN0YWIgbW91bnRzOworICAgIGlmICghUmVhZEZzdGFiRnJvbUZpbGUoIi9wcm9jL21vdW50cyIsICZtb3VudHMpKSB7CisgICAgICAgIHJldHVybiBTdGF0dXM6OmZyb21FeGNlcHRpb25Db2RlKEVJTlZBTCwgIkZhaWxlZCB0byBnZXQgL3Byb2MvbW91bnRzIik7CisgICAgfQorCisgICAgZm9yIChjb25zdCBhdXRvJiBtb3VudF9yZWMgOiBtb3VudHMpIHsKKyAgICAgICAgY29uc3QgYXV0byBmc3RhYl9yZWMgPSBHZXRFbnRyeUZvck1vdW50UG9pbnQoJmZzdGFiX2RlZmF1bHQsIG1vdW50X3JlYy5tb3VudF9wb2ludCk7CisgICAgICAgIGlmICghZnN0YWJfcmVjKSBjb250aW51ZTsKKworICAgICAgICBpZiAoZnN0YWJfcmVjLT5mc19tZ3JfZmxhZ3MuY2hlY2twb2ludF9ibGspIHsKKyAgICAgICAgICAgIGFuZHJvaWQ6OmJhc2U6OnVuaXF1ZV9mZCBmZCgKKyAgICAgICAgICAgICAgICBURU1QX0ZBSUxVUkVfUkVUUlkob3Blbihtb3VudF9yZWMubW91bnRfcG9pbnQuY19zdHIoKSwgT19SRE9OTFkgfCBPX0NMT0VYRUMpKSk7CisgICAgICAgICAgICBpZiAoZmQgPT0gLTEpIHsKKyAgICAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIG9wZW4gbW91bnQgcG9pbnQiIDw8IG1vdW50X3JlYy5tb3VudF9wb2ludDsKKyAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgc3RydWN0IGZzdHJpbV9yYW5nZSByYW5nZSA9IHt9OworICAgICAgICAgICAgcmFuZ2UubGVuID0gVUxMT05HX01BWDsKKyAgICAgICAgICAgIGlmIChpb2N0bChmZCwgRklUUklNLCAmcmFuZ2UpKSB7CisgICAgICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byB0cmltICIgPDwgbW91bnRfcmVjLm1vdW50X3BvaW50OworICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBzZXRCb3dTdGF0ZShtb3VudF9yZWMuYmxrX2RldmljZSwgIjEiKTsKKyAgICAgICAgfQorICAgICAgICBpZiAoZnN0YWJfcmVjLT5mc19tZ3JfZmxhZ3MuY2hlY2twb2ludF9ibGsgfHwgZnN0YWJfcmVjLT5mc19tZ3JfZmxhZ3MuY2hlY2twb2ludF9mcykgeworICAgICAgICAgICAgc3RkOjp0aHJlYWQoY3BfaGVhbHRoRGFlbW9uLCBzdGQ6OnN0cmluZyhtb3VudF9yZWMubW91bnRfcG9pbnQpLAorICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjpzdHJpbmcobW91bnRfcmVjLmJsa19kZXZpY2UpLAorICAgICAgICAgICAgICAgICAgICAgICAgZnN0YWJfcmVjLT5mc19tZ3JfZmxhZ3MuY2hlY2twb2ludF9mcyA9PSAxKQorICAgICAgICAgICAgICAgIC5kZXRhY2goKTsKKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gU3RhdHVzOjpvaygpOworfQorCituYW1lc3BhY2UgeworY29uc3QgaW50IGtTZWN0b3JTaXplID0gNTEyOworCit0eXBlZGVmIHVpbnQ2NF90IHNlY3Rvcl90OworCitzdHJ1Y3QgbG9nX2VudHJ5IHsKKyAgICBzZWN0b3JfdCBzb3VyY2U7ICAvLyBpbiBzZWN0b3JzIG9mIHNpemUga1NlY3RvclNpemUKKyAgICBzZWN0b3JfdCBkZXN0OyAgICAvLyBpbiBzZWN0b3JzIG9mIHNpemUga1NlY3RvclNpemUKKyAgICB1aW50MzJfdCBzaXplOyAgICAvLyBpbiBieXRlcworICAgIHVpbnQzMl90IGNoZWNrc3VtOworfSBfX2F0dHJpYnV0ZV9fKChwYWNrZWQpKTsKKworc3RydWN0IGx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0LCAweEYxRDRFMjQyLCAweDY4RERCM0Y4LCAweDFGREE4MzZFLCAweDgxQkUxNkNELAorICAgICAgICAweEY2QjkyNjVCLCAweDZGQjA3N0UxLCAweDE4Qjc0Nzc3LCAweDg4MDg1QUU2LCAweEZGMEY2QTcwLCAweDY2MDYzQkNBLCAweDExMDEwQjVDLAorICAgICAgICAweDhGNjU5RUZGLCAweEY4NjJBRTY5LCAweDYxNkJGRkQzLCAweDE2NkNDRjQ1LCAweEEwMEFFMjc4LCAweEQ3MEREMkVFLCAweDRFMDQ4MzU0LAorICAgICAgICAweDM5MDNCM0MyLCAweEE3NjcyNjYxLCAweEQwNjAxNkY3LCAweDQ5Njk0NzRELCAweDNFNkU3N0RCLCAweEFFRDE2QTRBLCAweEQ5RDY1QURDLAorICAgICAgICAweDQwREYwQjY2LCAweDM3RDgzQkYwLCAweEE5QkNBRTUzLCAweERFQkI5RUM1LCAweDQ3QjJDRjdGLCAweDMwQjVGRkU5LCAweEJEQkRGMjFDLAorICAgICAgICAweENBQkFDMjhBLCAweDUzQjM5MzMwLCAweDI0QjRBM0E2LCAweEJBRDAzNjA1LCAweENERDcwNjkzLCAweDU0REU1NzI5LCAweDIzRDk2N0JGLAorICAgICAgICAweEIzNjY3QTJFLCAweEM0NjE0QUI4LCAweDVENjgxQjAyLCAweDJBNkYyQjk0LCAweEI0MEJCRTM3LCAweEMzMEM4RUExLCAweDVBMDVERjFCLAorICAgICAgICAweDJEMDJFRjhEfTsKKworICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgbl9ieXRlczsgKytpKSB7CisgICAgICAgICpjcmMgXj0gKCh1aW50OF90KilkYXRhKVtpXTsKKyAgICAgICAgKmNyYyA9IHRhYmxlWyh1aW50OF90KSpjcmNdIF4gKmNyYyA+PiA4OworICAgIH0KK30KKworLy8gQSBtYXAgb2YgcmVsb2NhdGlvbnMuCisvLyBUaGUgbWFwIG11c3QgYmUgaW5pdGlhbGl6ZWQgc28gdGhhdCByZWxvY2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0+c2l6ZSAtIDEpIC8ga1NlY3RvclNpemUgKyAxOworCisgICAgaWYgKGNoZWNrQ29sbGlzaW9uKHVzZWRfc2VjdG9ycywgbGUtPnNvdXJjZSwgbGUtPnNvdXJjZSArIGNvdW50KSkgeworICAgICAgICBmc3luYyhkZXZpY2VfZmQpOworICAgICAgICBsc2VlazY0KGRldmljZV9mZCwgMCwgU0VFS19TRVQpOworICAgICAgICBscy5jb3VudCA9IGluZGV4ICsgMTsKKyAgICAgICAgbHMubWFnaWMgPSBrUGFydGlhbFJlc3RvcmVNYWdpYzsKKyAgICAgICAgd3JpdGUoZGV2aWNlX2ZkLCAmbHNfYnVmZmVyWzBdLCBscy5ibG9ja19zaXplKTsKKyAgICAgICAgZnN5bmMoZGV2aWNlX2ZkKTsKKyAgICAgICAgdXNlZF9zZWN0b3JzLmNsZWFyKCk7CisgICAgICAgIHVzZWRfc2VjdG9yc1swXSA9IGZhbHNlOworICAgIH0KKworICAgIG1hcmtVc2VkKHVzZWRfc2VjdG9ycywgbGUtPmRlc3QsIGxlLT5kZXN0ICsgY291bnQpOworCisgICAgaWYgKGluZGV4ID09IDAgJiYgbHMuc2VxdWVuY2UgIT0gMCkgeworICAgICAgICBsb2dfc2VjdG9yX3YxXzAqIG5leHQgPSByZWludGVycHJldF9jYXN0PGxvZ19zZWN0b3JfdjFfMCo+KCZidWZmZXJbMF0pOworICAgICAgICBpZiAobmV4dC0+bWFnaWMgPT0ga01hZ2ljKSB7CisgICAgICAgICAgICBuZXh0LT5tYWdpYyA9IGtQYXJ0aWFsUmVzdG9yZU1hZ2ljOworICAgICAgICB9CisgICAgfQorCisgICAgbHNlZWs2NChkZXZpY2VfZmQsIGxlLT5zb3VyY2UgKiBrU2VjdG9yU2l6ZSwgU0VFS19TRVQpOworICAgIHdyaXRlKGRldmljZV9mZCwgJmJ1ZmZlclswXSwgbGUtPnNpemUpOworCisgICAgaWYgKGluZGV4ID09IDApIHsKKyAgICAgICAgZnN5bmMoZGV2aWNlX2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X2xzKSwgc2l6ZW9mKG9yaWdpbmFsX2xzKSk7CisgICAgICAgIGlmIChvcmlnaW5hbF9scy5tYWdpYyA9PSBrUGFydGlhbFJlc3RvcmVNYWdpYykgeworICAgICAgICAgICAgdmFsaWRhdGluZyA9IGZhbHNlOworICAgICAgICAgICAgYWN0aW9uID0gIlJlc3RvcmluZyI7CisgICAgICAgIH0gZWxzZSBpZiAob3JpZ2luYWxfbHMubWFnaWMgIT0ga01hZ2ljKSB7CisgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJObyBtYWdpYyI7CisgICAgICAgICAgICByZXR1cm4gU3RhdHVzOjpmcm9tRXhjZXB0aW9uQ29kZShFSU5WQUwsICJObyBtYWdpYyIpOworICAgICAgICB9CisKKyAgICAgICAgTE9HKElORk8pIDw8IGFjdGlvbiA8PCAiICIgPDwgb3JpZ2luYWxfbHMuc2VxdWVuY2UgPDwgIiBsb2cgc2VjdG9ycyI7CisKKyAgICAgICAgZm9yIChpbnQgc2VxdWVuY2UgPSBvcmlnaW5hbF9scy5zZXF1ZW5jZTsgc2VxdWVuY2UgPj0gMCAmJiBzdGF0dXMuaXNPaygpOyBzZXF1ZW5jZS0tKSB7CisgICAgICAgICAgICBhdXRvIGxzX2J1ZmZlciA9IHJlbG9jYXRlZFJlYWQoZGV2aWNlX2ZkLCByZWxvY2F0aW9ucywgdmFsaWRhdGluZywgMCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcmlnaW5hbF9scy5ibG9ja19zaXplLCBvcmlnaW5hbF9scy5ibG9ja19zaXplKTsKKyAgICAgICAgICAgIGxvZ19zZWN0b3JfdjFfMCYgbHMgPSAqcmVpbnRlcnByZXRfY2FzdDxsb2dfc2VjdG9yX3YxXzAqPigmbHNfYnVmZmVyWzBdKTsKKworICAgICAgICAgICAgVXNlZF9TZWN0b3JzIHVzZWRfc2VjdG9yczsKKyAgICAgICAgICAgIHVzZWRfc2VjdG9yc1swXSA9IGZhbHNlOworCisgICAgICAgICAgICBpZiAobHMubWFnaWMgIT0ga01hZ2ljICYmIChscy5tYWdpYyAhPSBrUGFydGlhbFJlc3RvcmVNYWdpYyB8fCB2YWxpZGF0aW5nKSkgeworICAgICAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIk5vIG1hZ2ljISI7CisgICAgICAgICAgICAgICAgc3RhdHVzID0gU3RhdHVzOjpmcm9tRXhjZXB0aW9uQ29kZShFSU5WQUwsICJObyBtYWdpYyIpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBpZiAobHMuYmxvY2tfc2l6ZSAhPSBvcmlnaW5hbF9scy5ibG9ja19zaXplKSB7CisgICAgICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiQmxvY2sgc2l6ZSBtaXNtYXRjaCEiOworICAgICAgICAgICAgICAgIHN0YXR1cyA9IFN0YXR1czo6ZnJvbUV4Y2VwdGlvbkNvZGUoRUlOVkFMLCAiQmxvY2sgc2l6ZSBtaXNtYXRjaCIpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBpZiAoKGludClscy5zZXF1ZW5jZSAhPSBzZXF1ZW5jZSkgeworICAgICAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkV4cGVjdGluZyBsb2cgc2VjdG9yICIgPDwgc2VxdWVuY2UgPDwgIiBidXQgZ290ICIgPDwgbHMuc2VxdWVuY2U7CisgICAgICAgICAgICAgICAgc3RhdHVzID0gU3RhdHVzOjpmcm9tRXhjZXB0aW9uQ29kZSgKKyAgICAgICAgICAgICAgICAgICAgRUlOVkFMLCAoIkV4cGVjdGluZyBsb2cgc2VjdG9yICIgKyBzdGQ6OnRvX3N0cmluZyhzZXF1ZW5jZSkgKyAiIGJ1dCBnb3QgIiArCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZDo6dG9fc3RyaW5nKGxzLnNlcXVlbmNlKSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNfc3RyKCkpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBMT0coSU5GTykgPDwgYWN0aW9uIDw8ICIgZnJvbSBsb2cgc2VjdG9yICIgPDwgbHMuc2VxdWVuY2U7CisgICAgICAgICAgICBmb3IgKGxvZ19lbnRyeSogbGUgPQorICAgICAgICAgICAgICAgICAgICAgcmVpbnRlcnByZXRfY2FzdDxsb2dfZW50cnkqPigmbHNfYnVmZmVyW2xzLmhlYWRlcl9zaXplXSkgKyBscy5jb3VudCAtIDE7CisgICAgICAgICAgICAgICAgIGxlID49IHJlaW50ZXJwcmV0X2Nhc3Q8bG9nX2VudHJ5Kj4oJmxzX2J1ZmZlcltscy5oZWFkZXJfc2l6ZV0pOyAtLWxlKSB7CisgICAgICAgICAgICAgICAgLy8gVGhpcyBpcyB2ZXJ5IG5vaXN5IC0gbGltaXQgdG8gREVCVUcgb25seQorICAgICAgICAgICAgICAgIExPRyhWRVJCT1NFKSA8PCBhY3Rpb24gPDwgIiAiIDw8IGxlLT5zaXplIDw8ICIgYnl0ZXMgZnJvbSBzZWN0b3IgIiA8PCBsZS0+ZGVzdAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8PCAiIHRvICIgPDwgbGUtPnNvdXJjZSA8PCAiIHdpdGggY2hlY2tzdW0gIiA8PCBzdGQ6OmhleAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8PCBsZS0+Y2hlY2tzdW07CisKKyAgICAgICAgICAgICAgICBhdXRvIGJ1ZmZlciA9IHJlbG9jYXRlZFJlYWQoZGV2aWNlX2ZkLCByZWxvY2F0aW9ucywgdmFsaWRhdGluZywgbGUtPmRlc3QsIGxlLT5zaXplLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBscy5ibG9ja19zaXplKTsKKyAgICAgICAgICAgICAgICB1aW50MzJfdCBjaGVja3N1bSA9IGxlLT5zb3VyY2UgLyAobHMuYmxvY2tfc2l6ZSAvIGtTZWN0b3JTaXplKTsKKyAgICAgICAgICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IGxlLT5zaXplOyBpICs9IGxzLmJsb2NrX3NpemUpIHsKKyAgICAgICAgICAgICAgICAgICAgY3JjMzIoJmJ1ZmZlcltpXSwgbHMuYmxvY2tfc2l6ZSwgJmNoZWNrc3VtKTsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBpZiAobGUtPmNoZWNrc3VtICYmIGNoZWNrc3VtICE9IGxlLT5jaGVja3N1bSkgeworICAgICAgICAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJDaGVja3N1bXMgZG9uJ3QgbWF0Y2ggIiA8PCBzdGQ6OmhleCA8PCBjaGVja3N1bTsKKyAgICAgICAgICAgICAgICAgICAgc3RhdHVzID0gU3RhdHVzOjpmcm9tRXhjZXB0aW9uQ29kZShFSU5WQUwsICJDaGVja3N1bXMgZG9uJ3QgbWF0Y2giKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgaWYgKHZhbGlkYXRpbmcpIHsKKyAgICAgICAgICAgICAgICAgICAgcmVsb2NhdGUocmVsb2NhdGlvbnMsIGxlLT5zb3VyY2UsIGxlLT5kZXN0LCAobGUtPnNpemUgLSAxKSAvIGtTZWN0b3JTaXplICsgMSk7CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgcmVzdG9yZVNlY3RvcihkZXZpY2VfZmQsIHVzZWRfc2VjdG9ycywgbHNfYnVmZmVyLCBsZSwgYnVmZmVyKTsKKyAgICAgICAgICAgICAgICAgICAgcmVzdG9yZV9jb3VudCsrOworICAgICAgICAgICAgICAgICAgICBpZiAocmVzdG9yZV9saW1pdCAmJiByZXN0b3JlX2NvdW50ID49IHJlc3RvcmVfbGltaXQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIExPRyhXQVJOSU5HKSA8PCAiSGl0IHRoZSB0ZXN0IGxpbWl0IjsKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1cyA9IFN0YXR1czo6ZnJvbUV4Y2VwdGlvbkNvZGUoRUFHQUlOLCAiSGl0IHRoZSB0ZXN0IGxpbWl0Iik7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorCisgICAgICAgIGlmICghc3RhdHVzLmlzT2soKSkgeworICAgICAgICAgICAgaWYgKCF2YWxpZGF0aW5nKSB7CisgICAgICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiQ2hlY2twb2ludCByZXN0b3JlIGZhaWxlZCBldmVuIHRob3VnaCBjaGVja3BvaW50IHZhbGlkYXRpb24gcGFzc2VkIjsKKyAgICAgICAgICAgICAgICByZXR1cm4gc3RhdHVzOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBMT0coV0FSTklORykgPDwgIkNoZWNrcG9pbnQgdmFsaWRhdGlvbiBmYWlsZWQgLSBhdHRlbXB0aW5nIHRvIHJvbGwgZm9yd2FyZCI7CisgICAgICAgICAgICBhdXRvIGJ1ZmZlciA9IHJlbG9jYXRlZFJlYWQoZGV2aWNlX2ZkLCByZWxvY2F0aW9ucywgZmFsc2UsIG9yaWdpbmFsX2xzLnNlY3RvcjAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3JpZ2luYWxfbHMuYmxvY2tfc2l6ZSwgb3JpZ2luYWxfbHMuYmxvY2tfc2l6ZSk7CisgICAgICAgICAgICBsc2VlazY0KGRldmljZV9mZCwgMCwgU0VFS19TRVQpOworICAgICAgICAgICAgd3JpdGUoZGV2aWNlX2ZkLCAmYnVmZmVyWzBdLCBvcmlnaW5hbF9scy5ibG9ja19zaXplKTsKKyAgICAgICAgICAgIHJldHVybiBT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ZG93biBzdGFsZSBkbSBkZXZpY2UgbmFtZWQgIiA8PCBuYW1lOwogCiAgICAgICAgICAgICBtZW1zZXQoYnVmZmVyMiwgMCwgREVWTUFQUEVSX0JVRkZFUl9TSVpFKTsKLSAgICAgICAgICAgIHN0cnVjdCBkbV9pb2N0bCAqaW8yID0gKHN0cnVjdCBkbV9pb2N0bCAqKSBidWZmZXIyOworICAgICAgICAgICAgc3RydWN0IGRtX2lvY3RsKiBpbzIgPSAoc3RydWN0IGRtX2lvY3RsKilidWZmZXIyOwogICAgICAgICAgICAgaW9jdGxJbml0KGlvMiwgREVWTUFQUEVSX0JVRkZFUl9TSVpFLCBuLT5uYW1lLCAwKTsKICAgICAgICAgICAgIGlmIChpb2N0bChmZCwgRE1fREVWX1JFTU9WRSwgaW8yKSkgewogICAgICAgICAgICAgICAgIGlmIChlcnJubyAhPSBFTlhJTykgewpAQCAtMjU1LDcgKzI1Miw3IEBACiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgTE9HKFZFUkJPU0UpIDw8ICJGb3VuZCB1bm1hbmFnZWQgZG0gZGV2aWNlIG5hbWVkICIgPDwgbmFtZTsKKyAgICAgICAgICAgIExPRyhERUJVRykgPDwgIkZvdW5kIHVubWFuYWdlZCBkbSBkZXZpY2UgbmFtZWQgIiA8PCBuYW1lOwogICAgICAgICB9CiAgICAgICAgIG54dCA9IG4tPm5leHQ7CiAgICAgfSB3aGlsZSAobnh0KTsKQEAgLTI2Niw5ICsyNjMsOCBAQAogICAgIHJldHVybiAwOwogfQogCi12b2lkICpEZXZtYXBwZXI6Ol9hbGlnbih2b2lkICpwdHIsIHVuc2lnbmVkIGludCBhKQotewotICAgICAgICB1bnNpZ25lZCBsb25nIGFnbiA9IC0tYTsKK3ZvaWQqIERldm1hcHBlcjo6X2FsaWduKHZvaWQqIHB0ciwgdW5zaWduZWQgaW50IGEpIHsKKyAgICB1bnNpZ25lZCBsb25nIG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gICAgICAgICAgICAtIGRhdGEtPnVzZWRfYmxvY2tzX2FscmVhZHlfZG9uZTsKLSAgICAgICAgICAgIGludCByZW1haW5pbmdfdGltZSA9IChpbnQpKGVsYXBzZWRfdGltZSAqIHJlbWFpbmluZ19ibG9ja3MKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8gZGF0YS0+dXNlZF9ibG9ja3NfYWxyZWFkeV9kb25lKTsKKyAgICAgICAgICAgIG9mZjY0X3QgcmVtYWluaW5nX2Jsb2NrcyA9IGRhdGEtPnRvdF91c2VkX2Jsb2NrcyAtIGRhdGEtPnVzZWRfYmxvY2tzX2FscmVhZHlfZG9uZTsKKyAgICAgICAgICAgIGludCByZW1haW5pbmdfdGltZSA9CisgICAgICAgICAgICAgICAgKGludCkoZWxhcHNlZF90aW1lICogcmVtYWluaW5nX2Jsb2NrcyAvIGRhdGEtPnVzZWRfYmxvY2tzX2FscmVhZHlfZG9uZSk7CiAKICAgICAgICAgICAgIC8vIENoYW5nZSB0aW1lIG9ubHkgaWYgbm90IHlldCBzZXQsIGxvd2VyLCBvciBhIGxvdCBoaWdoZXIgZm9yCiAgICAgICAgICAgICAvLyBiZXN0IHVzZXIgZXhwZXJpZW5jZQotICAgICAgICAgICAgaWYgKGRhdGEtPnJlbWFpbmluZ190aW1lID09IC0xCi0gICAgICAgICAgICAgICAgfHwgcmVtYWluaW5nX3RpbWUgPCBkYXRhLT5yZW1haW5pbmdfdGltZQotICAgICAgICAgICAgICAgIHx8IHJlbWFpbmluZ190aW1lID4gZGF0YS0+cmVtYWluaW5nX3RpbWUgKyA2MCkgeworICAgICAgICAgICAgaWYgKGRhdGEtPnJlbWFpbmluZ190aW1lID09IC0xIHx8IHJlbWFpbmluZ190aW1lIDwgZGF0YS0+cmVtYWluaW5nX3RpbWUgfHwKKyAgICAgICAgICAgICAgICByZW1haW5pbmdfdGltZSA+IGRhdGEtPnJlbWFpbmluZ190aW1lICsgNjApIHsKICAgICAgICAgICAg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kxPQ0tfVU5JTklUKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgPyAwCisgICAgICAgICAgICAgICAgICAgICAgICAgICA6IGJpdG1hcF9nZXRfYml0KGJsb2NrX2JpdG1hcCwgYmxvY2spOwogICAgICAgICAgICAgdXBkYXRlX3Byb2dyZXNzKGRhdGEsIHVzZWQpOwogICAgICAgICAgICAgaWYgKHVzZWQpIHsKICAgICAgICAgICAgICAgICBpZiAoZGF0YS0+Y291bnQgPT0gMCkgewpAQCAtMjMyLDggKzIyMiw4IEBACiAgICAgICAgICAgICBvZmZzZXQgKz0gaW5mby5ibG9ja19zaXplOwogCiAgICAgICAgICAgICAvKiBXcml0ZSBkYXRhIGlmIHdlIGFyZSBhbGlnbmVkIG9yIGJ1ZmZlciBzaXplIHJlYWNoZWQgKi8KLSAgICAgICAgICAgIGlmIChvZmZzZXQgJSAoaW5mby5ibG9ja19zaXplICogQkxPQ0tTX0FUX0FfVElNRSkgPT0gMAotICAgICAgICAgICAgICAgIHx8IGRhdGEtPmNvdW50ID09IEJMT0NLU19BVF9BX1RJTUUpIHsKKyAgICAgICAgICAgIGlmIChvZmZzZXQgJSAoaW5mby5ibG9ja19zaXplICogQkxPQ0tTX0FUX0FfVElNRSkgPT0gMCB8fAorICAgICAgICAgICAgICAgIGRhdGEtPmNvdW50ID09IEJMT0NLU19BVF9BX1RJTUUpIHsKICAgICAgICAgICAgICAgICBpZiAoZmx1c2hfb3V0c3RhbmRpbmdfZGF0YShkYXRhKSkgewogICAgICAgICAgICAgICAgICAgICBnb3RvIGVycm91dDsKICAgICAgICAgICAgICAgICB9CkBAIC0yNjAsNyArMjUwLDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgc2V0X3Byb2dyZXNzX3Byb3BlcnRpZXMpIHsKICAgICB1MzIgaTsKICAgICBzdHJ1Y3QgZW5jcnlwdEdyb3Vwc0RhdGEgZGF0YTsKLSAgICBpbnQgcmM7IC8vIENhbid0I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CB0b19maXggPDwgIiB0byAiIDw8IGN1cnJlbnRfcGF0aDsKKyAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQogICAgIH0KICAgICBhbmRyb2lkOjp2b2xkOjpGc3luY0RpcmVjdG9yeShkaXJlY3RvcnlfcGF0aCk7CkBAIC0xODIsMTAgKzE4NCwxMCBAQAogCiBzdGF0aWMgYm9vbCByZWFkX2FuZF9maXhhdGVfdXNlcl9jZV9rZXkodXNlcmlkX3QgdXNlcl9pZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhbmRyb2lkOjp2b2xkOjpLZXlBdXRoZW50aWNhdGlvbiYgYXV0aCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBLZXlCdWZmZXIgKmNlX2tleSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEtleUJ1ZmZlciogY2Vfa2V5KSB7CiAgICAgYXV0byBjb25zdCBkaXJlY3RvcnlfcGF0aCA9IGdldF9jZV9rZXlfZGlyZWN0b3J5X3BhdGgodXNlcl9pZCk7CiAgICAgYXV0byBjb25zdCBwYXRocyA9IGdldF9jZV9rZXlfcGF0aHMoZGlyZWN0b3J5X3BhdGgpOwotICAgIGZvciAoYXV0byBjb25zdCBjZV9rZXlfcGF0aDogcGF0aHMpIHsKKyAgICBmb3IgKGF1dG8gY29uc3QgY2Vfa2V5X3BhdGggOiBwYXRocykgewogICAgICAgICBMT0coREVCVUcpIDw8ICJUcnlpbmcgdXNlciBDRSBrZXkgIiA8PCBjZV9rZXlfcGF0aDsKICAgICAgICAgaWYgKGFuZHJvaWQ6OnZvbGQ6OnJldHJpZXZlS2V5KGNlX2tleV9wYXRoLCBhdXRoLCBjZV9rZXkpKSB7CiAgICAgICAgICAgICBMT0coREVCVUcpIDw8ICJTdWNjZXNzZnVsbHkgcmV0cmlldmVkIGtleSI7CkBAIC0yNDMsMTIgKzI0NSwxNCBAQAogICAgICA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b250ZW50c19tb2RlID0gY29udGVudHNfbW9kZTsKLSAgICBrZXlfcmVmLT5maWxlbmFtZXNfbW9kZSA9IGZpbGVuYW1lc19tb2RlOworICAgIGF1dG8gZW50cnkgPSBHZXRFbnRyeUZvck1vdW50UG9pbnQoJmZzdGFiX2RlZmF1bHQsIERBVEFfTU5UX1BPSU5UKTsKKyAgICBpZiAoZW50cnkgPT0gbnVsbHB0cikgeworICAgICAgICByZXR1cm47CisgICAgfQorICAgIGtleV9yZWYtPmNvbnRlbnRzX21vZGUgPSBlbnRyeS0+ZmlsZV9jb250ZW50c19tb2RlOworICAgIGtleV9yZWYtPmZpbGVuYW1lc19tb2RlID0gZW50cnktPmZpbGVfbmFtZXNfbW9kZTsKIH0KIAogc3RhdGljIGJvb2wgZW5zdXJlX3BvbGljeShjb25zdCBQb2xpY3lLZXlSZWYmIGtleV9yZWYsIGNvbnN0IHN0ZDo6c3RyaW5nJiBwYXRoKSB7Ci0gICAgcmV0dXJuIGU0Y3J5cHRfcG9saWN5X2Vuc3VyZShwYXRoLmNfc3RyKCksIGtleV9yZWYua2V5X3Jhd19yZWYuZGF0YSgpLAorICAgIHJldHVybiBmc2NyeXB0X3BvbGljeV9lbnN1cmUocGF0aC5jX3N0cigpLCBrZXlfcmVmLmtleV9yYXdfcmVmLmRhdGEoKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleV9yZWYua2V5X3Jhd19yZWYuc2l6ZSgpLCBrZXlfcmVmLmNvbnRlbnRzX21vZGUuY19zdHIoKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleV9yZWYuZmlsZW5hbWVzX21vZGUuY19zdHIoKSkgPT0gMDsKIH0KQEAgLTMyNiwxMyArMzMwLDEzIEBACiAgICAgICAgICAgICBMT0coREVCVUcpIDw8ICJJbnN0YWxsZWQgZGUga2V5IGZvciB1c2VyICIgPDwgdXNlcl9pZDsKICAgICAgICAgfQogICAgIH0KLSAgICAvLyBleHQ0ZW5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eXBlID09ICJmMmZzIiAmJiAoUmVhbHBhdGgodm9sLT5nZXRSYXdEbURldlBhdGgoKSwgJmdjX3BhdGgpIHx8CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSZWFscGF0aCh2b2wtPmdldFJhd0RldlBhdGgoKSwgJmdjX3BhdGgpKSkgewotICAgICAgICAgICAgICAgICAgICBwYXRocy0+cHVzaF9iYWNrKHN0ZDo6c3RyaW5nKCIvc3lzL2ZzLyIpICsgZnNfdHlwZSArCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIi8iICsgQmFzZW5hbWUoZ2NfcGF0aCkpOworICAgICAgICAgICAgICAgICAgICBwYXRocy0+cHVzaF9iYWNrKHN0ZDo6c3RyaW5nKCIvc3lzL2ZzLyIpICsgZnNfdHlwZSArICIvIiArIEJhc2VuYW1lKGdjX3BhdGgpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9Ci0KICAgICAgICAgfQogICAgIH0KIH0KIAogc3RhdGljIHZvaWQgYWRkRnJvbUZzdGFiKHN0ZDo6bGlzdDxzdGQ6OnN0cmluZz4qIHBhdGhzLCBQYXRoVHlwZXMgcGF0aF90eXBlKSB7Ci0gICAgc3RkOjp1bmlxdWVfcHRyPGZzdGFiLCBkZWNsdHlwZSgmZnNfbWdyX2ZyZWVfZnN0YWIpPiBmc3RhYihmc19tZ3JfcmVhZF9mc3RhYl9kZWZhdWx0KCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmc19tZ3JfZnJlZV9mc3RhYik7Ci0gICAgc3RydWN0IGZzdGFiX3JlYyAqcHJldl9yZWMgPSBOVUxMOworICAgIEZzdGFiIGZzdGFiOworICAgIFJlYWREZWZhdWx0RnN0YWIoJmZzdGFiKTsKIAotICAgIGZvciAoaW50IGkgPSAwOyBpIDwgZnN0YWItPm51bV9lbnRyaWVzOyBpKyspIHsKLSA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aV0pKSB7CisgICAgICAgIGlmIChlbnRyeS5mc19tZ3JfZmxhZ3Mubm9fdHJpbSkgewogICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgIH0KIAotICAgICAgICAvKiBTa2lwIHRoZSBtdWx0aS10eXBlIHBhcnRpdGlvbnMsIHdoaWNoIGFyZSByZXF1aXJlZCB0byBiZSBmb2xsb3dpbmcgZWFjaCBvdGhlci4KLSAgICAgICAgICogU2VlIGZzX21nci5jJ3MgbW91bnRfd2l0aF9hbHRlcm5hdGl2ZXMoKS4KLSAgICAgICAgICovCi0gICAgICAgIGlmIChwcmV2X3JlYyAmJiAhc3RyY21wKHByZXZfcmVjLT5tb3VudF9wb2ludCwgZnN0YWItPnJlY3NbaV0ubW91bnRfcG9pbnQpKSB7CisgICAgICAgIC8vIFNraXAgdGhlIG11bHRpLXR5cGUgcGFydGl0aW9ucywgd2hpY2ggYXJlIHJlcXVpcmVkIHRvIGJlIGZvbGxvd2luZyBlYWNoIG90aGVyLgorICAgICAgICAvLyBTZWUgZnNfbWdyLmMncyBtb3VudF93aXRoX2FsdGVybmF0aXZlcygpLgorICAgICAgICBpZiAoZW50cnkubW91bnRfcG9pbnQgPT0gcHJldmlvdXNfbW91bnRfcG9pbnQpIHsKICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICB9CiAKICAgICAgICAgaWYgKHBhdGhfdHlwZSA9PSBQYXRoVHlwZXM6OmtNb3VudFBvaW50KSB7Ci0gICAgICAgICAgICBwYXRocy0+cHVzaF9iYWNrKGZzdGFiLT5yZWNzW2ldLm1vdW50X3BvaW50KTsKKyAgICAgICAgICAgIHBhdGhzLT5wdXNoX2JhY2soZW50cnkubW91bnRfcG9pbnQpOwogICAgICAgICB9IGVsc2UgaWYgKHBhdGhfdHlwZSA9PSBQYXRoVHlwZXM6OmtCbGtEZXZpY2UpIHsKICAgICAgICAgICAgIHN0ZDo6c3RyaW5nIGdjX3BhdGg7Ci0gICAgICAgICAgICBpZiAoc3RkOjpzdHJpbmcoZnN0YWItPnJlY3NbaV0uZnNfdHlwZSkgPT0gImYyZnMiICYmCi0gICAgICAgICAgICAgICAgUmVhbHBhdGgoYW5kcm9pZDo6dm9sZDo6QmxvY2tEZXZpY2VGb3JQYXRoKAotICAgICAgICAgICAgICAgICAgICBzdGQ6OnN0cmluZyhmc3RhYi0+cmVjc1tpXS5tb3VudF9wb2ludCkgKyAiLyIpLCAmZ2NfcGF0aCkpIHsKLSAgICAgICAgICAgICAgICBwYXRocy0+cHVzaF9iYWNrKHN0ZDo6c3RyaW5nKCIvc3lzL2ZzLyIpICsgZnN0YWItPnJlY3NbaV0uZnNfdHlwZSArCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiLyIgKyBCYXNlbmFtZShnY19wYXRoKSk7CisgICAgICAgICAgICBpZiAoZW50cnkuZnNfdHlwZSA9PSAiZjJmcyIgJiYKKyAgICAgICAgICAgICAgICBSZWFscGF0aChhbmRyb2lkOjp2b2xkOjpCbG9ja0RldmljZUZvclBhdGgoZW50cnkubW91bnRfcG9pbnQgKyAiLyIpLCAmZ2NfcGF0aCkpIHsKKyAgICAgICAgICAgICAgICBwYXRocy0+cHVzaF9iYWNrKCIvc3lzL2ZzLyIgKyBlbnRyeS5mc190eXBlICsgIi8iICsgQmFzZW5hbWUoZ2NfcGF0aCkpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAKLSAgICAgICAgcHJldl9yZWMgPSAmZnN0YWItPnJlY3NbaV07CisgICAgICAgIHByZXZpb3VzX21vdW50X3BvaW50ID0gZW50cnkubW91bnRfcG9pbnQ7CiAgICAgfQogfQogCkBAIC0xNzcsOCArMTc5LDggQEAKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIG5zZWNzX3QgdGltZSA9IHN5c3RlbVRpbWUoU1lTVEVNX1RJTUVfQk9PVFRJTUUpIC0gc3RhcnQ7Ci0gICAgICAgICAgICBMT0coSU5GTykgPDwgIlRyaW1tZWQgIiA8PCByYW5nZS5sZW4gPDwgIiBieXRlcyBvbiAiIDw8IHBhdGgKLSAgICAgICAgICAgICAgICAgICAgPDwgIiBpbiAiIDw8IG5hbm9zZWNvbmRzX3RvX21pbGxpc2Vjb25kcyh0aW1lKSA8PCAibXMiOworICAgICAgICAgICAgTE9HKElORk8pIDw8ICJUcmltbWVkICIgPDwgcmFuZ2UubGVuIDw8ICIgYnl0ZXMgb24gIiA8PCBwYXRoIDw8ICIgaW4gIgorICAgICAgICAgICAgICAgICAgICAgIDw8IG5hbm9zZWNvbmRzX3RvX21pbGxpc2Vjb25kcyh0aW1lKSA8PCAibXMiOwogICAgICAgICAgICAgZXh0cmFzLnB1dExvbmcoU3RyaW5nMTYoImJ5dGVzIiksIHJhbmdlLmxlbik7CiAgICAgICAgICAgICBleHRyYXMucHV0TG9uZyhTdHJpbmcxNigidGltZSIpLCB0aW1lKTsKICAgICAgICAgICAgIGlmIChsaXN0ZW5lcikgewpAQCAtMjIzLDggKzIyNSw4IEBACiAgICAgICAgIH0KIAogICAgICAgICBsay5sb2NrKCk7Ci0gICAgICAgIGFib3J0ZWQgPSBjdl9hYm9ydC53YWl0X2ZvcihsaywgMTBzLCBbXXsKLSAgICAgICAgICAgIHJldHVybiBpZGxlX21haW50X3N0YXQgPT0gSWRsZU1haW50U3RhdHM6OmtBYm9ydDt9KTsKKyAgICAgICAgYWJvcnRlZCA9CisgICAgICAgICAgICBjdl9hYm9ydC53YWl0X2ZvcihsaywgMTBzLCBbXSB7IHJldHVybiBpZGxlX21haW50X3N0YXQgPT0gSWRsZU1haW50U3RhdHM6OmtBYm9ydDsgfSk7CiAgICAgICAgIGxrLnVubG9jaygpOwogICAgIH0KIApAQCAtMjM0LDkgKzIzNiw2IEBACiBzdGF0aWMgaW50IHN0YXJ0R2MoY29uc3Qgc3RkOjpsaXN0PHN0ZDo6c3RyaW5nPiYgcGF0aHMpIHsKICAgICBmb3IgKGNvbnN0IGF1dG8mIHBhdGggOiBwYXRocykgewog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ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmc19tZ3JfZnJlZV9mc3RhYik7Ci0gICAgc3RydWN0IGZzdGFiX3JlYyAqcmVjID0gTlVMTDsKK3N0YXRpYyB2b2lkIHJ1bkRldkdjRnN0YWIodm9pZCkgeworICAgIEZzdGFiIGZzdGFiOworICAgIFJlYWREZWZhdWx0RnN0YWIoJmZzdGFiKTsKIAotICAgIGZvciAoaW50IGkgPSAwOyBpIDwgZnN0YWItPm51bV9lbnRyaWVzOyBpKyspIHsKLSAgICAgICAgaWYgKGZzX21ncl9oYXNfc3lzZnNfcGF0aCgmZnN0YWItPnJlY3NbaV0pKSB7Ci0gICAgICAgICAgICByZWMgPSAmZnN0YWItPnJlY3NbaV07CisgICAgc3RkOjpzdHJpbmcgcGF0aDsKKyAgICBmb3IgKGNvbnN0IGF1dG8mIGVudHJ5IDogZnN0YWIpIHsKKyAgICAgICAgaWYgKCFlbnRyeS5zeXNmc19wYXRoLmVtcHR5KCkpIHsKKyAgICAgICAgICAgIHBhdGggPSBlbnRyeS5zeXNmc19wYXRoOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICB9Ci0gICAgaWYgKCFyZWMpIHsKKworICAgIGlmIChwYXRoLmVtcHR5KCkpIHsKICAgICAgICAgcmV0dXJuOwogICAgIH0KIAotICAgIHN0ZDo6c3RyaW5nIHBhdGg7Ci0gICAgcGF0aC5hcHBlbmQocmVjLT5zeXNmc19wYXRoKTsKICAgICBwYXRoID0gcGF0aCArICIvbWFudWFsX2djIjsKICAgICBUaW1lciB0aW1lcjsKIApAQCAtMjg0LDcgKzI3OSw3IEBACiAgICAgICAgICAgICBQTE9HKFdBUk5JTkcpIDw8ICJSZWFkaW5nIG1hbnVhbF9nYyBmYWlsZWQgaW4gIiA8PCBwYXRoOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KLQorICAgICAgICByZXF1aXJlID0gYW5kcm9pZDo6YmFzZTo6V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c3luYyAiIDw8IGZpbGVuYW1lCi0gICAgICAgICAgICAgICAgICAgICAgICAgIDw8ICIgb24gYSBmaWxlIHN5c3RlbSBkb2VzIG5vdCBzdXBwb3J0IHN5bmNocm9uaXphdGlvbiI7Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIGZzeW5jICIgPDwgZmlsZW5hbWU7Ci0gICAgICAgICAgICB1bmxpbmsoZmlsZW5hbWUuY19zdHIoKSk7Ci0gICAgICAgICAgICByZXR1cm4gZmFsc2U7Ci0gICAgICAgIH0KLSAgICB9Ci0gICAgcmV0dXJuIHRydWU7Ci19Ci0KIHN0YXRpYyBib29sIHJlYWRSYW5kb21CeXRlc09yTG9nKHNpemVfdCBjb3VudCwgc3RkOjpzdHJpbmcqIG91dCkgewogICAgIGF1dG8gc3RhdHVzID0gUmVhZFJhbmRvbUJ5dGVzKGNvdW50LCAqb3V0KTsKICAgICBpZiAoc3RhdHVzICE9IE9LKSB7CkBAIC0yMDIsNyArMTc1LDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga206OktleVB1cnBvc2UgcHVycG9zZSwgY29uc3Qga206OkF1dGhvcml6YXRpb25TZXQmIGtleVBhcmFtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qga206OkF1dGhvcml6YXRpb25TZXQmIG9wUGFyYW1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrbTo6SGFyZHdhcmVBdXRoVG9rZW4mIGF1dGhUb2tlbiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga206OkF1dGhvcml6YXRpb25TZXQqIG91dFBhcmFtcykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrbTo6QXV0aG9yaXphdGlvblNldCogb3V0UGFyYW1zLCBib29sIGtlZXBPbGQpIHsKICAgICBhdXRvIGttS2V5UGF0aCA9IGRpciArICIvI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ikgPDwgIktleSBkZWxldGlvbiBmYWlsZWQgZHVyaW5nIHVwZ3JhZGUsIGNvbnRpbnVpbmcgYW55d2F5OiAiIDw8IGRpcjsKKyAgICAgICAgaWYgKCFrZWVwT2xkKSB7CisgICAgICAgICAgICBpZiAocmVuYW1lKG5ld0tleVBhdGguY19zdHIoKSwga21LZXlQYXRoLmNfc3RyKCkpICE9IDApIHsKKyAgICAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiVW5hYmxlIHRvIG1vdmUgdXBncmFkZWQga2V5IHRvIGxvY2F0aW9uOiAiIDw8IGttS2V5UGF0aDsKKyAgICAgICAgICAgICAgICByZXR1cm4gS2V5bWFzdGVyT3BlcmF0aW9uKCk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoIWFuZHJvaWQ6OnZvbGQ6OkZzeW5jRGlyZWN0b3J5KGRpcikpIHsKKyAgICAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJLZXkgZGlyIHN5bmMgZmFpbGVkOiAiIDw8IGRpcjsKKyAgICAgICAgICAgICAgICByZXR1cm4gS2V5bWFzdGVyT3BlcmF0aW9uKCk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoIWtleW1hc3Rlci5kZWxldGVLZXkoa21LZXkpKSB7CisgICAgICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiS2V5IGRlbGV0aW9uIGZhaWxlZCBkdXJpbmcgdXBncmFkZSwgY29udGludWluZyBhbnl3YXk6ICIgPDwgZGlyOworICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgICAgIGttS2V5ID0gbmV3S2V5OwogICAgICAgICBMT0coSU5GTykgPDwgIktleSB1cGdyYWRlZDogIiA8PCBkaXI7CkBAIC0yMzcsMTIgKzIxMiwxMiBAQAogCiBzdGF0aWMgYm9vbCBlbmNyeXB0V2l0aEtleW1hc3RlcktleShLZXltYXN0ZXImIGtleW1hc3RlciwgY29uc3Qgc3RkOjpzdHJpbmcmIGRpciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGttOjpBdXRob3JpemF0aW9uU2V0JiBrZXlQYXJhbXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrbTo6SGFyZHdhcmVBdXRoVG9rZW4mIGF1dGhUb2tlbiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEtleUJ1ZmZlciYgbWVzc2FnZSwgc3RkOjpzdHJpbmcqIGNpcGhlcnRleHQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGttOjpIYXJkd2FyZUF1dGhUb2tlbiYgYXV0aFRva2VuLCBjb25zdCBLZXlCdWZmZXImIG1lc3NhZ2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OnN0cmluZyogY2lwaGVydGV4dCwgYm9vbCBrZWVwT2xkKSB7CiAgICAga206OkF1dGhvcml6YXRpb25TZXQgb3BQYXJhbXM7CiAgICAga206OkF1dGhvcml6YXRpb25TZXQgb3V0UGFyYW1zOwotICAgIGF1dG8gb3BIYW5kbGUgPQotICAgICAgICBiZWdpbihrZXltYXN0ZXIsIGRpciwga206OktleVB1cnBvc2U6OkVOQ1JZUFQsIGtleVBhcmFtcywgb3BQYXJhbXMsIGF1dGhUb2tlbiwgJm91dFBhcmFtcyk7CisgICAgYXV0byBvcEhhbmRsZSA9IGJlZ2luKGtleW1hc3RlciwgZGlyLCBrbTo6S2V5UHVycG9zZTo6RU5DUllQVCwga2V5UGFyYW1zLCBvcFBhcmFtcywgYXV0aFRva2VuLAorICAgICAgICAgICAgICAgICAgICAgICAgICAmb3V0UGFyYW1zLCBrZWVwT2xkKTsKICAgICBpZiAoIW9wSGFuZGxlKSByZXR1cm4gZmFsc2U7CiAgICAgYXV0byBub25jZUJsb2IgPSBvdXRQYXJhbXMuR2V0VGFnVmFsdWUoa206OlRBR19OT05DRSk7CiAgICAgaWYgKCFub25jZUJsb2IuaXNPaygpKSB7CkBAIC0yNjYsMTMgKzI0MSwxNCBAQAogc3RhdGljIGJvb2wgZGVjcnlwdFdpdGhLZXltYXN0ZXJLZXkoS2V5bWFzdGVyJiBrZXltYXN0ZXIsIGNvbnN0IHN0ZDo6c3RyaW5nJiBkaXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrbTo6QXV0aG9yaXphdGlvblNldCYga2V5UGFyYW1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qga206OkhhcmR3YXJlQXV0aFRva2VuJiBhdXRoVG9rZW4sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgY2lwaGVydGV4dCwgS2V5QnVmZmVyKiBtZXNzYWdlKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgY2lwaGVydGV4dCwgS2V5QnVmZmVyKiBtZXNzYWdlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBrZWVwT2xkKSB7CiAgICAgYXV0byBub25jZSA9IGNpcGhlcnRleHQuc3Vic3RyKDAsIEdDTV9OT05DRV9CWVRFUyk7CiAgICAgYXV0byBib2R5QW5kTWFjID0gY2lwaGVydGV4dC5zdWJzdHIoR0NNX05PTkNFX0JZVEVTKTsKICAgICBhdXRvIG9wUGFyYW1zID0ga206OkF1dGhvcml6YXRpb25TZXRCdWlsZGVyKCkuQXV0aG9yaXphdGlvbihrbTo6VEFHX05PTkNFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGttOjpzdXBwb3J0OjpibG9iMmhpZGxWZWMobm9uY2UpKTsKLSAgICBhdXRvIG9wSGFuZGxlID0KLSAgICAgICAgYmVnaW4oa2V5bWFzdGVyLCBkaXIsIGttOjpLZXlQdXJwb3NlOjpERUNSWVBULCBrZXlQYXJhbXMsIG9wUGFyYW1zLCBhdXRoVG9rZW4sIG51bGxwdHIpOworICAgIGF1dG8gb3BIYW5kbGUgPSBiZWdpbihrZXltYXN0ZXIsIGRpciwga206OktleVB1cnBvc2U6OkRFQ1JZUFQsIGtleVBhcmFtcywgb3BQYXJhbXMsIGF1dGhUb2tlbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgbnVsbHB0ciwga2VlcE9sZCk7CiAgICAgaWYgKCFvcEhhbmRsZSkgcmV0dXJuIGZhbHNlOwogICAgIGlmICghb3BIYW5kbGUudXBkYXRlQ29tcGxldGVseShib2R5QW5kTWFjLCBtZXNzYWdlKSkgcmV0dXJuIGZhbHNlOwogICAgIGlmICghb3BIYW5kbGUuZmluaXNoKG51bGxwdHIpKSByZXR1cm4gZmFsc2U7CkBAIC00NzgsNyArNDU0LDggQEAKICAgICAgICAga206OkF1dGhvcml6YXRpb25TZXQga2V5UGFyYW1zOwogICAgICAgICBrbTo6SGFyZHdhcmVBdXRoVG9rZW4gYXV0aFRva2VuOwogICAgICAgICBzdGQ6OnRpZShrZXlQYXJhbXMsIGF1dGhUb2tlbikgPSBiZWdpblBhcmFtcyhhdXRoLCBhcHBJZCk7Ci0gICAgICAgIGlmICghZW5jcnlwdFdpdGhLZXltYXN0ZXJLZXkoa2V5bWFzdGVyLCBkaXIsIGtleVBhcmFtcywgYXV0aFRva2VuLCBrZXksICZlbmNyeXB0ZWRLZXkpKQorICAgICAgICBpZiAoIWVuY3J5cHRXaXRoS2V5bWFzdGVyS2V5KGtleW1hc3RlciwgZGlyLCBrZXlQYXJhbXMsIGF1dGhUb2tlbiwga2V5LCAmZW5jcnlwdGVkS2V5LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZhbHNlKSkKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICB9IGVsc2UgewogICAgICAgICBpZiAoIWVuY3J5cHRXaXRob3V0S2V5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xLZXkoa2V5LCAmZXh0NF9rZXkpKSByZXR1cm4gZmFsc2U7Ci0gICAgKnJhd19yZWYgPSBnZW5lcmF0ZUtleVJlZihleHQ0X2tleS5yYXcsIGV4dDRfa2V5LnNpemUpOworICAgIGlmICghZmlsbEtleShrZXksICZmc19rZXkpKSByZXR1cm4gZmFsc2U7CisgICAgKnJhd19yZWYgPSBnZW5lcmF0ZUtleVJlZihmc19rZXkucmF3LCBmc19rZXkuc2l6ZSk7CiAgICAga2V5X3NlcmlhbF90IGRldmljZV9rZXlyaW5nOwotICAgIGlmICghZTRjcnlwdEtleXJpbmcoJmRldmljZV9rZXlyaW5nKSkgcmV0dXJuIGZhbHNlOworICAgIGlmICghZnNjcnlwdEtleXJpbmcoJmRldmljZV9rZXlyaW5nKSkgcmV0dXJuIGZhbHNlOwogICAgIGZvciAoY2hhciBjb25zdCogY29uc3QqIG5hbWVfcHJlZml4ID0gTkFNRV9QUkVGSVhFUzsgKm5hbWVfcHJlZml4ICE9IG51bGxwdHI7IG5hbWVfcHJlZml4KyspIHsKICAgICAgICAgYXV0byByZWYgPSBrZXluYW1lKCpuYW1lX3ByZWZpeCwgKnJhd19yZWYpOwogICAgICAgICBrZXlfc2VyaWFsX3Qga2V5X2lkID0KLSAgICAgICAgICAgIGFkZF9rZXkoImxvZ29uIiwgcmVmLmNfc3RyKCksICh2b2lkKikmZXh0NF9rZXksIHNpemVvZihleHQ0X2tleSksIGRldmljZV9rZXlyaW5nKTsKKyAgICAgICAgICAgIGFkZF9rZXkoImxvZ29uIiwgcmVmLmNfc3RyKCksICh2b2lkKikmZnNfa2V5LCBzaXplb2YoZnNfa2V5KSwgZGV2aWNlX2tleXJpbmcpOwogICAgICAgICBpZiAoa2V5X2lkID09IC0xKSB7CiAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIGluc2VydCBrZXkgaW50byBrZXlyaW5nICIgPDwgZGV2aWNlX2tleXJpbmc7CiAgICAgICAgICAgICByZXR1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ZXlfYmxvYiA9ICJrZXltYXN0ZXJfa2V5X2Jsb2IiOworc3RhdGljIGNvbnN0IGNoYXIqIGtGbl9rZXltYXN0ZXJfa2V5X2Jsb2JfdXBncmFkZWQgPSAia2V5bWFzdGVyX2tleV9ibG9iX3VwZ3JhZGVkIjsKKwogc3RhdGljIGJvb2wgbW91bnRfdmlhX2ZzX21ncihjb25zdCBjaGFyKiBtb3VudF9wb2ludCwgY29uc3QgY2hhciogYmxrX2RldmljZSkgewogICAgIC8vIGZzX21ncl9kb19tb3VudCBydW5zIGZzY2suIFVzZSBzZXRleGVjY29uIHRvIHJ1biB0cnVzdGVkCiAgICAgLy8gcGFydGl0aW9ucyBpbiB0aGUgZnNjayBkb21haW4uCi0gICAgaWYgKHNldGV4ZWNjb24oc2Vjb250ZXh0RnNjaygpKSkgeworICAgIGlmIChzZXRleGVjY29uKGFuZHJvaWQ6OnZvbGQ6OnNGc2NrQ29udGV4dCkpIHsKICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBzZXRleGVjY29uIjsKICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgIH0KLSAgICBhdXRvIG1vdW50X3JjID0gZnNfbWdyX2RvX21vdW50KGZzdGFiX2RlZmF1bHQsIGNvbnN0X2Nhc3Q8Y2hhcio+KG1vdW50X3BvaW50KSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0X2Nhc3Q8Y2hhcio+KGJsa19kZXZpY2UpLCBudWxscHRyKTsKKyAgICBhdXRvIG1vdW50X3JjID0gZnNfbWdyX2RvX21vdW50KCZmc3RhYl9kZWZhdWx0LCBjb25zdF9jYXN0PGNoYXIqPihtb3VudF9wb2ludCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdF9jYXN0PGNoYXIqPihibGtfZGV2aWNlKSwgbnVsbHB0ciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuZHJvaWQ6OnZv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RoLCBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4mIGNtZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IHNlYXJjaExldmVscykgeworICAgIGlmIChzZWFyY2hMZXZlbHMgPT0gMCkgeworICAgICAgICBjbWQuZW1wbGFjZV9iYWNrKHBhdGgpOworICAgICAgICByZXR1cm4gdHJ1ZTsKKyAgICB9CisgICAgYXV0byBkaXJwID0gc3RkOjp1bmlxdWVfcHRyPERJUiwgaW50ICgqKShESVIqKT4ob3BlbmRpcihwYXRoLmNfc3RyKCkpLCBjbG9zZWRpcik7CisgICAgaWYgKCFkaXJwKSB7CisgICAgICAgIFBMT0coRVJST1IpIDw8ICJVbmFibGUgdG8gb3BlbiBkaXJlY3Rvcnk6ICIgPDwgcGF0aDsKKyAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgIH0KICAgICBib29sIGZvdW5kID0gZmFsc2U7CiAgICAgc3RydWN0IGRpcmVudCogZW50OwotICAgIHdoaWxlICgoZW50ID0gcmVhZGRpcihkaXIpKSAhPSBOVUxMKSB7CisgICAgd2hpbGUgKChlbnQgPSByZWFkZGlyKGRpcnAuZ2V0KCkpKSAhPSBOVUxMKSB7CiAgICAgICAgIGlmICgoIXN0cmNtcChlbnQtPmRfbmFtZSwgIi4iKSkgfHwgKCFzdHJjbXAoZW50LT5kX25hbWUsICIuLiIpKSkgewogICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgIH0KLSAgICAgICAgaWYgKGFkZFdpbGRjYXJkKSB7Ci0gICAgICAgICAgICBjbWQucHVzaF9iYWNrKFN0cmluZ1ByaW50ZigiJXMvJXMvKiIsIHBhdGguY19zdHIoKSwgZW50LT5kX25hbWUpKTsKLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIGNtZC5wdXNoX2JhY2soU3RyaW5nUHJpbnRmKCIlcy8lcyIsIHBhdGguY19zdHIoKSwgZW50LT5kX25hbWUpKTsKLSAgICAgICAgfQotICAgICAgIC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oKSkpID09IC0xKSB7CisgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIHVubGluayAiIDw8IGRpcjsKKyAgICAgICAgICAgIHJldHVybiAtZXJybm87CisgICAgICAgIH0KKyAgICB9IGVsc2UgaWYgKGVycm5vICE9IEVOT0VOVCkgeworICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIHN0YXQgIiA8PCBkaXI7CisgICAgICAgIHJldHVybiAtZXJybm87CisgICAgfQorICAgIGlmIChURU1QX0ZBSUxVUkVfUkVUUlkobWtkaXIoZGlyLmNfc3RyKCksIG1vZGUpKSA9PSAtMSAmJiBlcnJubyAhPSBFRVhJU1QpIHsKKyAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBta2RpciAiIDw8IGRpcjsKKyAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICB9CisgICAgcmV0dXJuIE9LOworfQorCiBib29sIEZpbmRWYWx1ZShjb25zdCBzdGQ6OnN0cmluZyYgcmF3LCBjb25zdCBzdGQ6OnN0cmluZyYga2V5LCBzdGQ6OnN0cmluZyogdmFsdWUpIHsKICAgICBhdXRvIHF1YWwgPSBrZXkgKyAiPVwiIjsKLSAgICBhdXRvIHN0YXJ0ID0gcmF3LmZpbmQocXVhbCk7Ci0gICAgaWYgKHN0YXJ0ID4gMCAmJiByYXdbc3RhcnQgLSAxXSAhPSAnICcpIHsKLSAgICAgICAgc3RhcnQgPSByYXcuZmluZChxdWFsLCBzdGFydCArIDEpOworICAgIHNpemVfdCBzdGFydCA9IDA7CisgICAgd2hpbGUgKHRydWUpIHsKKyAgICAgICAgc3RhcnQgPSByYXcuZmluZChxdWFsLCBzdGFydCk7CisgICAgICAgIGlmIChzdGFydCA9PSBzdGQ6OnN0cmluZzo6bnBvcykgcmV0dXJuIGZhbHNlOworICAgICAgICBpZiAoc3RhcnQgPT0gMCB8fCByYXdbc3RhcnQgLSAxXSA9PSAnICcpIHsKKyAgICA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mVjdG9yPHN0ZDo6c3RyaW5nPiogb3V0cHV0LAorICAgICAgICAgICAgICAgICAgICBzZWN1cml0eV9jb250ZXh0X3QgY29udGV4dCkgeworICAgIGF1dG8gYXJndiA9IENvbnZlcnRUb0FyZ3YoYXJncyk7CisKKyAgICBhbmRyb2lkOjpiYXNlOjp1bmlxdWVfZmQgcGlwZV9yZWFkLCBwaXBlX3dyaXRlOworICAgIGlmICghYW5kcm9pZDo6YmFzZTo6UGlwZSgmcGlwZV9yZWFkLCAmcGlwZV93cml0ZSkpIHsKKyAgICAgICAgUExPRyhFUlJPUikgPDwgIlBpcGUgaW4gRm9ya0V4ZWN2cCI7CiAgICAgICAgIHJldHVybiAtZXJybm87CiAgICAgfQogCisgICAgcGlkX3QgcGlkID0gZm9yaygpOworICAgIGlmIChwaWQgPT0gMCkgeworICAgICAgICBpZiAoY29udGV4dCkgeworICAgICAgICAgICAgaWYgKHNldGV4ZWNjb24oY29udGV4dCkpIHsKKyAgICAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gc2V0ZXhlY2NvbiBpbiBGb3JrRXhlY3ZwIjsKKyAgICAgICAgICAgICAgICBhYm9ydCgpOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIHBpcGVfcmVhZC5yZXNldCgpOworICAgICAgICBpZiAoZHVwMihwaXBlX3dyaXRlLmdldCgpLCBTVERPVVRfRklMRU5PKSA9PSAtMSkgeworICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgImR1cDIgaW4gRm9ya0V4ZWN2cCI7CisgICAgICAgICAgICBfZXhpdChFWElUX0ZBSUxVUkUpOworICAgICAgICB9CisgICAgICAgIHBpcGVfd3JpdGUucmVzZXQoKTsKKyAgICAgICAgZXhlY3ZwKGFyZ3ZbMF0sIGNvbnN0X2Nhc3Q8Y2hhcioqPihhcmd2LmRhdGEoKSkpOworICAgICAgICBQTE9HKEVSUk9SKSA8PCAiZXhlYyBpbiBGb3JrRXhlY3ZwIjs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XIqKikgY2FsbG9jKGFyZ2MgKyAxLCBzaXplb2YoY2hhciopKTsKLSAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IGFyZ2M7IGkrKykgewotICAgICAgICBhcmd2W2ldID0gKGNoYXIqKSBhcmdzW2ldLmNfc3RyKCk7Ci0gICAgICAgIGlmIChpID09IDApIHsKLSAgICAgICAgICAgIExPRyhWRVJCT1NFKSA8PCBhcmdzW2ldOwotICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgTE9HKFZFUkJPU0UpIDw8ICIgICAgIiA8PCBhcmdzW2ldOwotICAgICAgICB9Ci0gICAgfQorICAgIGF1dG8gYXJndiA9IENvbnZlcnRUb0FyZ3YoYXJncyk7CiAKICAgICBwaWRfdCBwaWQgPSBmb3JrKCk7CiAgICAgaWYgKHBpZCA9PSAwKSB7CkBAIC0zNTgsMTggKzQwMSwxNCBAQAogICAgICAgICBjbG9zZShTVERPVVRfRklMRU5PKTsKICAgICAgICAgY2xvc2UoU1RERVJSX0ZJTEVOTyk7CiAKLSAgICAgICAgaWYgKGV4ZWN2cChhcmd2WzBdLCBhcmd2KSkgewotICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBleGVjIjsKLSAgICAgICAgfQotCi0gICAgICAgIF9leGl0KDEpOworICAgICAgICBleGVjdnAoYXJndlswXSwgY29uc3RfY2FzdDxjaGFyKio+KGFyZ3YuZGF0YSgpKSk7CisgICAgICAgIFBMT0coRVJST1IpIDw8ICJleGVjIGluIEZvcmtFeGVjdnBBc3luYyI7CisgICAgICAgIF9leGl0KEVYSVRfRkFJTFVSRSk7CiAgICAgfQotCiAgICAgaWYgKHBpZCA9PSAtMSkgewotICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIGV4ZWMiOworICAgICAgICBQTE9HKEVSUk9SKSA8PCAiZm9yayBpbiBGb3JrRXhlY3ZwQXN5bmMiOworICAgICAgICByZXR1cm4gLTE7CiAgICAgfQotCi0gICAgZnJlZShhcmd2KTsKICAgICByZXR1cm4gcGlkOwogfQogCkBAIC0zODQsNyArNDIzLDcgQEAKICAgICAgICAgcmV0dXJuIC1lcnJubzsKICAgICB9CiAKLSAgICBzaXplX3QgbjsKKyAgICBzc2l6ZV90IG47CiAgICAgd2hpbGUgKChuID0gVEVNUF9GQUlMVVJFX1JFVFJZKHJlYWQoZmQsICZidWZbMF0sIGJ5dGVzKSkpID4gMCkgewogICAgICAgICBieXRlcyAtPSBuOwogICAgICAgICBidWYgKz0gbjsKQEAgLTQwMSwxMCArNDQwLDEwIEBACiBzdGF0dXNfdCBHZW5lcmF0ZVJhbmRvbVV1aWQoc3RkOjpzdHJpbmcmIG91dCkgewogICAgIHN0YXR1c190IHJlcyA9IFJlYWRSYW5kb21CeXRlcygxNiwgb3V0KTsKICAgICBpZiAocmVzID09IE9LKSB7Ci0gICAgICAgIG91dFs2XSAmPSAweDBmOyAgLyogY2xlYXIgdmVyc2lvbiAgICAgICAgKi8KLSAgICAgICAgb3V0WzZdIHw9IDB4NDA7ICAvKiBzZXQgdG8gdmVyc2lvbiA0ICAgICAqLwotICAgICAgICBvdXRbOF0gJj0gMHgzZjsgIC8qIGNsZWFyIHZhcmlhbnQgICAgICAgICovCi0gICAgICAgIG91dFs4XSB8PSAweDgwOyAgLyogc2V0IHRvIElFVEYgdmFyaWFudCAgKi8KKyAgICAgICAgb3V0WzZdICY9IDB4MGY7IC8qIGNsZWFyIHZlcnNpb24gICAgICAgICovCisgICAgICAgIG91dFs2XSB8PSAweDQwOyAvKiBzZXQgdG8gdmVyc2lvbiA0ICAgICAqLworICAgICAgICBvdXRbOF0gJj0gMHgzZjsgLyogY2xlYXIgdmFyaWFudCAgICAgICAgKi8KKyAgICAgICAgb3V0WzhdIHw9IDB4ODA7IC8qIHNldCB0byBJRVRGIHZhcmlhbnQgICovCiAgICAgfQogICAgIHJldHVybiByZXM7CiB9CkBAIC00MTYsMjQgKzQ1NSwyNiBAQAogICAgIGZvciAoc2l6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c2UgJyAnOiBjYXNlICctJzogY2FzZSAnOic6IGNvbnRpbnVlOworICAgICAgICAgICAgY2FzZSAnZic6IGNhc2UgJ0YnOiB2YWwgPSAxNTsgYnJlYWs7CisgICAgICAgICAgICBjYXNlICdlJzogY2FzZSAnRSc6IHZhbCA9IDE0OyBicmVhazsKKyAgICAgICAgICAgIGNhc2UgJ2QnOiBjYXNlICdEJzogdmFsID0gMTM7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnYyc6IGNhc2UgJ0MnOiB2YWwgPSAxMjsgYnJlYWs7CisgICAgICAgICAgICBjYXNlICdiJzogY2FzZSAnQic6IHZhbCA9IDExOyBicmVhazsKKyAgICAgICAgICAgIGNhc2UgJ2EnOiBjYXNlICdBJzogdmFsID0gMTA7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnOSc6IHZhbCA9IDk7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnOCc6IHZhbCA9IDg7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnNyc6IHZhbCA9IDc7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnNic6IHZhbCA9IDY7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnNSc6IHZhbCA9IDU7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnNCc6IHZhbCA9IDQ7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnMyc6IHZhbCA9IDM7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnMic6IHZhbCA9IDI7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnMSc6IHZhbCA9IDE7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnMCc6IHZhbCA9IDA7IGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDogcmV0dXJuIC1FSU5WQUw7CisgICAgICAgICAgICAgICAgLy8gY2xhbmctZm9ybWF0IG9uCiAgICAgICAgIH0KIAogICAgICAgICBpZiAoZXZlbikgewpAQCAtNDc2LDEwICs1MTcsNDYgQEAKICAgICByZXR1cm4gU3RyVG9IZXgodG1wLCBvdXQpOwogfQogCitzdGF0dXNfdCBHZXRCbG9ja0RldlNpemUoaW50IGZkLCB1aW50NjRfdCogc2l6ZSkgeworICAgIGlmIChpb2N0bChmZCwgQkxLR0VUU0laRTY0LCBzaXplKSkgeworICAgICAgICByZXR1cm4gLWVycm5vOworICAgIH0KKworICAgIHJldHVybiBPSzsKK30KKworc3RhdHVzX3QgR2V0QmxvY2tEZXZTaXplKGNvbnN0IHN0ZDo6c3RyaW5nJiBwYXRoLCB1aW50NjRfdCogc2l6ZSkgeworICAgIGludCBmZCA9IG9wZW4ocGF0aC5jX3N0cigpLCBPX1JET05MWSB8IE9fQ0xPRVhFQyk7CisgICAgc3RhdHVzX3QgcmVzID0gT0s7CisKKyAgICBpZiAoZmQgPCAwKSB7CisgICAgICAgIHJldHVybiAtZXJybm87CisgICAgfQorCisgICAgcmVzID0gR2V0QmxvY2tEZXZTaXplKGZkLCBzaXplKTsKKworICAgIGNsb3NlKGZkKTsKKworICAgIHJldHVybiByZXM7Cit9CisKK3N0YXR1c190IEdldEJsb2NrRGV2NTEyU2VjdG9ycyhjb25zdCBzdGQ6OnN0cmluZyYgcGF0aCwgdWludDY0X3QqIG5yX3NlYykgeworICAgIHVpbnQ2NF90IHNpemU7CisgICAgc3RhdHVzX3QgcmVzID0gR2V0QmxvY2tEZXZTaXplKHBhdGgsICZzaXplKTsKKworICAgIGlmIChyZXMgIT0gT0spIHsKKyAgICAgICAgcmV0dXJuIHJlczsKKyAgICB9CisKKyAgICAqbnJfc2VjID0gc2l6ZSAvIDUxMjsKKworICAgIHJldHVybiBPSzsKK30KKwogdWludDY0X3QgR2V0RnJlZUJ5dGVzKGNvbnN0IHN0ZDo6c3RyaW5nJiBwYXRoKSB7CiAgICAgc3RydWN0IHN0YXR2ZnMgc2I7CiAgICAgaWYgKHN0YXR2ZnMocGF0aC5jX3N0cigpLCAmc2IpID09IDApIHsKLSAgICAgICAgcmV0dXJuICh1aW50NjRfdCkg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zdCBjaGFyKiBuYW1lID0gZGUtPmRfbmFtZTsKICAgICAgICAgaWYgKGZzdGF0YXQoZGZkLCBuYW1lLCAmcywgQVRfU1lNTElOS19OT0ZPTExPVykgPT0gMCkgewogICAgICAgICAgICAgc2l6ZSArPSBzdGF0X3NpemUoJnMpOwogICAgICAgICB9CkBAIC01MjQsMTAgKzYwMSw4IEBACiAKICAgICAgICAgICAgIC8qIGFsd2F5cyBza2lwICIuIiBhbmQgIi4uIiAqLwogICAgICAgICAgICAgaWYgKG5hbWVbMF0gPT0gJy4nKSB7Ci0gICAgICAgICAgICAgICAgaWYgKG5hbWVbMV0gPT0gMCkKLSAgICAgICAgICAgICAgICAgICAgY29udGludWU7Ci0gICAgICAgICAgICAgICAgaWYgKChuYW1lWzFdID09ICcuJykgJiYgKG5hbWVbMl0gPT0gMCkpCi0gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgIGlmIChuYW1lWzFdID09IDApIGNvbnRpbnVlOworICAgICAgICAgICAgICAgIGlmICgobmFtZVsxXSA9PSAnLicpICYmIChuYW1lWzJdID09IDApKSBjb250aW51ZTsKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgc3ViZmQgPSBvcGVuYXQoZGZkLCBuYW1lLCBPX1JET05MWSB8IE9fRElSRUNUT1JZIHwgT19DTE9FWEVDKTsKQEAgLTU0Niw5ICs2MjEsNyBAQAogICAgICAgICBQTE9HKFdBUk5JTkcpIDw8ICJGYWlsZWQgdG8gb3BlbiAiIDw8IHBhdGg7CiAgICAgICAgIHJldHVybiAtMTsKICAgICB9IGVsc2UgewotICAgICAgICB1aW50NjRfdCByZXMgPSBjYWxjdWxhdGVfZGlyX3NpemUoZGlyZmQpOwotICAgICAgICBjbG9zZShkaXJmZCk7Ci0gICAgICAgIHJldHVybiByZXM7CisgICAgICAgIHJldHVybiBjYWxjdWxhdGVfZGlyX3NpemUoZGlyZmQpOwogICAgIH0KIH0KIApAQCAtNTY0LDggKzYzN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pOworICAgIGlmIChwcmVmaXguYmFjaygpICE9ICcvJykgeworICAgICAgICBhbmRyb2lkOjpiYXNlOjpTdHJpbmdBcHBlbmRGKCZwcmVmaXhXaXRoU2xhc2gsICIvIik7CisgICAgfQorCisgICAgc3RkOjp1bmlxdWVfcHRyPEZJTEUsIGludCAoKikoRklMRSopPiBtbnRzKHNldG1udGVudCgiL3Byb2MvbW91bnRzIiwgInJlIiksIGVuZG1udGVudCk7CisgICAgaWYgKCFtbnRzKSB7CisgICAgICAgIFBMT0coRVJST1IpIDw8ICJVbmFibGUgdG8gb3BlbiAvcHJvYy9tb3VudHMiOworICAgICAgICByZXR1cm4gLWVycm5vOworICAgIH0KKworICAgIC8vIFNvbWUgdm9sdW1lcyBjYW4gYmUgc3RhY2tlZCBvbiBlYWNoIG90aGVyLCBzbyBmb3JjZSB1bm1vdW50IGluCisgICAgLy8gcmV2ZXJzZSBvcmRlciB0byBnaXZlIHVzIHRoZSBiZXN0IGNoYW5jZSBvZiBzdWNjZXNzLgorICAgIHN0cnVjdCBtbnRlbnQqIG1udDsgIC8vIGdldG1udGVudCByZXR1cm5zIGEgdGhyZWFkIGxvY2FsLCBzbyBpdCdzIHNhZmUuCisgICAgd2hpbGUgKChtbnQgPSBnZXRtbnRlbnQobW50cy5nZXQoKSkpICE9IG51bGxwdHIpIHsKKyAgICAgICAgYXV0byBtb3VudFBvaW50ID0gc3RkOjpzdHJpbmcobW50LT5tbnRfZGlyKSArICIvIjsKKyAgICAgICAgaWYgKGFuZHJvaWQ6OmJhc2U6OlN0YXJ0c1dpdGgobW91bnRQb2ludCwgcHJlZml4V2l0aFNsYXNoKSkgeworICAgICAgICAgICAgbW91bnRQb2ludHMucHVzaF9mcm9udChtb3VudFBvaW50KTsKKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gT0s7Cit9CisKKy8vIFVubW91bnQgYWxsIG1vdW50cG9pbnRzIHRoYXQgc3RhcnQgd2l0aCBwcmVmaXguIHByZWZpeCBpdHNl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Jvd2VkIGZyb20gYW5kcm9pZDo6aW5zdGFsbGQKKyAgICBpbnQgZGZkID0gZGlyZmQoZGlyKTsKKyAgICBpZiAoZGZkIDwgMCkgeworICAgICAgICByZXR1cm4gLWVycm5vOworICAgIH0KKworICAgIHN0YXR1c190IHJlc3VsdCA9IE9LOworICAgIHN0cnVjdCBkaXJlbnQqIGRlOworICAgIHdoaWxlICgoZGUgPSByZWFkZGlyKGRpcikpKSB7CisgICAgICAgIGNvbnN0IGNoYXIqIG5hbWUgPSBkZS0+ZF9uYW1lOworICAgICAgICBpZiAoZGUtPmRfdHlwZSA9PSBEVF9ESVIpIHsKKyAgICAgICAgICAgIC8qIGFsd2F5cyBza2lwICIuIiBhbmQgIi4uIiAqLworICAgICAgICAgICAgaWYgKG5hbWVbMF0gPT0gJy4nKSB7CisgICAgICAgICAgICAgICAgaWYgKG5hbWVbMV0gPT0gMCkgY29udGludWU7CisgICAgICAgICAgICAgICAgaWYgKChuYW1lWzFdID09ICcuJykgJiYgKG5hbWVbMl0gPT0gMCkpIGNvbnRpbnVlOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBhbmRyb2lkOjpiYXNlOjp1bmlxdWVfZmQgc3ViZmQoCisgICAgICAgICAgICAgICAgb3BlbmF0KGRmZCwgbmFtZSwgT19SRE9OTFkgfCBPX0RJUkVDVE9SWSB8IE9fTk9GT0xMT1cgfCBPX0NMT0VYRUMpKTsKKyAgICAgICAgICAgIGlmIChzdWJmZC5nZXQoKSA9PSAtMSkgeworICAgICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJDb3VsZG4ndCBvcGVuYXQgIiA8PCBuYW1lOworICAgICAgICAgICAgICAgIHJlc3VsdCA9IC1lcnJubzsKKyAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHN0ZDo6dW5pcXVlX3B0cjxESVIsIGRlY2x0eXBlKCZjbG9zZWRpcik+IHN1YmRpcnAoCisgICAgICAgICAgICAgICAgYW5kcm9pZDo6YmFzZTo6RmRvcGVuZGlyKHN0ZDo6bW92ZShzdWJmZCkpLCBjbG9zZWRpcik7CisgICAgICAgICAgICBpZiAoIXN1YmRpcnApIHsKKyAgICAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiQ291bGRuJ3QgZmRvcGVuZGlyICIgPDwgbmFtZTsKKyAgICAgICAgICAgICAgICByZXN1bHQgPSAtZXJybm87CisgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICByZXN1bHQgPSBkZWxldGVfZGlyX2NvbnRlbnRzKHN1YmRpcnAuZ2V0KCkpOworICAgICAgICAgICAgaWYgKHVubGlua2F0KGRmZCwgbmFtZSwgQVRfUkVNT1ZFRElSKSA8IDApIHsKKyAgICAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiQ291bGRuJ3QgdW5saW5rYXQgIiA8PCBuYW1lOworICAgICAgICAgICAgICAgIHJlc3VsdCA9IC1lcnJubzsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIGlmICh1bmxpbmthdChkZmQsIG5hbWUsIDApIDwgMCkgeworICAgICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJDb3VsZG4ndCB1bmxpbmthdCAiIDw8IG5hbWU7CisgICAgICAgICAgICAgICAgcmVzdWx0ID0gLWVycm5vOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorICAgIHJldHVybiByZXN1bHQ7Cit9CisKK3N0YXR1c190IERlbGV0ZURpckNvbnRlbnRzQW5kRGlyKGNvbnN0IHN0ZDo6c3RyaW5nJiBwYXRobmFtZSkgeworICAgIHN0YXR1c190IHJlcyA9IERlbGV0ZURpckNvbnRlbnRzKHBhdGhuYW1lKTsKKyAgICBpZiAocmVzIDwgMCkgeworICAgICAgICByZXR1cm4gcmVzOworICAgIH0KKyAgICBpZiAoVEVNUF9GQUlMVVJFX1JFVFJZKHJtZGlyKH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gdWlkOwogCiAgICAgaWYgKGNoZWNrQ2FsbGluZ1Blcm1pc3Npb24oU3RyaW5nMTYocGVybWlzc2lvbiksIHJlaW50ZXJwcmV0X2Nhc3Q8aW50MzJfdCo+KCZwaWQpLAotICAgICAgICAgICAgcmVpbnRlcnByZXRfY2FzdDxpbnQzMl90Kj4oJnVpZCkpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVpbnRlcnByZXRfY2FzdDxpbnQzMl90Kj4oJnVpZCkpKSB7CiAgICAgICAgIHJldHVybiBvaygpOwogICAgIH0gZWxzZSB7CiAgICAgICAgIHJldHVybiBleGNlcHRpb24oYmluZGVyOjpTdGF0dXM6OkVYX1NFQ1VSSVRZLAotICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiVUlEICVkIC8gUElEICVkIGxhY2tzIHBlcm1pc3Npb24gJXMiLCB1aWQsIHBpZCwgcGVybWlzc2lvbikpOworICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiVUlEICVkIC8gUElEICVkIGxhY2tzIHBlcm1pc3Npb24gJXMiLCB1aWQsIHBpZCwgcGVybWlzc2lvbikpOwogICAgIH0KIH0KIApAQCAtOTcsNyArOTgsNyBAQAogICAgICAgICByZXR1cm4gb2soKTsKICAgICB9IGVsc2UgewogICAgICAgICByZXR1cm4gZXhjZXB0aW9uKGJpbmRlcjo6U3RhdHVzOjpFWF9TRUNVUklUWSwKLSAgICAgICAgICAgICAgICBTdHJpbmdQcmludGYoIlVJRCAlZCBpcyBub3QgZXhwZWN0ZWQgVUlEICVkIiwgdWlkLCBleHBlY3RlZFVpZCkpOworICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiVUlEICVkIGlzIG5vdCBleHBlY3RlZCBVSUQgJWQiLCB1aWQsIGV4cGVjdGVkVWlkKSk7CiAgICAgfQogfQogCkBAIC0xMDgsNyArMTA5LDcgQEAKICAgICBmb3IgKGNvbnN0IGNoYXImIGMgOiBpZCkgewogICAgICAgICBpZiAoIXN0ZDo6aXNhbG51bShjKSAmJiBjICE9ICc6JyAmJiBjICE9ICcsJykgewogICAgICAgICAgICAgcmV0dXJuIGV4Y2VwdGlvbihiaW5kZXI6OlN0YXR1czo6RVhfSUxMRUdBTF9BUkdVTUVOVCwKLSAgICAgICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJJRCAlcyBpcyBtYWxmb3JtZWQiLCBpZC5jX3N0cigpKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiSUQgJXMgaXMgbWFsZm9ybWVkIiwgaWQuY19zdHIoKSkpOwogICAgICAgICB9CiAgICAgfQogICAgIHJldHVybiBvaygpOwpAQCAtMTIwLDE2ICsxMjEsMTYgQEAKICAgICB9CiAgICAgaWYgKHBhdGhbMF0gIT0gJy8nKSB7CiAgICAgICAgIHJldHVybiBleGNlcHRpb24oYmluZGVyOjpTdGF0dXM6OkVYX0lMTEVHQUxfQVJHVU1FTlQsCi0gICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJQYXRoICVzIGlzIHJlbGF0aXZlIiwgcGF0aC5jX3N0cigpKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJQYXRoICVzIGlzIHJlbGF0aXZlIiwgcGF0aC5jX3N0cigpKSk7CiAgICAgfQogICAgIGlmICgocGF0aCArICcvJykuZmluZCgiLy4uLyIpICE9IHN0ZDo6c3RyaW5nOjpucG9zKSB7CiAgICAgICAgIHJldHVybiBleGNlcHRpb24oYmluZGVyOjpTdGF0dXM6OkVYX0lMTEVHQUxfQVJHVU1FTlQsCi0gICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJQYXRoICVzIGlzIHNoYWR5IiwgcGF0aC5jX3N0cigpKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJQYXRoICVzIGlzIHNoYWR5IiwgcGF0aC5jX3N0cigpKSk7CiAgICAgfQogICAgIGZvciAoY29uc3QgY2hhciYgYyA6IHBhdGgpIHsKICAgICAgICAgaWYgKGMgPT0gJ1wwJyB8fCBjID09ICdcbicpIHsKICAgICAgICAgICAgIHJldHVybiBleGNlcHRpb24oYmluZGVyOjpTdGF0dXM6OkVYX0lMTEVHQUxfQVJHVU1FTlQsCi0gICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiUGF0aCAlcyBpcyBtYWxmb3JtZWQiLCBwYXRoLmNfc3RyKCkpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJQYXRoICVzIGlzIG1hbGZvcm1lZCIsIHBhdGguY19zdHIoKSkpOwogICAgICAgICB9CiAgICAgfQogICAgIHJldHVybiBvaygpOwpAQCAtMTQwLDQ1ICsxNDEsMTQ0IEBACiAgICAgZm9yIChjb25zdCBjaGFyJiBjIDogaGV4KSB7CiAgICAgICAgIGlmICghc3RkOjppc3hkaWdpdChjKSAmJiBjICE9ICc6JyAmJiBjICE9ICctJykgewogICAgICAgICAgICAgcmV0dXJuIGV4Y2VwdGlvbihiaW5kZXI6OlN0YXR1czo6RVhfSUxMRUdBTF9BUkdVTUVOVCwKLSAgICAgICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJIZXggJXMgaXMgbWFsZm9ybWVkIiwgaGV4LmNfc3RyKCkpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJIZXggJXMgaXMgbWFsZm9ybWVkIiwgaGV4LmNfc3RyKCkpKTsKICAgICAgICAgfQogICAgIH0KICAgICByZXR1cm4gb2soKTsKIH0KIAotI2RlZmluZSBFTkZPUkNFX1VJRCh1aWQpIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotICAgIGJpbmRlcjo6U3RhdHVzIHN0YXR1cyA9IGNoZWNrVWlkKCh1aWQpKTsgICAgICAgICAgICAgICAgXAotICAgIGlmICghc3RhdHVzLmlzT2soKSkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotICAgICAgICByZXR1cm4gc3RhdHVzOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotICAgIH0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorYmluZGVyOjpTdGF0dXMgY2hlY2tBcmd1bWVudFBhY2thZ2VOYW1lKGNvbnN0IHN0ZDo6c3RyaW5nJiBwYWNrYWdlTmFtZSkgeworICAgIC8vIFRoaXMgbG9naWMgaXMgYm9ycm93ZWQgZnJvbSBQYWNrYWdlUGFyc2VyLmphdmEKKyAgICBib29sIGhhc1NlcCA9IGZhbHNlOworICAgIGJvb2wgZnJvbnQgPSB0cnVlOworCisgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBwYWNrYWdlTmFtZS5sZW5ndGgoKTsgKytpKSB7CisgICAgICAgIGNoYXIgYyA9IHBhY2thZ2VOYW1lW2ldOworICAgICAgICBpZiAoKGMgPj0gJ2EnICYmIGMgPD0gJ3onKSB8fCAoYyA+PSAnQScgJiYgYyA8PSAnWicpKSB7CisgICAgICAgICAgICBmcm9udCA9IGZhbHNlOworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KKyAgICAgICAgaWYgKCFmcm9udCkgeworICAgICAgICAgICAgaWYgKChjID49ICcwJyAmJiBjIDw9ICc5JykgfHwgYyA9PSAnXycpIHsKKyAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBpZiAoYyA9PSAnLicpIHsKKyAgICAgICAgICAgIGhhc1NlcCA9IHRydWU7CisgICAgICAgICAgICBmcm9udCA9IHRydWU7CisgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gZXhjZXB0aW9uKGJpbmRlcjo6U3RhdHVzOjpFWF9JTExFR0FMX0FSR1VNRU5ULAorICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiQmFkIHBhY2thZ2UgY2hhcmFjdGVyICVjIGluICVzIiwgYywgcGFja2FnZU5hbWUuY19zdHIoKSkpOworICAgIH0KKworICAgIGlmIChmcm9udCkgeworICAgICAgICByZXR1cm4gZXhjZXB0aW9uKGJpbmRlcjo6U3RhdHVzOjpFWF9JTExFR0FMX0FSR1VNRU5ULAorICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiTWlzc2luZyBzZXBhcmF0b3IgaW4gJXMiLCBwYWNrYWdlTmFtZS5jX3N0cigpKSk7CisgICAgfQorCisgICAgcmV0dXJuIG9rKCk7CiB9CiAKLSNkZWZpbmUgQ0hFQ0tfQVJHVU1FTlRfSUQoaWQpIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICBiaW5kZXI6OlN0YXR1cyBzdGF0dXMgPSBjaGVja0FyZ3VtZW50SWQoKGlkKSk7ICAgICAgICAgIFwKLSAgICBpZiAoIXN0YXR1cy5pc09rKCkpIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICAgICAgcmV0dXJuIHN0YXR1czsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICB9ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKK2JpbmRlcjo6U3RhdHVzIGNoZWNrQXJndW1lbnRQYWNrYWdlTmFtZXMoY29uc3Qgc3RkOjp2ZWN0b3I8c3RkOjpzdHJpbmc+JiBwYWNrYWdlTmFtZXMpIHsKKyAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IHBhY2thZ2VOYW1lcy5zaXplKCk7ICsraSkgeworICAgICAgICBiaW5kZXI6OlN0YXR1cyBzdGF0dXMgPSBjaGVja0FyZ3VtZW50UGFja2FnZU5hbWUocGFja2FnZU5hbWVzW2ldKTsKKyAgICAgICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7CisgICAgICAgICAgICByZXR1cm4gc3RhdHVzOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiBvaygpOwogfQogCi0jZGVmaW5lIENIRUNLX0FSR1VNRU5UX1BBVEgocGF0aCkgeyAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gY2hlY2tBcmd1bWVudFBhdGgoKHBhdGgpKTsgICAgICBcCi0gICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgIHJldHVybiBzdGF0dXM7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCitiaW5kZXI6OlN0YXR1cyBjaGVja0FyZ3VtZW50U2FuZGJveElkKGNvbnN0IHN0ZDo6c3RyaW5nJiBzYW5kYm94SWQpIHsKKyAgICAvLyBzYW5kYm94SWQgd2lsbCBiZSBpbiBlaXRoZXIgdGhlIGZvcm1hdCBzaGFyZWQtPHNoYXJlZC11c2VyLWlkPiBvciA8cGFja2FnZS1uYW1lPgorICAgIC8vIGFuZCA8c2hhcmVkLXVzZXItaWQ+IG5hbWUgaGFzIHNhbWUgcmVxdWlyZW1lbnRzIGFzIDxwYWNrYWdlLW5hbWU+LgorICAgIHN0ZDo6c2l6ZV90IG5hbWVTdGFydEluZGV4ID0gMDsKKyAgICBpZiAoYW5kcm9pZDo6YmFzZTo6U3RhcnRzV2l0aChzYW5kYm94SWQsICJzaGFyZWQtIikpIHsKKyAgICAgICAgbmFtZVN0YXJ0SW5kZXggPSA3OyAgLy8gbGVuKCJzaGFyZWQtIikKKyAgICB9CisgICAgcmV0dXJuIGNoZWNrQXJndW1lbnRQYWNrYWdlTmFtZShzYW5kYm94SWQuc3Vic3RyKG5hbWVTdGFydEluZGV4KSk7CiB9CiAKLSNkZWZpbmUgQ0hFQ0tfQVJHVU1FTlRfSEVYKGhleCkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICBiaW5kZXI6OlN0YXR1cyBzdGF0dXMgPSBjaGVja0FyZ3VtZW50SGV4KChoZXgpKTsgICAgICAgIFwKLSAgICBpZiAoIXN0YXR1cy5pc09rKCkpIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICAgICAgcmV0dXJuIHN0YXR1czsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICB9ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKK2JpbmRlcjo6U3RhdHVzIGNoZWNrQXJndW1lbnRTYW5kYm94SWRzKGNvbnN0IHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiYgc2FuZGJveElkcykgeworICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgc2FuZGJveElkcy5zaXplKCk7ICsraSkgeworICAgICAgICBiaW5kZXI6OlN0YXR1cyBzdGF0dXMgPSBjaGVja0FyZ3VtZW50U2FuZGJveElkKHNhbmRib3hJZHNbaV0pOworICAgICAgICBpZiAoIXN0YXR1cy5pc09rKCkpIHsKKyAgICAgICAgICAgIHJldHVybiBzdGF0dXM7CisgICAgICAgIH0KKyAgICB9CisgICAgcmV0dXJuIG9rKCk7CiB9CiAKLSNkZWZpbmUgQUNRVUlSRV9MT0NLIFwKKyNkZWZpbmUgRU5GT1JDRV9VSUQodWlkKSAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICBiaW5kZXI6OlN0YXR1cyBzdGF0dXMgPSBjaGVja1VpZCgodWlkKSk7IFwKKyAgICAgICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgICAgICByZXR1cm4gc3RhdHVzOyAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICB9ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB9CisKKyNkZWZpbmUgQ0hFQ0tfQVJHVU1FTlRfSUQoaWQpICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICBiaW5kZXI6OlN0YXR1cyBzdGF0dXMgPSBjaGVja0FyZ3VtZW50SWQoKGlkKSk7IFwKKyAgICAgICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgICAgICByZXR1cm4gc3RhdHVzOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICB9ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB9CisKKyNkZWZpbmUgQ0hFQ0tfQVJHVU1FTlRfUEFUSChwYXRoKSAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIGJpbmRlcjo6U3RhdHVzIHN0YXR1cyA9IGNoZWNrQXJndW1lbnRQYXRoKChwYXRoKSk7IFwKKyAgICAgICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICAgICAgcmV0dXJuIHN0YXR1czsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIH0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB9CisKKyNkZWZpbmUgQ0hFQ0tfQVJHVU1FTlRfSEVYKGhleCkgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gY2hlY2tBcmd1bWVudEhleCgoaGV4KSk7IFwKKyAgICAgICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgIHJldHVybiBzdGF0dXM7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB9CisKKyNkZWZpbmUgQ0hFQ0tfQVJHVU1FTlRfUEFDS0FHRV9OQU1FUyhwYWNrYWdlTmFtZXMpICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gY2hlY2tBcmd1bWVudFBhY2thZ2VOYW1lcygocGFja2FnZU5hbWVzKSk7IFwKKyAgICAgICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgIHJldHVybiBzdGF0dXM7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB9CisKKyNkZWZpbmUgQ0hFQ0tfQVJHVU1FTlRfU0FOREJPWF9JRFMoc2FuZGJveElkcykgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIGJpbmRlcjo6U3RhdHVzIHN0YXR1cyA9IGNoZWNrQXJndW1lbnRTYW5kYm94SWRzKChzYW5kYm94SWRzKSk7IFwKKyAgICAgICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICAgICAgcmV0dXJuIHN0YXR1czsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIH0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB9CisKKyNkZWZpbmUgQ0hFQ0tfQVJHVU1FTlRfUEFDS0FHRV9OQU1FKHBhY2thZ2VOYW1lKSAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICBiaW5kZXI6OlN0YXR1cyBzdGF0dXMgPSBjaGVja0FyZ3VtZW50UGFja2FnZU5hbWUoKHBhY2thZ2VOYW1lKSk7IFwKKyAgICAgICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgICAgICByZXR1cm4gc3RhdHVzOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICB9ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB9CisKKyNkZWZpbmUgQ0hFQ0tfQVJHVU1FTlRfU0FOREJPWF9JRChzYW5kYm94SWQpICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gY2hlY2tBcmd1bWVudFNhbmRib3hJZCgoc2FuZGJveElkKSk7IFwKKyAgICAgICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgIHJldHVybiBzdGF0dXM7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB9CisKKyNkZWZpbmUgQUNRVUlSRV9MT0NLICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgc3RkOjpsb2NrX2d1YXJkPHN0ZDo6bXV0ZXg+IGxvY2soVm9sdW1lTWFuYWdlcjo6SW5zdGFuY2UoKS0+Z2V0TG9jaygpKTsgXAogICAgIEFUUkFDRV9DQUxMKCk7CiAKLSNkZWZpbmUgQUNRVUlSRV9DUllQVF9MT0NLIFwKKyNkZWZpbmUgQUNRVUlSRV9DUllQVF9MT0NLICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKICAgICBzdGQ6OmxvY2tfZ3VhcmQ8c3RkOjptdXRleD4gbG9jayhWb2x1bWVNYW5hZ2VyOjpJbnN0YW5jZSgpLT5nZXRDcnlwdExvY2soKSk7IFwKICAgICBBVFJBQ0VfQ0FMTCgpOwogCkBAIC0xOTYsNyArMjk2LDcgQEAKICAgICByZXR1cm4gYW5kcm9pZDo6T0s7CiB9CiAKLXN0YXR1c190IFZvbGROYXRpdmVTZXJ2aWNlOjpkdW1wKGludCBmZCwgY29uc3QgVmVjdG9yPFN0cmluZzE2PiAmIC8qIGFyZ3MgKi8pIHsKK3N0YXR1c190IFZvbGROYXRpd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UkVfTE9DSzsKIAotICAgIHJldHVybiB0cmFuc2xhdGUoVm9sdW1lTWFuYWdlcjo6SW5zdGFuY2UoKS0+dW5tb3VudEFwcEZ1c2UodWlkLCBwaWQsIG1vdW50SWQpKTsKKyAgICByZXR1cm4gdHJhbnNsYXRlKFZvbHVtZU1hbmFnZXI6Okluc3RhbmNlKCktPnVubW91bnRBcHBGdXNlKHVpZCwgbW91bnRJZCkpOworfQorCitiaW5kZXI6OlN0YXR1cyBWb2xkTmF0aXZlU2VydmljZTo6b3BlbkFwcEZ1c2VGaWxlKGludDMyX3QgdWlkLCBpbnQzMl90IG1vdW50SWQsIGludDMyX3QgZmlsZUlkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IGZsYWdzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmRyb2lkOjpiYXNlOjp1bmlxdWVfZmQqIF9haWRsX3JldHVybikgeworICAgIEVORk9SQ0VfVUlEKEFJRF9TWVNURU0pOworICAgIEFDUVVJUkVfTE9DSzsKKworICAgIGludCBmZCA9IFZvbHVtZU1hbmFnZXI6Okluc3RhbmNlKCktPm9wZW5BcHBGdXNlRmlsZSh1aWQsIG1vdW50SWQsIGZpbGVJZCwgZmxhZ3MpOworICAgIGlmIChmZCA9PSAtMSkgeworICAgICAgICByZXR1cm4gZXJyb3IoIkZhaWxlZCB0byBvcGVuIEFwcEZ1c2UgZmlsZSBmb3IgdWlkOiAiICsgc3RkOjp0b19zdHJpbmcodWlkKSArCisgICAgICAgICAgICAgICAgICAgICAiIG1vdW50SWQ6ICIgKyBzdGQ6OnRvX3N0cmluZyhtb3VudElkKSArICIgZmlsZUlkOiAiICsgc3RkOjp0b19zdHJpbmcoZmlsZUlkKSArCisgICAgICAgICAgICAgICAgICAgICAiIGZsYWdzOiAiICsgc3RkOjp0b19zdHJpbmcoZmxhZ3MpKTsKKyAgICB9CisKKyAgICAq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bGFncykpOworfQorCitiaW5kZXI6OlN0YXR1cyBWb2xkTmF0aXZlU2VydmljZTo6cHJlcGFyZVNhbmRib3hGb3JBcHAoY29uc3Qgc3RkOjpzdHJpbmcmIHBhY2thZ2VOYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgYXBwSWQsIGNvbnN0IHN0ZDo6c3RyaW5nJiBzYW5kYm94SWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCB1c2VySWQpIHsKKyAgICBFTkZPUkNFX1VJRChBSURfU1lTVEVNKTsKKyAgICBDSEVDS19BUkdVTUVOVF9QQUNLQUdFX05BTUUocGFja2FnZU5hbWUpOworICAgIENIRUNLX0FSR1VNRU5UX1NBTkRCT1hfSUQoc2FuZGJveElkKTsKKyAgICBBQ1FVSVJFX0xPQ0s7CisKKyAgICByZXR1cm4gdHJhbnNsYXRlKAorICAgICAgICBWb2x1bWVNYW5hZ2VyOjpJbnN0YW5jZSgpLT5wcmVwYXJlU2FuZGJveEZvckFwcChwYWNrYWdlTmFtZSwgYXBwSWQsIHNhbmRib3hJZCwgdXNlcklkKSk7Cit9CisKK2JpbmRlcjo6U3RhdHVzIFZvbGROYXRpdmVTZXJ2aWNlOjpkZXN0cm95U2FuZGJveEZvckFwcChjb25zdCBzdGQ6OnN0cmluZyYgcGFja2FnZU5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIHNhbmRib3hJZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IHVzZXJJZCkgeworICAgIEVORk9SQ0VfVUlEKEFJRF9TWVNURU0pOworICAgIENIRUNLX0FSR1VNRU5UX1BBQ0tBR0VfTkFNRShwYWNrYWdlTmFtZ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NlID0gbWFrZWRldihtYWpvciwgbWlub3IpOwogCiAgICAgc3dpdGNoIChldnQtPmdldEFjdGlvbigpKSB7Ci0gICAgY2FzZSBOZXRsaW5rRXZlbnQ6OkFjdGlvbjo6a0FkZDogewotICAgICAgICBmb3IgKGNvbnN0IGF1dG8mIHNvdXJjZSA6IG1EaXNrU291cmNlcykgewotICAgICAgICAgICAgaWYgKHNvdXJjZS0+bWF0Y2hlcyhldmVudFBhdGgpKSB7Ci0gICAgICAgICAgICAgICAgLy8gRm9yIG5vdywgYXNzdW1lIHRoYXQgTU1DIGFuZCB2aXJ0aW8tYmxrICh0aGUgbGF0dGVyIGlzCi0gICAgICAgICAgICAgICAgLy8gZW11bGF0b3Itc3BlY2lmaWM7IHNlZSBEaXNrLmNwcCBmb3IgZGV0YWlscykgZGV2aWNlcyBhcmUgU0QsCi0gICAgICAgICAgICAgICAgLy8gYW5kIHRoYXQgZXZlcnl0aGluZyBlbHNlIGlzIFVTQgotICAgICAgICAgICAgICAgIGludCBmbGFncyA9IHNvdXJjZS0+Z2V0RmxhZ3MoKTsKLSAgICAgICAgICAgICAgICBpZiAobWFqb3IgPT0ga01ham9yQmxvY2tNbWMKLSAgICAgICAgICAgICAgICAgICAgfHwgKGFuZHJvaWQ6OnZvbGQ6OklzUnVubmluZ0luRW11bGF0b3IoKQotICAgICAgICAgICAgICAgICAgICAmJiBtYWpvciA+PSAoaW50KSBrTWFqb3JCbG9ja0V4cGVyaW1lbnRhbE1pbgotICAgICAgICAgICAgICAgICAgICAmJiBtYWpvciA8PSAoaW50KSBrTWFqb3JCbG9ja0V4cGVyaW1lbnRhbE1heCkpIHsKLSAgICAgICAgICAgICAgICAgICAgZmxhZ3MgfD0gYW5kcm9pZDo6dm9sZDo6RGlzazo6RmxhZ3M6OmtTZDsKLSAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICBmbGFncyB8PSBhbmRyb2lkOjp2b2xkOjpEaXNrOjpGbGFnczo6a1VzYjsKLSAgICAgICAgICAgICAgICB9CisgICAgICAgIGNhc2UgTmV0bGlua0V2ZW50OjpBY3Rpb246OmtBZGQ6IHsKKyAgICAgICAgICAgIGZvciAoY29uc3QgYXV0byYgc291cmNlIDogbURpc2tTb3VyY2VzKSB7CisgICAgICAgICAgICAgICAgaWYgKHNvdXJjZS0+bWF0Y2hlcyhldmVudFBhdGgpKSB7CisgICAgICAgICAgICAgICAgICAgIC8vIEZvciBub3csIGFzc3VtZSB0aGF0IE1NQyBhbmQgdmlydGlvLWJsayAodGhlIGxhdHRlciBpcworICAgICAgICAgICAgICAgICAgICAvLyBlbXVsYXRvci1zcGVjaWZpYzsgc2VlIERpc2suY3BwIGZvciBkZXRhaWxzKSBkZXZpY2VzIGFyZSBTRCwKKyAgICAgICAgICAgICAgICAgICAgLy8gYW5kIHRoYXQgZXZlcnl0aGluZyBlbHNlIGlzIFVTQgorICAgICAgICAgICAgICAgICAgICBpbnQgZmxhZ3MgPSBzb3VyY2UtPmdldEZsYWdzKCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChtYWpvciA9PSBrTWFqb3JCbG9ja01tYyB8fCAoYW5kcm9pZDo6dm9sZDo6SXNSdW5uaW5nSW5FbXVsYXRvcigpICYmCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFqb3IgPj0gKGludClrTWFqb3JCbG9ja0V4cGVyaW1lbnRhbE1pbiAmJgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ham9yIDw9IChpbnQpa01ham9yQmxvY2tFeHBlcmltZW50YWxNYXgpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBmbGFncyB8PSBhbmRyb2lkOjp2b2xkOjpEaXNrOjpGbGFnczo6a1NkOworICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgZmxhZ3MgfD0gYW5kcm9pZDo6dm9sZDo6RGlzazo6RmxhZ3M6OmtVc2I7CisgICAgICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGF1dG8gZGlzayA9IG5ldyBhbmRyb2lkOjp2b2xkOjpEaXNrKGV2ZW50UGF0aCwgZGV2aWNlLAotICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlLT5nZXROaWNrbmFtZSgpLCBmbGFncyk7Ci0gICAgICAgICAgICAgICAgaGFuZGxlRGlza0FkZGVkKHN0ZDo6c2hhcmVkX3B0cjxhbmRyb2lkOjp2b2xkOjpEaXNrPihkaXNrKSk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIGF1dG8gZGlzayA9CisgICAgICAgICAgICAgICAgICAgICAgICBuZXcgYW5kcm9pZDo6dm9sZDo6RGlzayhldmVudFBhdGgsIGRldmljZSwgc291cmNlLT5nZXROaWNrbmFtZSgpLCBmbGFncyk7CisgICAgICAgICAgICAgICAgICAgIGhhbmRsZURpc2tBZGRlZChzdGQ6OnNoYXJlZF9wdHI8YW5kcm9pZDo6dm9sZDo6RGlzaz4oZGlzaykpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CisgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQotICAgICAgICBicmVhazsKLSAgICB9Ci0gICAgY2FzZSBOZXRsaW5rRXZlbnQ6OkFjdGlvbjo6a0NoYW5nZTogewotICAgICAgICBMT0coREVCVUcpIDw8ICJEaXNrIGF0ICIgPDwgbWFqb3IgPDwgIjoiIDw8IG1pbm9yIDw8ICIgY2hhbmdlZCI7Ci0gICAgICAgIGhhbmRsZURpc2tDaGFuZ2VkKGRldmljZSk7Ci0gICAgICAgIGJyZWFrOwotICAgIH0KLSAgICBjYXNlIE5ldGxpbmtFdmVudDo6QWN0aW9uOjprUmVtb3ZlOiB7Ci0gICAgICAgIGhhbmRsZURpc2tSZW1vdmVkKGRldmljZSk7Ci0gICAgICAgIGJyZWFrOwotICAgIH0KLSAgICBkZWZhdWx0OiB7Ci0gICAgICAgIExPRyhXQVJOSU5HKSA8PCAiVW5leHBlY3RlZCBibG9jayBldmVudCBhY3Rpb24gIiA8PCAoaW50KSBldnQtPmdldEFjdGlvbigpOwotICAgICAgICBicmVhazsKLSAgICB9CisgICAgICAgIGNhc2UgTmV0bGlua0V2ZW50OjpBY3Rpb246OmtDaGFuZ2U6IHsKKyAgICAgICAgICAgIExPRyhERUJVRykgPDwgIkRpc2sgYXQgIiA8PCBtYWpvciA8PCAiOiIgPDwgbWlub3IgPDwgIiBjaGFuZ2VkIjsKKyAgICAgICAgICAgIGhhbmRsZURpc2tDaGFuZ2VkKGRldmljZSk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIE5ldGxpbmtFdmVudDo6QWN0aW9uOjprUmVtb3ZlOiB7CisgICAgICAgICAgICBoYW5kbGVEaXNrUmVtb3ZlZChkZXZpY2UpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgZGVmYXVsdDogeworICAgICAgICAgICAgTE9HKFdBUk5JTkcpIDw8ICJVbmV4cGVjdGVkIGJsb2NrIGV2ZW50IGFjdGlvbiAiIDw8IChpbnQpZXZ0LT5nZXRBY3Rpb24oKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CiAgICAgfQogfQogCkBAIC0yMzcsNyArMjYxLDcgQEAKICAgICAvLyB1bnRpbCB0aGUgdXNlciB1bmxvY2tzIHRoZSBkZXZpY2UgdG8gYWN0dWFsbHkgdG91Y2ggaXQKICAgICBpZiAobVNlY3VyZUtleWd1YXJkU2hvd2luZykgewogICAgICAgICBMT0coSU5GTykgPDwgIkZvdW5kIGRpc2sgYXQgIiA8PCBkaXNrLT5nZXRFdmVudFBhdGgoKQotICAgICAgICAgICAgICAgIDw8ICIgYnV0IGRlbGF5aW5nIHNjYW4gZHVlIHRvIHNlY3VyZSBrZXlndWFyZCI7CisgIC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nZXQ7CisgICAgTE9HKERFQlVHKSA8PCAiTGlua2luZyAiIDw8IHNvdXJjZSA8PCAiIHRvICIgPDwgdGFyZ2V0OworICAgIFN5bWxpbmsoc291cmNlLCB0YXJnZXQpOworICAgIHJldHVybiAwOworfQorCitpbnQgVm9sdW1lTWFuYWdlcjo6bW91bnRQa2dTcGVjaWZpY0Rpcihjb25zdCBzdGQ6OnN0cmluZyYgbW50U291cmNlUm9vdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nJiBtbnRUYXJnZXRSb290LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIHBhY2thZ2VOYW1lLCBjb25zdCBjaGFyKiBkaXJOYW1lKSB7CisgICAgc3RkOjpzdHJpbmcgbW50U291cmNlRGlyID0KKyAgICAgICAgU3RyaW5nUHJpbnRmKCIlcy9BbmRyb2lkLyVzLyVzIiwgbW50U291cmNlUm9vdC5jX3N0cigpLCBkaXJOYW1lLCBwYWNrYWdlTmFtZS5jX3N0cigpKTsKKyAgICBpZiAoQ3JlYXRlRGlyKG1udFNvdXJjZURpciwgMDc1NSkgPCAwKSB7CisgICAgICAgIHJldHVybiAtZXJybm87CisgICAgfQorICAgIHN0ZDo6c3RyaW5nIG1udFRhcmdldERpciA9CisgICAgICAgIFN0cmluZ1ByaW50ZigiJXMvQW5kcm9pZC8lcy8lcyIsIG1udFRhcmdldFJvb3QuY19zdHIoKSwgZGlyTmFtZSwgcGFja2FnZU5hbWUuY19zdHIoKSk7CisgICAgaWYgKENyZWF0ZURpcihtbnRUYXJnZXREaXIsIDA3NTUpIDwgMCkgeworICAgICAgICByZXR1cm4gLWVycm5vOworICAgIH0KKyAgICByZXR1cm4gQmluZE1vdW50KG1udFNvdXJjZURpciwgbW50VGFyZ2V0RGlyKTsKK30KKworaW50IFZvbHVtZU1hbmFnZXI6Om1vdW50UGtnU3Bl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KKyAgICB9CisgICAgaWYgKFRFTVBfRkFJTFVSRV9SRVRSWShzdGF0KCIvbW50L3J1bnRpbWUvd3JpdGUiLCAmbW50V3JpdGVTYikpID09IC0xKSB7CisgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gc3RhdCAvbW50L3J1bnRpbWUvd3JpdGUiOworICAgICAgICByZXR1cm4gLTE7CisgICAgfQorCisgICAgc3RkOjpzdHJpbmcgb2JiTW91bnREaXIgPSBTdHJpbmdQcmludGYoIi9tbnQvdXNlci8lZC9vYmJfbW91bnQiLCB1c2VySWQpOworICAgIGlmIChmc19wcmVwYXJlX2RpcihvYmJNb3VudERpci5jX3N0cigpLCAwNzAwLCBBSURfUk9PVCwgQUlEX1JPT1QpICE9IDApIHsKKyAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBmc19wcmVwYXJlX2RpciAiIDw8IG9iYk1vdW50RGlyOworICAgICAgICByZXR1cm4gLTE7CisgICAgfQorICAgIGNvbnN0IHVuaXF1ZV9mZCBvYmJNb3VudERpckZkKAorICAgICAgICBURU1QX0ZBSUxVUkVfUkVUUlkob3BlbihvYmJNb3VudERpci5jX3N0cigpLCBPX1JET05MWSB8IE9fRElSRUNUT1JZIHwgT19DTE9FWEVDKSkpOworICAgIGlmIChvYmJNb3VudERpckZkLmdldCgpIDwgMCkgeworICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIG9wZW4gIiA8PCBvYmJNb3VudERpcjsKKyAgICAgICAgcmV0dXJuIC0xOworICAgIH0KKworICAgIHN0ZDo6dW5vcmRlcmVkX3NldDxhcHBpZF90PiB2YWxpZEFwcElkczsKKyAgICBmb3IgKGF1dG8mIHBhY2thZ2UgOiBwYWNrYWdlTmFtZXMpIHsKKyAgICAgICAgdmFsaWRBcHBJZHMuaW5zZXJ0KG1BcHBJZHNbcGFja2FnZV0pOworICAgIH0KKyAgICBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4mIHVzZXJQYWNrYWdlcyA9IG1Vc2VyUGFja2FnZXNbdXNlcklkXTsKKworICAgIHN0ZDo6dmVjdG9yPHBpZF90PiBjaGlsZFBpZHM7CisKKyAgICBzdHJ1Y3QgZGlyZW50KiBkZTsKKyAgICAvLyBQb2tlIHRocm91Z2ggYWxsIHJ1bm5pbmcgUElEcyBsb29rIGZvciBhcHBzIHJ1bm5pbmcgaW4gdXNlcklkCisgICAgd2hpbGUgKChkZSA9IHJlYWRkaXIoZGlycC5nZXQoKSkpKSB7CisgICAgICAgIHBpZF90IHBpZDsKKyAgICAgICAgaWYgKGRlLT5kX3R5cGUgIT0gRFRfRElSKSBjb250aW51ZTsKKyAgICAgICAgaWYgKCFhbmRyb2lkOjpiYXNlOjpQYXJzZUludChkZS0+ZF9uYW1lLCAmcGlkKSkgY29udGludWU7CisKKyAgICAgICAgY29uc3QgdW5pcXVlX2ZkIHBpZEZkKAorICAgICAgICAgICAgb3BlbmF0KGRpcmZkKGRpcnAuZ2V0KCkpLCBkZS0+ZF9uYW1lLCBPX1JET05MWSB8IE9fRElSRUNUT1JZIHwgT19DTE9FWEVDKSk7CisgICAgICAgIGlmIChwaWRGZC5nZXQoKSA8IDApIHsKKyAgICAgICAgICAgIFBMT0coV0FSTklORykgPDwgIkZhaWxlZCB0byBvcGVuIC9wcm9jLyIgPDwgcGlkOworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KKyAgICAgICAgc3RydWN0IHN0YXQgc2I7CisgICAgICAgIGlmIChmc3RhdChwaWRGZC5nZXQoKSwgJnNiKSAhPSAwKSB7CisgICAgICAgICAgICBQTE9HKFdBUk5JTkcpIDw8ICJGYWlsZWQgdG8gc3RhdCAiIDw8IGRlLT5kX25hbWU7CisgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgfQorICAgICAgICBpZiAobXVsdGl1c2VyX2dldF91c2VyX2lkKHNiLnN0X3VpZCkgIT0gdXNlcklkKSB7CisgICAgICAgICAgICBjb250aW51ZTs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ICBmb3IgKGF1dG8mIHBhY2thZ2UgOiB1c2VyUGFja2FnZXMpIHsKKyAgICAgICAgICAgIGlmIChtQXBwSWRzW3BhY2thZ2VdID09IGFwcElkKSB7CisgICAgICAgICAgICAgICAgcGFja2FnZXNGb3JVaWQucHVzaF9iYWNrKHBhY2thZ2UpOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIGlmIChwYWNrYWdlc0ZvclVpZC5lbXB0eSgpKSB7CisgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgfQorICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgc2FuZGJveElkID0gbVNhbmRib3hJZHNbYXBwSWRdOworCisgICAgICAgIC8vIFdlIHB1cnBvc2VmdWxseSBsZWF2ZSB0aGUgbmFtZXNwYWNlIG9wZW4gYWNyb3NzIHRoZSBmb3JrCisgICAgICAgIC8vIE5PTElOVE5FWFRMSU5FKGFuZHJvaWQtY2xvZXhlYy1vcGVuKTogRGVsaWJlcmF0ZWx5IG5vdCBPX0NMT0VYRUMKKyAgICAgICAgdW5pcXVlX2ZkIG5zRmQob3BlbmF0KHBpZEZkLmdldCgpLCAibnMvbW50IiwgT19SRE9OTFkpKTsKKyAgICAgICAgaWYgKG5zRmQuZ2V0KCkgPCAwKSB7CisgICAgICAgICAgICBQTE9HKFdBUk5JTkcpIDw8ICJGYWlsZWQgdG8gb3BlbiBuYW1lc3BhY2UgZm9yICIgPDwgZGUtPmRfbmFtZTsKKyAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICB9CisKKyAgICAgICAgcGlkX3QgY2hpbGQ7CisgICAgICAgIGlmICghKGNoaWxkID0gZm9yaygpKSkgeworICAgICAgICAgICAgaWYgKHNldG5zKG5zRmQuZ2V0KCksIENMT05FX05FV05TKSAhPSAwKSB7CisgICAgICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBzZXRucyBmb3IgIiA8PCBkZS0+ZF9uYW1lOworICAgICAgICAgICAgICAgIF9leGl0KDEpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBpbnQgbW91bnRNb2RlOworICAgICAgICAgICAgaWYgKHJlbW91bnRNb2RlID09IC0xKSB7CisgICAgICAgICAgICAgICAgbW91bnRNb2RlID0KKyAgICAgICAgICAgICAgICAgICAgZ2V0TW91bnRNb2RlRm9yUnVubmluZ1Byb2MocGFja2FnZXNGb3JVaWQsIHVzZXJJZCwgbW50V3JpdGVTYiwgbW50RnVsbFNiKTsKKyAgICAgICAgICAgICAgICBpZiAobW91bnRNb2RlID09IC0xKSB7CisgICAgICAgICAgICAgICAgICAgIF9leGl0KDEpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgbW91bnRNb2RlID0gcmVtb3VudE1vZGU7CisgICAgICAgICAgICAgICAgaWYgKGhhbmRsZU1vdW50TW9kZUluc3RhbGxlcihtb3VudE1vZGUsIG9iYk1vdW50RGlyRmQuZ2V0KCksIG9iYk1vdW50RGlyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2FuZGJveElkKSA8IDApIHsKKyAgICAgICAgICAgICAgICAgICAgX2V4aXQoMSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKG1vdW50TW9kZSA9PSBWb2xkTmF0aXZlU2VydmljZTo6UkVNT1VOVF9NT0RFX0ZVTEwgfHwKKyAgICAgICAgICAgICAgICBtb3VudE1vZGUgPT0gVm9sZE5hdGl2ZVNlcnZpY2U6OlJFTU9VTlRfTU9ERV9MRUdBQ1kgfHwKKyAgICAgICAgICAgICAgICBtb3VudE1vZGUgPT0gVm9sZE5hdGl2ZVNlcnZpY2U6OlJFTU9VTlRfTU9ERV9OT05FKSB7CisgICAgICAgICAgICAgICAgLy8gVGhlc2UgbW91bnQgbW9kZXMgYXJlIG5vdCBnb2luZyB0byBjaGFuZ2UgZHluYW1pY2FsbHksIHNvIGRvbid0IGJvdGhlcgorICAgICAgICAgICAgICAgIC8vIHVubW91bnRpbmcvcmVtb3VudGluZyBkaXJzLgorICAgICAgICAgICAgICAgIF9leGl0KDApOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBmb3IgKGF1dG8mIHZvbHVtZUxhYmVsIDogdmlzaWJsZVZvbExhYmVscykgeworICAgICAgICAgICAgICAgIHN0ZDo6c3RyaW5nIG1udFNvdXJjZSA9IFN0cmluZ1ByaW50ZigiL21udC9ydW50aW1lL3dyaXRlLyVzIiwgdm9sdW1lTGFiZWwuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgc3RkOjpzdHJpbmcgbW50VGFyZ2V0ID0gU3RyaW5nUHJpbnRmKCIvc3RvcmFnZS8lcyIsIHZvbHVtZUxhYmVsLmNfc3RyKCkpOworICAgICAgICAgICAgICAgIGlmICh2b2x1bWVMYWJlbCA9PSAiZW11bGF0ZWQiKSB7CisgICAgICAgICAgICAgICAgICAgIFN0cmluZ0FwcGVuZEYoJm1udFNvdXJjZSwgIi8lZCIsIHVzZXJJZCk7CisgICAgICAgICAgICAgICAgICAgIFN0cmluZ0FwcGVuZEYoJm1udFRhcmdldCwgIi8lZCIsIHVzZXJJZCk7CisgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgc3RkOjpzdHJpbmcgc2FuZGJveFNvdXJjZSA9CisgICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiJXMvQW5kcm9pZC9zYW5kYm94LyVzIiwgbW50U291cmNlLmNfc3RyKCksIHNhbmRib3hJZC5jX3N0cigpKTsKKyAgICAgICAgICAgICAgICBpZiAoQ3JlYXRlRGlyKHNhbmRib3hTb3VyY2UsIDA3NTUpIDwgMCkgeworICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKEJpbmRNb3VudChzYW5kYm94U291cmNlLCBtbnRUYXJnZXQpIDwgMCkgeworICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBzdGQ6OnN0cmluZyBvYmJTb3VyY2VEaXIgPSBTdHJpbmdQcmludGYoIiVzL0FuZHJvaWQvb2JiIiwgbW50U291cmNlLmNfc3RyKCkpOworICAgICAgICAgICAgICAgIHN0ZDo6c3RyaW5nIG9iYlRhcmdldERpciA9IFN0cmluZ1ByaW50ZigiJXMvQW5kcm9pZC9vYmIiLCBtbnRUYXJnZXQuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgaWYgKFVubW91bnRUcmVlKG9iYlRhcmdldERpcikgPCAwKSB7CisgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAoIWNyZWF0ZVBrZ1NwZWNpZmljRGlyUm9vdHMobW50U291cmNlKSB8fCAhY3JlYXRlUGtnU3BlY2lmaWNEaXJSb290cyhtbnRUYXJnZXQpKSB7CisgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBmb3IgKGF1dG8mIHBhY2thZ2UgOiBwYWNrYWdlc0ZvclVpZCkgeworICAgICAgICAgICAgICAgICAgICBtb3VudFBrZ1NwZWNpZmljRGlyKG1udFNvdXJjZSwgbW50VGFyZ2V0LCBwYWNrYWdlLCAiZGF0YSIpOworICAgICAgICAgICAgICAgICAgICBtb3VudFBrZ1NwZWNpZmljRGlyKG1udFNvdXJjZSwgbW50VGFyZ2V0LCBwYWNrYWdlLCAibWVkaWEiKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1vdW50TW9kZSAhPSBWb2xkTmF0aXZlU2VydmljZTo6UkVNT1VOVF9NT0RFX0lOU1RBTExFUikgeworICAgICAgICAgICAgICAgICAgICAgICAgbW91bnRQa2dTcGVjaWZpY0RpcihtbnRTb3VyY2UsIG1udFRhcmdldCwgcGFja2FnZSwgIm9iYiIpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGlmIChtb3VudE1vZGUgPT0gVm9sZE5hdGl2ZVNlcnZpY2U6OlJFTU9VTlRfTU9ERV9JTlNUQUxMRVIpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKEJpbmRNb3VudChvYmJTb3VyY2VEaXIsIG9iYlRhcmdldERpcikgPCAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIF9leGl0KDApOworICAgICAgICB9CisKKyAgICAgICAgaWYgKGNoaWxkID09IC0xKSB7CisgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIGZvcmsiOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgY2hpbGRQaWRzLnB1c2hfYmFjayhjaGlsZCk7CiAgICAgICAgIH0KICAgICB9Ci0gICAgTE9HKERFQlVHKSA8PCAiTGlua2luZyAiIDw8IHNvdXJjZSA8PCAiIHRvICIgPDwgdGFyZ2V0OwotICAgIGlmIChURU1QX0ZBSUxVUkVfUkVUUlkoc3ltbGluayhzb3VyY2UuY19zdHIoKSwgdGFyZ2V0LmNfc3RyKCkpKSkgewotICAgICAgICBQTE9HKFdBUk5JTkcpIDw8ICJGYWlsZWQgdG8gbGluayI7CisgICAgZm9yIChhdXRvJiBjaGlsZCA6IGNoaWxkUGlkcykgeworICAgICAgICBURU1QX0ZBSUxVUkVfUkVUUlkod2FpdHBpZChjaGlsZCwgbnVsbHB0ciwgMCkpOworICAgIH0KKyAgICByZXR1cm4gMDsKK30KKworaW50IFZvbHVtZU1hbmFnZXI6OmdldE1vdW50TW9kZUZvclJ1bm5pbmdQcm9jKGNvbnN0IHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiYgcGFja2FnZXNGb3JVaWQ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VJST1IpIDw8ICJGYWlsZWQgdG8gc3RhdCAiIDw8IHNhbmRib3g7CisgICAgICAgIHJldHVybiAtMTsKKyAgICB9CisgICAgaWYgKHN0b3JhZ2VTYi5zdF9kZXYgPT0gc2FuZGJveFN0YXQuc3RfZGV2ICYmIHN0b3JhZ2VTYi5zdF9pbm8gPT0gc2FuZGJveFN0YXQuc3RfaW5vKSB7CisgICAgICAgIHJldHVybiBWb2xkTmF0aXZlU2VydmljZTo6UkVNT1VOVF9NT0RFX1dSSVRFOworICAgIH0KKworICAgIHJldHVybiBWb2xkTmF0aXZlU2VydmljZTo6UkVNT1VOVF9NT0RFX05PTkU7Cit9CisKK2ludCBWb2x1bWVNYW5hZ2VyOjpoYW5kbGVNb3VudE1vZGVJbnN0YWxsZXIoaW50IG1vdW50TW9kZSwgaW50IG9iYk1vdW50RGlyRmQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nJiBvYmJNb3VudERpciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIHNhbmRib3hJZCkgeworICAgIGlmIChtb3VudE1vZGUgPT0gVm9sZE5hdGl2ZVNlcnZpY2U6OlJFTU9VTlRfTU9ERV9JTlNUQUxMRVIpIHsKKyAgICAgICAgaWYgKFRFTVBfRkFJTFVSRV9SRVRSWShmYWNjZXNzYXQob2JiTW91bnREaXJGZCwgc2FuZGJveElkLmNfc3RyKCksIEZfT0ssIDApKSAhPSAtMSkgeworICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgIH0gZWxzZSBpZiAoZXJybm8gIT0gRU5PRU5UKSB7CisgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIGFjY2VzcyAiIDw8IG9iYk1vdW50RGlyIDw8ICIvIiA8PCBzYW5kYm94SWQ7CisgICAgICAgICAgICByZXR1cm4gLWVycm5vOworICAgICAgICB9CisgICAgICAgIGNvbnN0IHVuaXF1ZV9mZCBmZChURU1QX0ZBSUxVUkVfUkVUUlkoCisgICAgICAgICAgICBvcGVuYXQob2JiTW91bnREaXJGZCwgc2FuZGJveElkLmNfc3RyKCksIE9fUkRXUiB8IE9fQ1JFQVQgfCBPX0NMT0VYRUMsIDA2MDApKSk7CisgICAgICAgIGlmIChmZC5nZXQoKSA8IDApIHsKKyAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gY3JlYXRlICIgPDwgb2JiTW91bnREaXIgPDwgIi8iIDw8IHNhbmRib3hJZDsKKyAgICAgICAgICAgIHJldHVybiAtZXJybm87CisgICAgICAgIH0KKyAgICB9IGVsc2UgeworICAgICAgICBpZiAoVEVNUF9GQUlMVVJFX1JFVFJZKGZhY2Nlc3NhdChvYmJNb3VudERpckZkLCBzYW5kYm94SWQuY19zdHIoKSwgRl9PSywgMCkpICE9IC0xKSB7CisgICAgICAgICAgICBpZiAoVEVNUF9GQUlMVVJFX1JFVFJZKHVubGlua2F0KG9iYk1vdW50RGlyRmQsIHNhbmRib3hJZC5jX3N0cigpLCAwKSkgPT0gLTEpIHsKKyAgICAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIHVubGluayAiIDw8IG9iYk1vdW50RGlyIDw8ICIvIiA8PCBzYW5kYm94SWQ7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfSBlbHNlIGlmIChlcnJubyAhPSBFTk9FTlQpIHsKKyAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gYWNjZXNzICIgPDwgb2JiTW91bnREaXIgPDwgIi8iIDw8IHNhbmRib3hJZDsKKyAgICAgICAgICAgIHJldHVybiAtZXJybm87CisgICAgICAgIH0KKyAgICB9CisgICAgcmV0dXJuIDA7Cit9CisKK2ludCBWb2x1bWVNYW5hZ2VyOjpwcmVwYXJlU2FuZGJveGVzKHVzZXJpZF90IHVzZXJJZCwgY29uc3Qgc3RkOjp2ZWN0b3I8c3RkOjpzdHJpbmc+JiBwYWNrYWdlTmFtZXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4mIHZpc2libGVWb2xMYWJlbHMpIHsKKyAgICBpZiAodmlzaWJsZVZvbExhYmVscy5lbXB0eSgpKSB7CisgICAgICAgIHJldHVybiAwOworICAgIH0KKyAgICBmb3IgKGF1dG8mIHZvbHVtZUxhYmVsIDogdmlzaWJsZVZvbExhYmVscykgeworICAgICAgICBzdGQ6OnN0cmluZyB2b2x1bWVSb290KFN0cmluZ1ByaW50ZigiL21udC9ydW50aW1lL3dyaXRlLyVzIiwgdm9sdW1lTGFiZWwuY19zdHIoKSkpOworICAgICAgICBib29sIGlzVm9sUHJpbWFyeUVtdWxhdGVkID0gKHZvbHVtZUxhYmVsID09IG1QcmltYXJ5LT5nZXRMYWJlbCgpICYmIG1QcmltYXJ5LT5pc0VtdWxhdGVkKCkpOworICAgICAgICBpZiAoaXNWb2xQcmltYXJ5RW11bGF0ZWQpIHsKKyAgICAgICAgICAgIFN0cmluZ0FwcGVuZEYoJnZvbHVtZVJvb3QsICIvJWQiLCB1c2VySWQpOworICAgICAgICAgICAgaWYgKENyZWF0ZURpcih2b2x1bWVSb290LCAwNzU1KSA8IDApIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gLWVycm5vOworICAgICAgICAgICAgfQorICAgICAgICB9CisKKyAgICAgICAgc3RkOjpzdHJpbmcgc2FuZGJveFJvb3QgPQorICAgICAgICAgICAgcHJlcGFyZVN1YkRpcnModm9sdW1lUm9vdCwgIkFuZHJvaWQvc2FuZGJveC8iLCAwNzAwLCBBSURfUk9PVCwgQUlEX1JPT1QpOworICAgICAgICBpZiAoc2FuZGJveFJvb3QuZW1wdHkoKSkgeworICAgICAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICAgICAgfQorICAgIH0KKworICAgIGlmIChwcmVwYXJlU2FuZGJveFRhcmdldHModXNlcklkLCB2aXNpYmxlVm9sTGFiZWxzKSA8IDApIHsKKyAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICB9CisKKyAgICBpZiAobW91bnRQa2dTcGVjaWZpY0RpcnNGb3JSdW5uaW5nUHJvY3ModXNlcklkLCBwYWNrYWdlTmFtZXMsIHZpc2libGVWb2xMYWJlbHMsIC0xKSA8IDApIHsKKyAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBzZXR1cCBzYW5kYm94ZXMgZm9yIGFscmVhZHkgcnVubmluZyBwcm9jZXNzZXMiOwogICAgICAgICByZXR1cm4gLWVycm5vOwogICAgIH0KICAgICByZXR1cm4gMDsKIH0KIAoraW50IFZvbHVtZU1hbmFnZXI6OnByZXBhcmVTYW5kYm94VGFyZ2V0cyh1c2VyaWRfdCB1c2VySWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiYgdmlzaWJsZVZvbExhYmVscykgeworICAgIHN0ZDo6c3RyaW5nIG1udFRhcmdldFJvb3QgPSBTdHJpbmdQcmludGYoIi9tbnQvdXNlci8lZCIsIHVzZXJJZCk7CisgICAgaWYgKGZzX3ByZXBhcmVfZGlyKG1udFRhcmdldFJvb3QuY19zdHIoKSwgMDc1MSwgQUlEX1JPT1QsIEFJRF9ST09UKSAhPSAwKSB7CisgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gZnNfcHJlcGFyZV9kaXIgIiA8PCBtbnRUYXJnZXRSb290OworICAgICAgICByZXR1cm4gLWVycm5vOworICAgIH0KKworICAgIFN0cmluZ0FwcGVuZEYoJm1udFRhcmdldFJvb3QsICIvcGFja2FnZSIpOworICAgIGlmIChmc19wcmVwYXJlX2RpcihtbnRUYXJnZXRSb290Lm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AgICAgICAgICAgIHJldHVybiAtZXJybm87CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisKKyAgICBTdHJpbmdBcHBlbmRGKCZtbnRUYXJnZXRSb290LCAiL3NlbGYiKTsKKyAgICBpZiAoZnNfcHJlcGFyZV9kaXIobW50VGFyZ2V0Um9vdC5jX3N0cigpLCAwNzU1LCBBSURfUk9PVCwgQUlEX1JPT1QpICE9IDApIHsKKyAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBmc19wcmVwYXJlX2RpciAiIDw8IG1udFRhcmdldFJvb3Q7CisgICAgICAgIHJldHVybiAtZXJybm87CisgICAgfQorCisgICAgaWYgKG1QcmltYXJ5KSB7CisgICAgICAgIHN0ZDo6c3RyaW5nIHBrZ1ByaW1hcnlTb3VyY2UobVByaW1hcnktPmdldFBhdGgoKSk7CisgICAgICAgIGlmIChtUHJpbWFyeS0+aXNFbXVsYXRlZCgpKSB7CisgICAgICAgICAgICBTdHJpbmdBcHBlbmRGKCZwa2dQcmltYXJ5U291cmNlLCAiLyVkIiwgdXNlcklkKTsKKyAgICAgICAgfQorICAgICAgICBTdHJpbmdBcHBlbmRGKCZtbnRUYXJnZXRSb290LCAiL3ByaW1hcnkiKTsKKyAgICAgICAgaWYgKFN5bWxpbmsocGtnUHJpbWFyeVNvdXJjZSwgbW50VGFyZ2V0Um9vdCkgPCAwKSB7CisgICAgICAgICAgICByZXR1cm4gLWVycm5vOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiAwOworfQorCitzdGQ6OnN0cmluZyBWb2x1bWVNYW5hZ2VyOjpwcmVwYXJlU3ViRGlycyhjb25zdCBzdGQ6OnN0cmluZyYgcGF0aFByZWZpeCwgY29uc3Qgc3RkOjpzdHJpbmcmIHN1YkRpcnMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RlX3QgbW9kZSwgdWlkX3QgdWlkLCBnaWRfdCBnaWQpIHsKKyAgICBzdGQ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tZXMsIHZpc2libGVWb2xMYWJlbHMpICE9IDApIHsKKyAgICAgICAgICAgIHJldHVybiAtZXJybm87CisgICAgICAgIH0KKyAgICB9CiAgICAgcmV0dXJuIDA7CiB9CiAKIGludCBWb2x1bWVNYW5hZ2VyOjpvblVzZXJTdG9wcGVkKHVzZXJpZF90IHVzZXJJZCkgeworICAgIExPRyhWRVJCT1NFKSA8PCAib25Vc2VyU3RvcHBlZDogIiA8PCB1c2VySWQ7CiAgICAgbVN0YXJ0ZWRVc2Vycy5lcmFzZSh1c2VySWQpOworCisgICAgaWYgKGhhc0lzb2xhdGVkU3RvcmFnZSgpKSB7CisgICAgICAgIGF1dG8mIHVzZXJQYWNrYWdlcyA9IG1Vc2VyUGFja2FnZXNbdXNlcklkXTsKKyAgICAgICAgc3RkOjpzdHJpbmcgdXNlck1udFRhcmdldFJvb3QgPSBTdHJpbmdQcmludGYoIi9tbnQvdXNlci8lZCIsIHVzZXJJZCk7CisgICAgICAgIHN0ZDo6c3RyaW5nIHBrZ1ByaW1hcnlEaXIgPQorICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCIlcy9wYWNrYWdlL3NlbGYvcHJpbWFyeSIsIHVzZXJNbnRUYXJnZXRSb290LmNfc3RyKCkpOworICAgICAgICBpZiAoVW5saW5rKHBrZ1ByaW1hcnlEaXIpIDwgMCkgeworICAgICAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICAgICAgfQorICAgICAgICBtVXNlclBhY2thZ2VzLmVyYXNlKHVzZXJJZCk7CisgICAgICAgIGlmIChEZWxldGVEaXJDb250ZW50c0FuZERpcih1c2VyTW50VGFyZ2V0Um9vdCkgPCAwKSB7CisgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRGVsZXRlRGlyQ29udGVudHNBbmREaXIgZmFpbGVkIG9uICIgPDwgdXNlck1udFRhcmdldFJvb3Q7CisgICAgICAgICAgICByZXR1cm4gLWVycm5vOworICAgICAgICB9CisgICAgICAgIExPRyhWRVJCT1N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7CisgICAgICAgIGF1dG8gdm9sID0gZmluZFZvbHVtZSh2b2xJZCk7CisgICAgICAgIHVzZXJpZF90IG1vdW50VXNlcklkID0gdm9sLT5nZXRNb3VudFVzZXJJZCgpOworICAgICAgICBpZiAobW91bnRVc2VySWQgPT0gdXNlcklkIHx8IHZvbC0+aXNFbXVsYXRlZCgpKSB7CisgICAgICAgICAgICB2aXNpYmxlVm9sTGFiZWxzLnB1c2hfYmFjayh2b2wtPmdldExhYmVsKCkpOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiBwcmVwYXJlU2FuZGJveGVzKHVzZXJJZCwge3BhY2thZ2VOYW1lfSwgdmlzaWJsZVZvbExhYmVscyk7Cit9CisKK2ludCBWb2x1bWVNYW5hZ2VyOjpkZXN0cm95U2FuZGJveEZvckFwcChjb25zdCBzdGQ6OnN0cmluZyYgcGFja2FnZU5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIHNhbmRib3hJZCwgdXNlcmlkX3QgdXNlcklkKSB7CisgICAgaWYgKCFoYXNJc29sYXRlZFN0b3JhZ2UoKSkgeworICAgICAgICByZXR1cm4gMDsKKyAgICB9CisgICAgTE9HKFZFUkJPU0UpIDw8ICJkZXN0cm95U2FuZGJveEZvckFwcDogIiA8PCBwYWNrYWdlTmFtZSA8PCAiLCBzYW5kYm94SWQ9IiA8PCBzYW5kYm94SWQKKyAgICAgICAgICAgICAgICAgPDwgIiwgdXNlcklkPSIgPDwgdXNlcklkOworICAgIGF1dG8mIHVzZXJQYWNrYWdlcyA9IG1Vc2VyUGFja2FnZXNbdXNlcklkXTsKKyAgICB1c2VyUGFja2FnZXMuZXJhc2Uoc3RkOjpyZW1vdmUodXNlclBhY2thZ2VzLmJlZ2luKCksIHVzZXJQYWNrYWdlcy5lbmQoKSwgcGFja2FnZU5hbWUpLAorICAgICAgICAgICAgICAgICAgICAgICB1c2VyUGFja2FnZXMuZW5kKCkpOworICAgIC8vIElmIHRoZSBwYWNrYWdlIGlzIG5vdCB1bmluc3RhbGxlZCBpbiBhbnkgb3RoZXIgdXNlcnMsIHJlbW92ZSBhcHBJZCBhbmQgc2FuZGJveElkCisgICAgLy8gY29ycmVzcG9uZGluZyB0byBpdCBmcm9tIHRoZSBpbnRlcm5hbCBzdGF0ZS4KKyAgICBib29sIGluc3RhbGxlZEluQW55VXNlciA9IGZhbHNlOworICAgIGZvciAoYXV0byYgaXQgOiBtVXNlclBhY2thZ2VzKSB7CisgICAgICAgIGF1dG8mIHBhY2thZ2VzID0gaXQuc2Vjb25kOworICAgICAgICBpZiAoc3RkOjpmaW5kKHBhY2thZ2VzLmJlZ2luKCksIHBhY2thZ2VzLmVuZCgpLCBwYWNrYWdlTmFtZSkgIT0gcGFja2FnZXMuZW5kKCkpIHsKKyAgICAgICAgICAgIGluc3RhbGxlZEluQW55VXNlciA9IHRydWU7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgIH0KKyAgICBpZiAoIWluc3RhbGxlZEluQW55VXNlcikgeworICAgICAgICBjb25zdCBhdXRvJiBlbnRyeSA9IG1BcHBJZHMuZmluZChwYWNrYWdlTmFtZSk7CisgICAgICAgIGlmIChlbnRyeSAhPSBtQXBwSWRzLmVuZCgpKSB7CisgICAgICAgICAgICBtU2FuZGJveElkcy5lcmFzZShlbnRyeS0+c2Vjb25kKTsKKyAgICAgICAgICAgIG1BcHBJZHMuZXJhc2UoZW50cnkpOworICAgICAgICB9CisgICAgfQorCisgICAgc3RkOjp2ZWN0b3I8c3RkOjpzdHJpbmc+IHZpc2libGVWb2xMYWJlbHM7CisgICAgZm9yIChhdXRvJiB2b2xJZCA6IG1WaXNpYmxlVm9sdW1lSWRzKSB7CisgICAgICAgIGF1dG8gdm9sID0gZmluZFZvbHVtZSh2b2xJZCk7CisgICAgICAgIHVzZXJpZF90IG1vdW50VXNlcklkID0gdm9sLT5nZXRNb3VudFVzZXJJZCgpOworICAgICAgICBpZiAobW91bnRVc2VySWQgPT0gdXNlcklkIHx8IHZvbC0+aXNFbXVsYXRlZCgpKSB7CisgICAgICAgICAgICBpZiAoZGVzdHJveVNhbmRib3hGb3JBcHBPblZvbChwYWNrYWdlTmFtZSwgc2FuZGJveElkLCB1c2VySWQsIHZvbC0+Z2V0TGFiZWwoKSkgPCAwKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKworICAgIHJldHVybiAwOworfQorCitpbnQgVm9sdW1lTWFuYWdlcjo6ZGVzdHJveVNhbmRib3hGb3JBcHBPblZvbChjb25zdCBzdGQ6OnN0cmluZyYgcGFja2FnZU5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgc2FuZGJveElkLCB1c2VyaWRfdCB1c2VySWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgdm9sTGFiZWwpIHsKKyAgICBMT0coVkVSQk9TRSkgPDwgImRlc3Ryb3lTYW5kYm94T25Wb2w6ICIgPDwgcGFja2FnZU5hbWUgPDwgIiwgdXNlcklkPSIgPDwgdXNlcklkCisgICAgICAgICAgICAgICAgIDw8ICIsIHZvbExhYmVsPSIgPDwgdm9sTGFiZWw7CisKKyAgICBzdGQ6OnN0cmluZyBzYW5kYm94RGlyID0gU3RyaW5nUHJpbnRmKCIvbW50L3J1bnRpbWUvd3JpdGUvJXMiLCB2b2xMYWJlbC5jX3N0cigpKTsKKyAgICBpZiAodm9sTGFiZWwgPT0gbVByaW1hcnktPmdldExhYmVsKCkgJiYgbVByaW1hcnktPmlzRW11bGF0ZWQoKSkgeworICAgICAgICBTdHJpbmdBcHBlbmRGKCZzYW5kYm94RGlyLCAiLyVkIiwgdXNlcklkKTsKKyAgICB9CisgICAgU3RyaW5nQXBwZW5kRigmc2FuZG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c2hhcmVkX3B0cnMgb3duaW5nIHRoZSB1bmRlcmx5aW5nIHBvaW50ZXIgd2l0aG91dCBzaGFyaW5nIGl0LgorICAgICAgICBtUHJpbWFyeSA9IGZpbmRWb2x1bWUodm9sLT5nZXRJZCgpKTsKKyAgICAgICAgZm9yICh1c2VyaWRfdCB1c2VySWQgOiBtU3RhcnRlZFVzZXJzKSB7CisgICAgICAgICAgICBpZiAobGlua1ByaW1hcnkodXNlcklkKSAhPSAwKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKyAgICBpZiAodm9sLT5pc0VtdWxhdGVkKCkpIHsKKyAgICAgICAgZm9yICh1c2VyaWRfdCB1c2VySWQgOiBtU3RhcnRlZFVzZXJzKSB7CisgICAgICAgICAgICBpZiAocHJlcGFyZVNhbmRib3hlcyh1c2VySWQsIG1Vc2VyUGFja2FnZXNbdXNlcklkXSwge3ZvbC0+Z2V0TGFiZWwoKX0pICE9IDApIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gLWVycm5vOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfSBlbHNlIGlmIChtU3RhcnRlZFVzZXJzLmZpbmQobW91bnRVc2VySWQpICE9IG1TdGFydGVkVXNlcnMuZW5kKCkpIHsKKyAgICAgICAgaWYgKHByZXBhcmVTYW5kYm94ZXMobW91bnRVc2VySWQsIG1Vc2VyUGFja2FnZXNbbW91bnRVc2VySWRdLCB7dm9sLT5nZXRMYWJlbCgpfSkgIT0gMCkgeworICAgICAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gMDsKK30KKworaW50IFZvbHVtZU1hbmFnZXI6Om9uVm9sdW1lVW5tb3VudGVkKGFuZHJvaWQ6OnZvbGQ6OlZvbHVtZUJhc2UqIHZvbCkgeworICAgIGlmICghaGFzSXNvbGF0ZWRTdG9yYWdlKCkpIHsKKyAgICAg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2FnZU5hbWUgZm9yICIgPDwgdWlkOworICAgICAgICByZXR1cm4gLTE7CisgICAgfQorICAgIHJldHVybiBtb3VudFBrZ1NwZWNpZmljRGlyc0ZvclJ1bm5pbmdQcm9jcyh1c2VySWQsIHBhY2thZ2VOYW1lcywgdmlzaWJsZVZvbExhYmVscywgbW91bnRNb2RlKTsKIH0KIAotaW50IFZvbHVtZU1hbmFnZXI6OnJlbW91bnRVaWQodWlkX3QgdWlkLCBjb25zdCBzdGQ6OnN0cmluZyYgbW9kZSkgeworaW50IFZvbHVtZU1hbmFnZXI6OnJlbW91bnRVaWRMZWdhY3kodWlkX3QgdWlkLCBpbnQzMl90IG1vdW50TW9kZSkgeworICAgIHN0ZDo6c3RyaW5nIG1vZGU7CisgICAgc3dpdGNoIChtb3VudE1vZGUpIHsKKyAgICAgICAgY2FzZSBWb2xkTmF0aXZlU2VydmljZTo6UkVNT1VOVF9NT0RFX05PTkU6CisgICAgICAgICAgICBtb2RlID0gIm5vbmUiOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgVm9sZE5hdGl2ZVNlcnZpY2U6OlJFTU9VTlRfTU9ERV9ERUZBVUxUOgorICAgICAgICAgICAgbW9kZSA9ICJkZWZhdWx0IjsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFZvbGROYXRpdmVTZXJ2aWNlOjpSRU1PVU5UX01PREVfUkVBRDoKKyAgICAgICAgICAgIG1vZGUgPSAicmVhZCI7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBWb2xkTmF0aXZlU2VydmljZTo6UkVNT1VOVF9NT0RFX1dSSVRFOgorICAgICAgICAgICAgbW9kZSA9ICJ3cml0ZSI7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJVbmtub3duIG1vZGUgIiA8PCBzdGQ6OnRvX3N0cmluZyhtb3VudE1vZGUpOworICAgICAgICAgIC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UMKKyAgICAgICAgLy8gTk9MSU5UTkVYVExJTkUoYW5kcm9pZC1jbG9leGVjLW9wZW4pOiBEZWxpYmVyYXRlbHkgbm90IE9fQ0xPRVhFQworICAgICAgICBuc0ZkID0gb3BlbmF0KHBpZEZkLCAibnMvbW50IiwgT19SRE9OTFkpOwogICAgICAgICBpZiAobnNGZCA8IDApIHsKICAgICAgICAgICAgIFBMT0coV0FSTklORykgPDwgIkZhaWxlZCB0byBvcGVuIG5hbWVzcGFjZSBmb3IgIiA8PCBkZS0+ZF9uYW1lOwogICAgICAgICAgICAgZ290byBuZXh0OwpAQCAtNTA5LDcgKzExOTUsNyBAQAogICAgICAgICAgICAgICAgIF9leGl0KDEpOwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICB1bm1vdW50X3RyZWUoIi9zdG9yYWdlLyIpOworICAgICAgICAgICAgYW5kcm9pZDo6dm9sZDo6VW5tb3VudFRyZWUoIi9zdG9yYWdlLyIpOwogCiAgICAgICAgICAgICBzdGQ6OnN0cmluZyBzdG9yYWdlU291cmNlOwogICAgICAgICAgICAgaWYgKG1vZGUgPT0gImRlZmF1bHQiKSB7CkBAIC01MjIsMjYgKzEyMDgsMjIgQEAKICAgICAgICAgICAgICAgICAvLyBTYW5lIGRlZmF1bHQgb2Ygbm8gc3RvcmFnZSB2aXNpYmxlCiAgICAgICAgICAgICAgICAgX2V4aXQoMCk7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBpZiAoVEVNUF9GQUlMVVJFX1JFVFJZKG1vdW50KHN0b3JhZ2VTb3VyY2UuY19zdHIoKSwgIi9zdG9yYWdlIiwKLSAgICAgICAgICAgICAgICAgICAgTlVMTCwgTVNfQklORCB8IE1TX1JFQywgTlVMTCkpID09IC0xKSB7Ci0gICAgICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBtb3VudCAiIDw8IHN0b3JhZ2VTb3VyY2UgPDwgIiBmb3IgIgotICAgICAgICAgICAgICAgICAgICAgICAgPDwgZGUtPmRfbmFtZTsKKyAgICAgICAgICAgIGlmIChURU1QX0ZBSUxVUkVfUkVUUlkoCisgICAgICAgICAgICAgICAgICAgIG1vdW50KHN0b3JhZ2VTb3VyY2UuY19zdHIoKSwgIi9zdG9yYWdlIiwgTlVMTCwgTVNfQklORCB8IE1TX1JFQywgTlVMTCkpID09IC0xKSB7CisgICAgICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBtb3VudCAiIDw8IHN0b3JhZ2VTb3VyY2UgPDwgIiBmb3IgIiA8PCBkZS0+ZF9uYW1lOwogICAgICAgICAgICAgICAgIF9leGl0KDEpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKFRFTVBfRkFJTFVSRV9SRVRSWShtb3VudChOVUxMLCAiL3N0b3JhZ2UiLCBOVUxMLAotICAgICAgICAgICAgICAgICAgICBNU19SRUMgfCBNU19TTEFWRSwgTlVMTCkpID09IC0xKSB7Ci0gICAgICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBzZXQgTVNfU0xBVkUgdG8gL3N0b3JhZ2UgZm9yICIKLSAgICAgICAgICAgICAgICAgICAgICAgIDw8IGRlLT5kX25hbWU7CisgICAgICAgICAgICBpZiAoVEVNUF9GQUlMVVJFX1JFVFJZKG1vdW50KE5VTEwsICIvc3RvcmFnZSIsIE5VTEwsIE1TX1JFQyB8IE1TX1NMQVZFLCBOVUxMKSkgPT0gLTEpIHsKKyAgICAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIHNldCBNU19TTEFWRSB0byAvc3RvcmFnZSBmb3IgIiA8PCBkZS0+ZF9uYW1lOwogICAgICAgICAgICAgICAgIF9leGl0KDEpOwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAvLyBNb3VudCB1c2VyLXNwZWNpZmljIHN5bWxpbmsgaGVscGVyIGludG8gcGxhY2UKICAgICAgICAgICAgIHVzZXJpZF90IHVzZXJfaWQ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Ryb2lkOjpiYXNlOjpTdHJpbmdQcmludGYoCi0gICAgICAgICAgICAiZmQ9JWksIgotICAgICAgICAgICAgInJvb3Rtb2RlPTQwMDAwLCIKLSAgICAgICAgICAgICJkZWZhdWx0X3Blcm1pc3Npb25zLCIKLSAgICAgICAgICAgICJhbGxvd19vdGhlciwiCi0gICAgICAgICAgICAidXNlcl9pZD0lZCxncm91cF9pZD0lZCwiCi0gICAgICAgICAgICAiY29udGV4dD1cInU6b2JqZWN0X3I6YXBwX2Z1c2VfZmlsZTpzMFwiLCIKLSAgICAgICAgICAgICJmc2NvbnRleHQ9dTpvYmplY3RfcjphcHBfZnVzZWZzOnMwIiwKLSAgICAgICAgICAgIGRldmljZV9mZCwKLSAgICAgICAgICAgIHVpZCwKLSAgICAgICAgICAgIHVpZCk7Ci0KLSAgICBjb25zdCBpbnQgcmVzdWx0ID0gVEVNUF9GQUlMVVJFX1JFVFJZKG1vdW50KAotICAgICAgICAgICAgIi9kZXYvZnVzZSIsIHBhdGguY19zdHIoKSwgImZ1c2UiLAotICAgICAgICAgICAgTVNfTk9TVUlEIHwgTVNfTk9ERVYgfCBNU19OT0VYRUMgfCBNU19OT0FUSU1FLCBvcHRzLmNfc3RyKCkpKTsKLSAgICBpZiAocmVzdWx0ICE9IDApIHsKLSAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBtb3VudCAiIDw8IHBhdGg7Ci0gICAgICAgIHJldHVybiAtZXJybm87Ci0gICAgfQotCi0gICAgcmV0dXJuIGFuZHJvaWQ6Ok9LOwotfQotCi1zdGF0aWMgYW5kcm9pZDo6c3RhdHVzX3QgcnVuQ29tbWFuZEluTmFtZXNwYWNlKGNvbnN0IHN0ZDo6c3RyaW5nJiBjb21tYW5kLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aWRfdCB1aWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpZF90IHBp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ci0gICAgICAgICAgICByZXR1cm4gLUVQRVJNOwotICAgICAgICB9Ci0gICAgICAgIGlmIChyb290TmFtZSA9PSBwaWROYW1lKSB7Ci0gICAgICAgICAgICBMT0coRVJST1IpIDw8ICJEb24ndCBtb3VudCBhcHBmdXNlIGluIHJvb3QgbmFtZXNwYWNlIjsKLSAgICAgICAgICAgIHJldHVybiAtRVBFUk07Ci0gICAgICAgIH0KLSAgICB9Ci0KLSAgICAvLyBXZSBwdXJwb3NlZnVsbHkgbGVhdmUgdGhlIG5hbWVzcGFjZSBvcGVuIGFjcm9zcyB0aGUgZm9yawotICAgIHVuaXF1ZV9mZCBuc19mZChvcGVuYXQocGlkX2ZkLmdldCgpLCAibnMvbW50IiwgT19SRE9OTFkpKTsgLy8gbm90IE9fQ0xPRVhFQwotICAgIGlmIChuc19mZC5nZXQoKSA8IDApIHsKLSAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBvcGVuIG5hbWVzcGFjZSBmb3IgL3Byb2MvIiA8PCBwaWQgPDwgIi9ucy9tbnQiOwotICAgICAgICByZXR1cm4gLWVycm5vOwotICAgIH0KLQotICAgIGludCBjaGlsZCA9IGZvcmsoKTsKLSAgICBpZiAoY2hpbGQgPT0gMCkgewotICAgICAgICBpZiAoc2V0bnMobnNfZmQuZ2V0KCksIENMT05FX05FV05TKSAhPSAwKSB7Ci0gICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIHNldG5zIjsKLSAgICAgICAgICAgIF9leGl0KC1lcnJubyk7Ci0gICAgICAgIH0KLQotICAgICAgICBpZiAoY29tbWFuZCA9PSAibW91bnQiKSB7Ci0gICAgICAgICAgICBfZXhpdChtb3VudEluTmFtZXNwYWNlKHVpZCwgZGV2aWNlX2ZkLCBwYXRoKSk7Ci0gICAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PSAidW5tb3VudCIpIHsKLSAgICAgICAgICAgIC8vIElmIGl0J3MganVzdCBhZnRlciBhbGwgRkQgb3BlbmVkIG9uIG1vdW50IHBvaW50IGFyZSBjbG9zZWQsIHVtb3VudDIgY2FuIGZhaWwgd2l0aAotICAgICAgICAgICAgLy8gRUJVU1kuIFRvIGF2b2lkIHRoZSBjYXNlLCBzcGVjaWZ5IE1OVF9ERVRBQ0guCi0gICAgICAgICAgICBpZiAodW1vdW50MihwYXRoLmNfc3RyKCksIFVNT1VOVF9OT0ZPTExPVyB8IE1OVF9ERVRBQ0gpICE9IDAgJiYKLSAgICAgICAgICAgICAgICAgICAgZXJybm8gIT0gRUlOVkFMICYmIGVycm5vICE9IEVOT0VOVCkgewotICAgICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gdW5tb3VudCBkaXJlY3RvcnkuIjsKLSAgICAgICAgICAgICAgICBfZXhpdCgtZXJybm8pOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKHJtZGlyKHBhdGguY19zdHIoKSkgIT0gMCkgewotICAgICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gcmVtb3ZlIHRoZSBtb3VudCBkaXJlY3RvcnkuIjsKLSAgICAgICAgICAgICAgICBfZXhpdCgtZXJybm8pOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgX2V4aXQoYW5kcm9pZDo6T0spOwotICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiVW5rbm93biBhcHBmdXNlIGNvbW1hbmQgIiA8PCBjb21tYW5kOwotICAgICAgICAgICAgX2V4aXQoLUVQRVJNKTsKLSAgICAgICAgfQotICAgIH0KLQotICAgIGlmIChjaGlsZCA9PSAtMSkgewotICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIGZvbGsgY2hpbGQgcHJvY2VzcyI7Ci0gICAgICAgIHJldHVybiAtZXJybm87Ci0gICAgfQotCi0gICAgYW5kcm9pZDo6c3RhdHVzX3Qgc3RhdHVzOwotICAgIFRFTVBfRk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Q6OnZlY3RvcjxzdGQ6OnN0cmluZz4mIHZpc2libGVWb2xMYWJlbHMpOworICAgIGludCBoYW5kbGVNb3VudE1vZGVJbnN0YWxsZXIoaW50IG1vdW50TW9kZSwgaW50IG9iYk1vdW50RGlyRmQsIGNvbnN0IHN0ZDo6c3RyaW5nJiBvYmJNb3VudERpciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nJiBzYW5kYm94SWQpOworICAgIGludCBtb3VudFBrZ1NwZWNpZmljRGlyc0ZvclJ1bm5pbmdQcm9jcyh1c2VyaWRfdCB1c2VySWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiYgcGFja2FnZU5hbWVzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4mIHZpc2libGVWb2xMYWJlbHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCByZW1vdW50TW9kZSk7CisgICAgaW50IGRlc3Ryb3lTYW5kYm94ZXNGb3JWb2woYW5kcm9pZDo6dm9sZDo6Vm9sdW1lQmFzZSogdm9sLCB1c2VyaWRfdCB1c2VySWQpOworICAgIHN0ZDo6c3RyaW5nIHByZXBhcmVTdWJEaXJzKGNvbnN0IHN0ZDo6c3RyaW5nJiBwYXRoUHJlZml4LCBjb25zdCBzdGQ6OnN0cmluZyYgc3ViRGlycywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RlX3QgbW9kZSwgdWlkX3QgdWlkLCBnaWRfdCBnaWQpOworICAgIGJvb2wgY3JlYXRlUGtnU3BlY2lmaWNEaXJSb290cyhjb25zdCBzdGQ6OnN0cmluZyYgdm9sdW1lUm9vdCk7CisgICAgaW50IG1vdW50UGtnU3BlY2lm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xPQl9TSVpFKSB7CiAgICAgICAgICAgICBTTE9HRSgiS2V5bWFzdGVyIGtleSBibG9iIHRvbyBsYXJnZSIpOwpAQCAtMTQxLDEyICsxNTAsOSBAQAogfQogCiAvKiBUaGlzIHNpZ25zIHRoZSBnaXZlbiBvYmplY3QgdXNpbmcgdGhlIGtleW1hc3RlciBrZXkuICovCi1zdGF0aWMgaW50IGtleW1hc3Rlcl9zaWduX29iamVjdChzdHJ1Y3QgY3J5cHRfbW50X2Z0ciAqZnRyLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5zaWduZWQgY2hhciAqb2JqZWN0LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2l6ZV90IG9iamVjdF9zaXplLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqKnNpZ25hdHVyZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCAqc2lnbmF0dXJlX3NpemUpCi17CitzdGF0aWMgaW50IGtleW1hc3Rlcl9zaWduX29iamVjdChzdHJ1Y3QgY3J5cHRfbW50X2Z0ciogZnRyLCBjb25zdCB1bnNpZ25lZCBjaGFyKiBvYmplY3QsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplX3Qgb2JqZWN0X3NpemUsIHVuc2lnbmVkIGNoYXIqKiBzaWduYXR1cmUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QqIHNpZ25hdHVyZV9zaXplKSB7CiAgICAgdW5zaWduZWQgY2hhciB0b19zaWduW1JTQV9LRVlfU0laRV9CWVRFU107CiAgICAgc2l6ZV90IHRvX3NpZ25fc2l6ZSA9IHNpemVvZih0b19zaWduKTsKICAgICBtZW1zZXQodG9fc2lnbiwgMCwgUlNBX0tFWV9TSVpFX0JZVEVTKTsKQEAgLTIyNSwyMSArMjMxLDIwIEBACiBzdGF0aWMgaW50IHBhc3N3b3JkX2V4cGlyeV90aW1lID0gMDsKIHN0YXRpYyBjb25zdCBpbnQgcGFzc3dvcmRfbWF4X2FnZV9zZWNvbmRzID0gNjA7CiAKLWVudW0gY2xhc3MgUmVib290VHlwZSB7cmVib290LCByZWNvdmVyeSwgc2h1dGRvd259Owotc3RhdGljIHZvaWQgY3J5cHRmc19yZWJvb3QoUmVib290VHlwZSBydCkKLXsKLSAgc3dpdGNoIChydCkgewotICAgICAgY2FzZSBSZWJvb3RUeXBlOjpyZWJvb3Q6Ci0gICAgICAgICAgcHJvcGVydHlfc2V0KEFORFJPSURfUkJfUFJPUEVSVFksICJyZWJvb3QiKTsKLSAgICAgICAgICBicmVhazsKK2VudW0gY2xhc3MgUmVib290VHlwZSB7IHJlYm9vdCwgcmVjb3ZlcnksIHNodXRkb3duIH07CitzdGF0aWMgdm9pZCBjcnlwdGZzX3JlYm9vdChSZWJvb3RUeXBlIHJ0KSB7CisgICAgc3dpdGNoIChydCkgeworICAgICAgICBjYXNlIFJlYm9vdFR5cGU6OnJlYm9vdDoKKyAgICAgICAgICAgIHByb3BlcnR5X3NldChBTkRST0lEX1JCX1BST1BFUlRZLCAicmVib290Iik7CisgICAgICAgICAgICBicmVhazsKIAotICAgICAgY2FzZSBSZWJvb3RUeXBlOjpyZWNvdmVyeToKLSAgICAgICAgICBwcm9wZXJ0eV9zZXQoQU5EUk9JRF9SQl9QUk9QRVJUWSwgInJlYm9vdCxyZWNvdmVyeSIpOwotICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFJlYm9vdFR5cGU6OnJlY292ZXJ5OgorICAgICAgICAgICAgcHJvcGVydHlfc2V0KEFORFJPSURfUkJfUFJPUEVSVFksICJyZWJvb3QscmVjb3ZlcnkiKTsKKyAgICAgICAgICAgIGJyZWFrOwogCi0gICAgICBjYXNlIFJlYm9vdFR5cGU6OnNodXRkb3duOgotICAgICAgICAgIHByb3BlcnR5X3NldChBTkRST0lEX1JCX1BST1BFUlRZLCAic2h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J5LmZzX21ncl9mbGFncy5mb3JjZV9mZGVfb3JfZmJlIHx8IGVudHJ5LmZzX21ncl9mbGFncy5maWxlX2VuY3J5cHRpb24pKSB7CisgICAgICAgICAgICBpZiAoa2V5X2xvYyAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgKmtleV9sb2MgPSBlbnRyeS5rZXlfbG9jOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKHJlYWxfYmxrX2RldmljZSAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgKnJlYWxfYmxrX2RldmljZSA9IGVudHJ5LmJsa19kZXZpY2U7CisgICAgICAgICAgICB9CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KICAgICB9Ci0gIH0KK30KIAotICBpZiAoY2FjaGVkX2RhdGEpIHsKLSAgICBpZiAobWV0YWRhdGFfZm5hbWUpIHsKLSAgICAgICAgKm1ldGFkYXRhX2ZuYW1lID0gY2FjaGVkX21ldGFkYXRhX2ZuYW1lOwotICAgIH0KLSAgICBpZiAob2ZmKSB7Ci0gICAgICAgICpvZmYgPSBjYWNoZWRfb2ZmOwotICAgIH0KLSAgICByYyA9IDA7Ci0gIH0KK3N0YXRpYyBpbnQgZ2V0X2NyeXB0X2Z0cl9pbmZvKGNoYXIqKiBtZXRhZGF0YV9mbmFtZSwgb2ZmNjRfdCogb2ZmKSB7CisgICAgc3RhdGljIGludCBjYWNoZWRfZGF0YSA9IDA7CisgICAgc3RhdGljIHVpbnQ2NF90IGNhY2hlZF9vZmYgPSAwOworICAgIHN0YXRpYyBjaGFyIGNhY2hlZF9tZXRhZGF0YV9mbmFtZVtQUk9QRVJUWV9WQUxVRV9NQVhdID0gIiI7CisgICAgY2hhciBrZXlfbG9jW1BST1BFUlRZX1ZBTFVFX01BWF07CisgICAgY2hhciByZWFsX2Jsa2RldltQUk9QRVJUWV9WQUxVRV9NQVhdOworICAgIGludCByYyA9IC0xOwogCi0gIHJldHVybiByYzsKKyAgICBpZiAoIWNhY2hlZF9kYXRhKSB7CisgICAgICAgIHN0ZDo6c3RyaW5nIGtleV9sb2M7CisgICAgICAgIHN0ZDo6c3RyaW5nIHJlYWxfYmxrZGV2OworICAgICAgICBnZXRfY3J5cHRfaW5mbygma2V5X2xvYywgJnJlYWxfYmxrZGV2KTsKKworICAgICAgICBpZiAoa2V5X2xvYyA9PSBLRVlfSU5fRk9PVEVSKSB7CisgICAgICAgICAgICBpZiAoYW5kcm9pZDo6dm9sZDo6R2V0QmxvY2tEZXZTaXplKHJlYWxfYmxrZGV2LCAmY2FjaGVkX29mZikgPT0gYW5kcm9pZDo6T0spIHsKKyAgICAgICAgICAgICAgICAvKiBJZiBpdCdzIGFuIGVuY3J5cHRlZCBBbmRyb2lkIHBhcnRpdGlvbiwgdGhlIGxhc3QgMTYgS2J5dGVzIGNvbnRhaW4gdGhlCisgICAgICAgICAgICAgICAgICogZW5jcnlwdGlvbiBpbmZvIGZvb3RlciBhbmQga2V5LCBhbmQgcGxlbnR5IG9mIGJ5dGVzIHRvIHNwYXJlIGZvciBmdXR1cmUKKyAgICAgICAgICAgICAgICAgKiBncm93dGguCisgICAgICAgICAgICAgICAgICovCisgICAgICAgICAgICAgICAgc3RybGNweShjYWNoZWRfbWV0YWRhdGFfZm5hbWUsIHJlYWxfYmxrZGV2LmNfc3RyKCksIHNpemVvZihjYWNoZWRfbWV0YWRhdGFfZm5hbWUpKTsKKyAgICAgICAgICAgICAgICBjYWNoZWRfb2ZmIC09IENSWVBUX0ZPT1RFUl9PRkZTRVQ7CisgICAgICAgICAgICAgICAgY2FjaGVkX2RhdGEgPSAxOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBTTE9HRSgiQ2Fubm90IGdldCBzaXplIG9mIGJsb2NrIGRldmljZSAlc1xuIiwgcmVhbF9ibGtkZXYuY19zdHIoKSk7CisgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBzdHJsY3B5KGNhY2hlZF9tZX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AgICAgICAgdW5zaWduZWQgY2hhciAqaWtleSwgdm9pZCAqcGFyYW1zIFVOVVNFRCkKLXsKK3N0YXRpYyBpbnQgcGJrZGYyKGNvbnN0IGNoYXIqIHBhc3N3ZCwgY29uc3QgdW5zaWduZWQgY2hhciogc2FsdCwgdW5zaWduZWQgY2hhciogaWtleSwKKyAgICAgICAgICAgICAgICAgIHZvaWQqIHBhcmFtcyBVTlVTRUQpIHsKICAgICBTTE9HSSgiVXNpbmcgcGJrZGYyIGZvciBjcnlwdGZzIEtERiIpOwogCiAgICAgLyogVHVybiB0aGUgcGFzc3dvcmQgaW50byBhIGtleSBhbmQgSVYgdGhhdCBjYW4gZGVjcnlwdCB0aGUgbWFzdGVyIGtleSAqLwotICAgIHJldHVybiBQS0NTNV9QQktERjJfSE1BQ19TSEExKHBhc3N3ZCwgc3RybGVuKHBhc3N3ZCksIHNhbHQsIFNBTFRfTEVOLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEhBU0hfQ09VTlQsIElOVEVSTUVESUFURV9CVUZfU0laRSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpa2V5KSAhPSAxOworICAgIHJldHVybiBQS0NTNV9QQktERjJfSE1BQ19TSEExKHBhc3N3ZCwgc3RybGVuKHBhc3N3ZCksIHNhbHQsIFNBTFRfTEVOLCBIQVNIX0NPVU5ULAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIElOVEVSTUVESUFURV9CVUZfU0laRSwgaWtleSkgIT0gMTsKIH0KIAotc3RhdGljIGludCBzY3J5cHQoY29uc3QgY2hhciAqcGFzc3dkLCBjb25zdCB1bnNpZ25lZCBjaGFyICpzYWx0LAotICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqaWtleSwgdm9pZCAqcGFyYW1zKQoteworc3RhdGljIGludCBzY3J5cHQoY29uc3QgY2hhciogcGFzc3dkLCBjb25zdCB1bnNpZ25lZCBjaGFyKiBzYWx0LCB1bnNpZ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gorICAgICAgICAgICAgaWYgKGtleW1hc3Rlcl9jcmVhdGVfa2V5KGNyeXB0X2Z0cikpIHsKKyAgICAgICAgICAgICAgICBTTE9HRSgia2V5bWFzdGVyX2NyZWF0ZV9rZXkgZmFpbGVkIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgfQogCi0gICAgICAgIGlmIChzY3J5cHRfa2V5bWFzdGVyKHBhc3N3ZCwgc2FsdCwgaWtleSwgY3J5cHRfZnRyKSkgewotICAgICAgICAgICAgU0xPR0UoInNjcnlwdCBmYWlsZWQiKTsKLSAgICAgICAgICAgIHJldHVybiAtMTsKLSAgICAgICAgfQotICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGlmIChzY3J5cHRfa2V5bWFzdGVyKHBhc3N3ZCwgc2FsdCwgaWtleSwgY3J5cHRfZnRyKSkgeworICAgICAgICAgICAgICAgIFNMT0dFKCJzY3J5cHQgZmFpbGVkIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgfQorICAgICAgICAgICAgYnJlYWs7CiAKLSAgICBjYXNlIEtERl9TQ1JZUFQ6Ci0gICAgICAgIGlmIChzY3J5cHQocGFzc3dkLCBzYWx0LCBpa2V5LCBjcnlwdF9mdHIpKSB7Ci0gICAgICAgICAgICBTTE9HRSgic2NyeXB0IGZhaWxlZCIpOwotICAgICAgICAgICAgcmV0dXJuIC0xOwotICAgICAgICB9Ci0gICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIEtERl9TQ1JZUFQ6CisgICAgICAgICAgICBpZiAoc2NyeXB0KHBhc3N3ZCwgc2FsdCwgaWtleSwgY3J5cHRfZnRyKSkgeworICAgICAgICAgICAgICAgIFNMT0dFKCJzY3J5cHQgZmFpbGVkIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgfQorICAgICAgICAgICAgYnJlYWs7CiAKLSAgICBkZWZhdWx0OgotICAgICAgICBTTE9HRSgiSW52YWxpZCBrZGZfdHlwZSIpOwotICAgICAgICByZXR1cm4gLTE7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBTTE9HRSgiSW52YWxpZCBrZGZfdHlwZSIpOworICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgIH0KIAogICAgIC8qIEluaXRpYWxpemUgdGhlIGRlY3J5cHRpb24gZW5naW5lICovCiAgICAgRVZQX0NJUEhFUl9DVFhfaW5pdCgmZV9jdHgpOwotICAgIGlmICghIEVWUF9FbmNyeXB0SW5pdF9leCgmZV9jdHgsIEVWUF9hZXNfMTI4X2NiYygpLCBOVUxMLCBpa2V5LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpa2V5K0lOVEVSTUVESUFURV9LRVlfTEVOX0JZVEVTKSkgeworICAgIGlmICghRVZQX0VuY3J5cHRJbml0X2V4KCZlX2N0eCwgRVZQX2Flc18xMjhfY2JjKCksIE5VTEwsIGlrZXksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWtleSArIElOVEVSTUVESUFURV9LRVlfTEVOX0JZVEVTKSkgewogICAgICAgICBTTE9HRSgiRVZQX0VuY3J5cHRJbml0IGZhaWxlZFxuIik7CiAgICAgICAgIHJldHVybiAtMTsKICAgICB9CiAgICAgRVZQX0NJUEhFUl9DVFhfc2V0X3BhZGRpbmcoJmVfY3R4LCAwKTsgLyogVHVybiBvZmYgcGFkZGluZyBhcyBvdXIgZGF0YSBpcyBibG9jayBhbGlnbmVkICovCiAKICAgICAvKiBFbmNyeXB0IHRoZSBtYXN0ZXIga2V5ICovCi0gICAgaWYgKCEgRVZQX0VuY3J5cHRVcGRhdGUoJmVfY3R4LCBlbmNyeXB0ZWRfbWFzdGVyX2tleSwgJmVuY3J5cHRlZF9sZW4sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVjcnlwdGVkX21hc3Rlcl9rZXksIGNyeXB0X2Z0ci0+a2V5c2l6ZSkpIHsKKyAgICBpZiAoIUVWUF9FbmNyeXB0V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yAgICAvKiBEZWNyeXB0IHRoZSBtYXN0ZXIga2V5ICovCisgICAgaWYgKCFFVlBfRGVjcnlwdFVwZGF0ZSgmZF9jdHgsIGRlY3J5cHRlZF9tYXN0ZXJfa2V5LCAmZGVjcnlwdGVkX2xlbiwgZW5jcnlwdGVkX21hc3Rlcl9rZXksCisgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXlzaXplKSkgeworICAgICAgICByZXR1cm4gLTE7CisgICAgfQorICAgIGlmICghRVZQX0RlY3J5cHRGaW5hbF9leCgmZF9jdHgsIGRlY3J5cHRlZF9tYXN0ZXJfa2V5ICsgZGVjcnlwdGVkX2xlbiwgJmZpbmFsX2xlbikpIHsKKyAgICAgICAgcmV0dXJuIC0xOworICAgIH0KIAotICByZXR1cm4gMDsKKyAgICBpZiAoZGVjcnlwdGVkX2xlbiArIGZpbmFsX2xlbiAhPSBzdGF0aWNfY2FzdDxpbnQ+KGtleXNpemUpKSB7CisgICAgICAgIHJldHVybiAtMTsKKyAgICB9CisKKyAgICAvKiBDb3B5IGludGVybWVkaWF0ZSBrZXkgaWYgbmVlZGVkIGJ5IHBhcmFtcyAqLworICAgIGlmIChpbnRlcm1lZGlhdGVfa2V5ICYmIGludGVybWVkaWF0ZV9rZXlfc2l6ZSkgeworICAgICAgICAqaW50ZXJtZWRpYXRlX2tleSA9ICh1bnNpZ25lZCBjaGFyKiltYWxsb2MoSU5URVJNRURJQVRFX0tFWV9MRU5fQllURVMpOworICAgICAgICBpZiAoKmludGVybWVkaWF0ZV9rZXkpIHsKKyAgICAgICAgICAgIG1lbWNweSgqaW50ZXJtZWRpYXRlX2tleSwgaWtleSwgSU5URVJNRURJQVRFX0tFWV9MRU5fQllURVMpOworICAgICAgICAgICAgKmludGVybWVkaWF0ZV9rZXlfc2l6ZSA9IElOVEVSTUVESUFURV9LRVlfTEVOX0JZVEVTOworICAgICAgICB9CisgICAgfQorCisgICAgRVZQX0NJUEhFUl9DVFhfY2xlYW51cCgmZF9jdHgpOwor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gICAgICAgICAgICAgICAgICAgIHNpemVfdCogaW50ZXJtZWRpYXRlX2tleV9zaXplKSB7CiAgICAga2RmX2Z1bmMga2RmOwotICAgIHZvaWQgKmtkZl9wYXJhbXM7CisgICAgdm9pZCoga2RmX3BhcmFtczsKICAgICBpbnQgcmV0OwogCiAgICAgZ2V0X2tkZl9mdW5jKGNyeXB0X2Z0ciwgJmtkZiwgJmtkZl9wYXJhbXMpOwotICAgIHJldCA9IGRlY3J5cHRfbWFzdGVyX2tleV9hdXgocGFzc3dkLCBjcnlwdF9mdHItPnNhbHQsIGNyeXB0X2Z0ci0+bWFzdGVyX2tleSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyeXB0X2Z0ci0+a2V5c2l6ZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlY3J5cHRlZF9tYXN0ZXJfa2V5LCBrZGYsIGtkZl9wYXJhbXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm1lZGlhdGVfa2V5LCBpbnRlcm1lZGlhdGVfa2V5X3NpemUpOworICAgIHJldCA9IGRlY3J5cHRfbWFzdGVyX2tleV9hdXgocGFzc3dkLCBjcnlwdF9mdHItPnNhbHQsIGNyeXB0X2Z0ci0+bWFzdGVyX2tleSwgY3J5cHRfZnRyLT5rZXlzaXplLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVjcnlwdGVkX21hc3Rlcl9rZXksIGtkZiwga2RmX3BhcmFtcywgaW50ZXJtZWRpYXRlX2tleSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVybWVkaWF0ZV9rZXlfc2l6ZSk7CiAgICAgaWYgKHJldCAhPSAwKSB7CiAgICAgICAgIFNMT0dXKCJmYWlsdXJlIGRlY3J5cHRpbmcgbWFzdGVyIGtleSIpOwogICAgIH0KQEAgLTE0MTcsMjggKzE0NDAsMjggQEAKICAgICByZXR1cm4gcmV0OwogfQogCi1zdGF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lzIG1vdW50ZWQgYnkKICAgICAgICAgICogcmVjb3ZlcnkgbW9kZS4KQEAgLTE1OTcsOCArMTYxNCwxMCBAQAogICAgICAgICBjaGFyIHJvX3Byb3BbUFJPUEVSVFlfVkFMVUVfTUFYXTsKICAgICAgICAgcHJvcGVydHlfZ2V0KCJyby5jcnlwdG8ucmVhZG9ubHkiLCByb19wcm9wLCAiIik7CiAgICAgICAgIGlmIChzdHJsZW4ocm9fcHJvcCkgPiAwICYmIHN0ZDo6c3RvaShyb19wcm9wKSkgewotICAgICAgICAgICAgc3RydWN0IGZzdGFiX3JlYyogcmVjID0gZnNfbWdyX2dldF9lbnRyeV9mb3JfbW91bnRfcG9pbnQoZnN0YWJfZGVmYXVsdCwgREFUQV9NTlRfUE9JTlQpOwotICAgICAgICAgICAgcmVjLT5mbGFncyB8PSBNU19SRE9OTFk7CisgICAgICAgICAgICBhdXRvIGVudHJ5ID0gR2V0RW50cnlGb3JNb3VudFBvaW50KCZmc3RhYl9kZWZhdWx0LCBEQVRBX01OVF9QT0lOVCk7CisgICAgICAgICAgICBpZiAoZW50cnkgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgIGVudHJ5LT5mbGFncyB8PSBNU19SRE9OTFk7CisgICAgICAgICAgICB9CiAgICAgICAgIH0KIAogICAgICAgICAvKiBJZiB0aGF0IHN1Y2NlZWRlZCwgdGhlbiBtb3VudCB0aGUgZGVjcnlwdGVkIGZpbGVzeXN0ZW0gKi8KQEAgLTE2MDksMTkgKzE2MjgsMTggQEAKICAgICAgICAgICogZnNfbWdyX2RvX21vdW50IHJ1bnMgZnNjay4gVXNlIHNldGV4ZWNjb24gdG8gcnVuIHRydXN0ZWQKICAgICAgICAgICogcGFydGl0aW9ucyBpbiB0aGUgZnNjayBkb21haW4uCiAgICAgICAgICAqLwotICAgICAgICBpZiAoc2V0ZXhlY2NvbihzZWNvbnRleHRGc2NrKCkpKXsKKyAgICAgICAgaWYgKHNldGV4ZWNjb24oYW5kcm9pZDo6dm9sZDo6c0ZzY2tDb250ZXh0KSkgewogICAgICAgICAgICAgU0xPR0UoIkZhaWxlZCB0byBzZXRleGVjY29uIik7CiAgICAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgIH0KLSAgICAgICAgd2hpbGUgKChtb3VudF9yYyA9IGZzX21ncl9kb19tb3VudChmc3RhYl9kZWZhdWx0LCBEQVRBX01OVF9QT0lOVCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcnlwdG9fYmxrZGV2LCAwKSkKLSAgICAgICAgICAgICAgICE9IDApIHsKKyAgICAgICAgYm9vbCBuZWVkc19jcCA9IGFuZHJvaWQ6OnZvbGQ6OmNwX25lZWRzQ2hlY2twb2ludCgpOworICAgICAgICB3aGlsZSAoKG1vdW50X3JjID0gZnNfbWdyX2RvX21vdW50KCZmc3RhYl9kZWZhdWx0LCBEQVRBX01OVF9QT0lOVCwgY3J5cHRvX2Jsa2RldiwgMCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWVkc19jcCkpICE9IDApIHsKICAgICAgICAgICAgIGlmIChtb3VudF9yYyA9PSBGU19NR1JfRE9NTlRfQlVTWSkgewogICAgICAgICAgICAgICAgIC8qIFRPRE86IGludm9rZSBzb21ldGhpbmcgc2ltaWxhciB0bwogICAgICAgICAgICAgICAgICAgIFByb2Nlc3M6OmtpbGxQcm9jZXNzV2l0aE9wZW5GaWxlcyhEQVRBX01OVF9QT0lOVCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0cmllcyA+IFJFVFJZX01PVU5UX0FUVEVNUFQvMiA/IDEgOiAyICkgKi8KLSAgICAgICAgICAgICAgICBTTE9HSSgiRmFpbGVkIHRvIG1vdW50ICVzIGJlY2F1c2UgaXQgaXMgYnVzeSAtIHdhaXRpbmciLAotICAgICAgICAgICAgICAgICAgICAgIGNyeXB0b19ibGtkZXYpOworICAgICAgICAgICAgICAgIFNMT0dJ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m9yZQotICAgICAgICAvLyBwcm9jZWVkaW5nIQotICAgICAgICBpZiAocmMpIHsKLSAgICAgICAgICBTTE9HVygiVXBncmFkZSBmYWlsZWQgd2l0aCBlcnJvciAlZCwiCi0gICAgICAgICAgICAgICAgIiBidXQgY29udGludWluZyB3aXRoIHByZXZpb3VzIHN0YXRlIiwKLSAgICAgICAgICAgICAgICByYyk7Ci0gICAgICAgICAgcmMgPSAwOworICAgICAgICAgICAgcmMgPSArK2NyeXB0X2Z0ci0+ZmFpbGVkX2RlY3J5cHRfY291bnQ7CisgICAgICAgICAgICBwdXRfY3J5cHRfZnRyX2FuZF9rZXkoY3J5cHRfZnRyKTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIC8qIFN1Y2Nlc3MhICovCisgICAgICAgICAgICBTTE9HSSgiUGFzc3dvcmQgZGlkIG5vdCBtYXRjaCBidXQgZGVjcnlwdGVkIGRyaXZlIG1vdW50ZWQgLSBjb250aW51ZSIpOworICAgICAgICAgICAgdW1vdW50KHRtcF9tb3VudF9wb2ludCk7CisgICAgICAgICAgICByYyA9IDA7CiAgICAgICAgIH0KICAgICB9Ci0gIH0KIAotIGVycm91dDoKLSAgaWYgKGludGVybWVkaWF0ZV9rZXkpIHsKLSAgICBtZW1zZXQoaW50ZXJtZWRpYXRlX2tleSwgMCwgaW50ZXJtZWRpYXRlX2tleV9zaXplKTsKLSAgICBmcmVlKGludGVybWVkaWF0ZV9rZXkpOwotICB9Ci0gIHJldHVybiByYzsKKyAgICBpZiAocmMgPT0gMCkgeworICAgICAgICBjcnlwdF9mdHItPmZhaWxlZF9kZWNyeXB0X2NvdW50ID0gMDsKKyAgICAgICAgaWYgKG9yaWdfZmFpbGVkX2RlY3J5cHRfY291bnQgIT0gMCkgeworICAgICAgICAgICAgcHV0X2NyeXB0X2Z0cl9hbmRfa2V5KGNyeXB0X2Z0cik7CisgICAgICAgIH0KKworICAgICAgICAvKiBTYXZlIHRoZSBuYW1lIG9mIHRoZSBj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AgICAgICAgY3J5cHRfZnRyLT5rZGZfdHlwZSA9IEtERl9TQ1JZUFRfS0VZTUFTVEVSOworICAgICAgICAgICAgdXBncmFkZSA9IDE7CisgICAgICAgIH0gZWxzZSBpZiAodXNlX2tleW1hc3RlciA9PSAwICYmIGNyeXB0X2Z0ci0+a2RmX3R5cGUgIT0gS0RGX1NDUllQVCkgeworICAgICAgICAgICAgY3J5cHRfZnRyLT5rZGZfdHlwZSA9IEtERl9TQ1JZUFQ7CisgICAgICAgICAgICB1cGdyYWRlID0gMTsKKyAgICAgICAgfQorCisgICAgICAgIGlmICh1cGdyYWRlKSB7CisgICAgICAgICAgICByYyA9IGVuY3J5cHRfbWFzdGVyX2tleShwYXNzd2QsIGNyeXB0X2Z0ci0+c2FsdCwgc2F2ZWRfbWFzdGVyX2tleSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyeXB0X2Z0ci0+bWFzdGVyX2tleSwgY3J5cHRfZnRyKTsKKyAgICAgICAgICAgIGlmICghcmMpIHsKKyAgICAgICAgICAgICAgICByYyA9IHB1dF9jcnlwdF9mdHJfYW5kX2tleShjcnlwdF9mdHIpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgU0xPR0QoIktleSBEZXJpdmF0aW9uIEZ1bmN0aW9uIHVwZ3JhZGU6IHJjPSVkXG4iLCByYyk7CisKKyAgICAgICAgICAgIC8vIERvIG5vdCBmYWlsIGV2ZW4gaWYgdXBncmFkZSBmYWlsZWQgLSBtYWNoaW5lIGlzIGJvb3RhYmxlCisgICAgICAgICAgICAvLyBOb3RlIHRoYXQgaWYgdGhpcyBjb2RlIGlzIGV2ZXIgaGl0LCB0aGVyZSBpcyBhICpzZXJpb3VzKiBwcm9ibGVtCisgICAgICAgICAgICAvLyBzaW5jZSBLREZzIHNob3VsZCBuZXZlciBmYWlsLiBZb3UgKm11c3QqIGZpeCB0aGUga2RmIGJlZm9yZQorICAgICAgICAgICAgLy8gcHJvY2VlZGluZyEKKyAgICAgICAgICAgIGlmIChyYykgeworICAgICAgICAgICAgICAgIFNMT0dXKAorICAgICAgICAgICAgICAgICAgICAiVXBncmFkZSBmYWlsZWQgd2l0aCBlcnJvciAlZCwiCisgICAgICAgICAgICAgICAgICAgICIgYnV0IGNvbnRpbnVpbmcgd2l0aCBwcmV2aW91cyBzdGF0ZSIsCisgICAgICAgICAgICAgICAgICAgIHJjKTsKKyAgICAgICAgICAgICAgICByYyA9IDA7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisKK2Vycm91dDoKKyAgICBpZiAoaW50ZXJtZWRpYXRlX2tleSkgeworICAgICAgICBtZW1zZXQoaW50ZXJtZWRpYXRlX2tleSwgMCwgaW50ZXJtZWRpYXRlX2tleV9zaXplKTsKKyAgICAgICAgZnJlZShpbnRlcm1lZGlhdGVfa2V5KTsKKyAgICB9CisgICAgcmV0dXJuIHJjOwogfQogCiAvKgpAQCAtMTg3MywxOSArMTg4NiwxMCBAQAogICoKICAqIG91dF9jcnlwdG9fYmxrZGV2IG11c3QgYmUgTUFYUEFUSExFTi4KICAqLwotaW50IGNyeXB0ZnNfc2V0dXBfZXh0X3ZvbHVtZShjb25zdCBjaGFyKiBsYWJlbCwgY29uc3QgY2hhciogcmVhbF9ibGtkZXYsCi0gICAgICAgIGNvbnN0IHVuc2lnbmVkIGNoYXIqIGtleSwgY2hhciogb3V0X2NyeXB0b19ibGtkZXYpIHsKLSAgICBpbnQgZmQgPSBvcGVuKHJlYWxfYmxrZGV2LCBPX1JET05MWXxPX0NMT0VYRUMpOwotICAgIGlmIChmZCA9PSAtMSkgewotICAgICAgICBTTE9HRSgiRmFpbGVkIHRvIG9wZW4gJXM6ICVzIiwgcmVhbF9ibGtkZXYsIHN0cmVycm9yKGVycm5vKSk7Ci0gICAgICAgIHJldHVybiAtMTsKLSAgICB9Ci0KLSAgICB1bnNpZ25lZCBsb25nIG5yX3NlYyA9IDA7Ci0gICAgZ2V0X2Jsa2Rldl9zaXplKGZkLCAmbn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Jsa2RldiwgcmVhbF9ibGtkZXYuZGF0YSgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZpb3VzbHlfZW5jcnlwdGVkX3VwdG8pOwogICAgIH0KIAogICAgIC8qIENhbGN1bGF0ZSBjaGVja3N1bSBpZiB3ZSBhcmUgbm90IGZpbmlzaGVkICovCiAgICAgaWYgKCFyYyAmJiBjcnlwdF9mdHIuZW5jcnlwdGVkX3VwdG8gIT0gY3J5cHRfZnRyLmZzX3NpemUpIHsKLSAgICAgICAgcmMgPSBjcnlwdGZzX1NIQTI1Nl9maWxlYmxvY2soY3J5cHRvX2Jsa2RldiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3J5cHRfZnRyLmhhc2hfZmlyc3RfYmxvY2spOworICAgICAgICByYyA9IGNyeXB0ZnNfU0hBMjU2X2ZpbGVibG9jayhjcnlwdG9fYmxrZGV2LCBjcnlwdF9mdHIuaGFzaF9maXJzdF9ibG9jayk7CiAgICAgICAgIGlmIChyYykgewogICAgICAgICAgICAgU0xPR0UoIkVycm9yIGNhbGN1bGF0aW5nIGNoZWNrc3VtIGZvciBjb250aW51aW5nIGVuY3J5cHRpb24iKTsKICAgICAgICAgICAgIHJjID0gLTE7CkBAIC0yMzk1LDcgKzIzODEsNyBAQAogICAgIC8qIFVuZG8gdGhlIGRtLWNyeXB0IG1hcHBpbmcgd2hldGhlciB3ZSBzdWNjZWVkIG9yIG5vdCAqLwogICAgIGRlbGV0ZV9jcnlwdG9fYmxrX2RldihDUllQVE9fQkxPQ0tfREVWSUNFKTsKIAotICAgIGlmICghIHJjKSB7CisgICAgaWYgKCFyYykgewogICAgICAgICAvKiBTdWNjZXNzICovCiAgICAgICAgIGNyeXB0X2Z0ci5mbGFncyAmPSB+Q1JZUFRfSU5DT05TSVNURU5UX1NUQVRFOwogCkBAIC0yNDQzLDggKzI0MjksNyBAQAogICAgICAgICAgICAgU0xPR0UoImVuY3J5cHRpb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cnlwdGZzX3JlYm9vdChSZWJvb3RUeXBlOjpyZWJvb3QpOwogCiAgICAgLyogc2hvdWxkbid0IGdldCBoZXJlICovCkBAIC0yNDk2LDkgKzI0ODMsOCBAQAogICAgIHJldHVybiBjcnlwdGZzX2VuYWJsZV9pbnRlcm5hbChDUllQVF9UWVBFX0RFRkFVTFQsIERFRkFVTFRfUEFTU1dPUkQsIG5vX3VpKTsKIH0KIAotaW50IGNyeXB0ZnNfY2hhbmdlcHcoaW50IGNyeXB0X3R5cGUsIGNvbnN0IGNoYXIgKm5ld3B3KQotewotICAgIGlmIChlNGNyeXB0X2lzX25hdGl2ZSgpKSB7CitpbnQgY3J5cHRmc19jaGFuZ2VwdyhpbnQgY3J5cHRfdHlwZSwgY29uc3QgY2hhciogbmV3cHcpIHsKKyAgICBpZiAoZnNjcnlwdF9pc19uYXRpdmUoKSkgewogICAgICAgICBTTE9HRSgiY3J5cHRmc19jaGFuZ2VwdyBub3QgdmFsaWQgZm9yIGZpbGUgZW5jcnlwdGlvbiIpOwogICAgICAgICByZXR1cm4gLTE7CiAgICAgfQpAQCAtMjUyNSwxMiArMjUxMSw4IEBACiAKICAgICBjcnlwdF9mdHIuY3J5cHRfdHlwZSA9IGNyeXB0X3R5cGU7CiAKLSAgICByYyA9IGVuY3J5cHRfbWFzdGVyX2tleShjcnlwdF90eXBlID09IENSWVBUX1RZUEVfREVGQVVMVCA/IERFRkFVTFRfUEFTU1dPUkQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBuZXdwdywKLSAgICAgICAgICAgICAgICAgICAgICAgY3J5cHRfZnRyLnNhbHQsCi0gICAgICAgICAgICAgICAgICAgICAgIHNhdmVkX21hc3Rlcl9rZXksCi0gICAgICAgICAgICAgICAgICAgICAgIGNyeXB0X2Z0ci5tYXN0ZXJfa2V5LAotICAgICAgICAgICAgICAgICAgICAgICAmY3J5cHRfZnRyKTsKKyAgICByYyA9IGVuY3J5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29vbiBhcyBpdCBiZWdpbnMgdG8gb3ZlcmZsb3cgdGhlCiAgICAgICAgICAgICAgICAgLy8gbWF4aW11bSBmaWVsZCBsZW5ndGguIEF0IHRoaXMgcG9pbnQgd2UgaGF2ZSBpbiBmYWN0IGZ1bGx5IHJlYWQgb3V0IHRoZSBvcmlnaW5hbAogICAgICAgICAgICAgICAgIC8vIHZhbHVlIGJlY2F1c2UgY3J5cHRmc19zZXRmaWVsZCB3b3VsZCBub3QgYWxsb3cgZmllbGRzIHdpdGggbG9uZ2VyIG5hbWVzIHRvIGJlCkBAIC0yNzQ2LDExICsyNzI0LDExIEBACiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZiAoIXBlcnNpc3RfZ2V0X2tleSh0ZW1wX2ZpZWxkLCB0ZW1wX3ZhbHVlKSkgewotICAgICAgICAgICAgICAgICAgaWYgKHN0cmxjYXQodmFsdWUsIHRlbXBfdmFsdWUsIGxlbikgPj0gKHVuc2lnbmVkKWxlbikgewotICAgICAgICAgICAgICAgICAgICAgIC8vIHZhbHVlIHRvbyBzbWFsbC4KLSAgICAgICAgICAgICAgICAgICAgICByYyA9IENSWVBUT19HRVRGSUVMRF9FUlJPUl9CVUZfVE9PX1NNQUxMOwotICAgICAgICAgICAgICAgICAgICAgIGdvdG8gb3V0OwotICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGlmIChzdHJsY2F0KHZhbHVlLCB0ZW1wX3ZhbHVlLCBsZW4pID49ICh1bnNpZ25lZClsZW4pIHsKKyAgICAgICAgICAgICAgICAgICAgLy8gdmFsdWUgdG9vIHNtYWxsLgorICAgICAgICAgICAgICAgICAgICByYyA9IENSWVBUT19HRVRGSUVMRF9FUlJPUl9CVUZfVE9PX1NNQUxMOworICAgICAgICAgICAgICAgICAgICBnb3RvIG91dDsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIC8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oZW4gc3RhcnRpbmcgZW5jcnlwdGlvbiwgY2xlYXIgd2hlbgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4aXQgY2xlYW5seSwgZWl0aGVyIHRocm91Z2ggc3VjY2VzcyBvcgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcnJlY3RseSBtYXJrZWQgcGFydGlhbCBlbmNyeXB0aW9uICovCi0jZGVmaW5lIENSWVBUX0RBVEFfQ09SUlVQVCAweDggLyogU2V0IHdoZW4gZW5jcnlwdGlvbiBpcyBmaW5lLCBidXQgdGhlCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kZXJseWluZyB2b2x1bWUgaXMgY29ycnVwdCAqLwotI2RlZmluZSBDUllQVF9GT1JDRV9FTkNSWVBUSU9OIDB4MTAgLyogU2V0IHdoZW4gaXQgaXMgdGltZSB0byBlbmNyeXB0IHRoaXMKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvbHVtZSBvbiBib290LiBFdmVyeXRoaW5nIGluIHRoaXMKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cnVjdHVyZSBpcyBzZXQgdXAgY29ycmVjdGx5IGFzCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aG91Z2ggZGV2aWNlIGlzIGVuY3J5cHRlZCBleGNlcHQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQgdGhlIG1hc3RlciBrZXkgaXMgZW5jcnlwdGVkIHdpdGggdGhlCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0IHBhc3N3b3JkLiAqLwotI2RlZmluZSBDUllQVF9GT1JDRV9DT01QTEVURSAweDIwIC8qIFNldCB3aGVuIHRoZSBhYm92ZSBlbmNyeXB0aW9uIGN5Y2xlIGlzCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcGxldGUuIE9uIG5leHQgY3J5cHRrZWVwZXIgZW50cnksIG1hdGNoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhlIHBhc3N3b3JkLiBJZiBpdCBtYXRjaGVzIGZpeCB0aGUgbWFzdGVyCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5IGFuZCByZW1vdmUgdGhpcyBmbGFnLiAqLworI2RlZmluZSBDUllQVF9FTkNSWVBUSU9OX0lOX1BST0dSRVNTICAgICAgIFwKKyAgICAweDIgLyogRW5jcnlwdGlvbiBwYXJ0aWFsbHkgY29tcGxldGVkLCBcCisgICAgICAgICAgIGVuY3J5cHRlZF91cHRvIHZhbGlkKi8KKyNkZWZpbmUgQ1JZUFRfSU5DT05TSVNURU5UX1NUQVRFICAgICAgICAgICAgICAgICAgICBcCisgICAgMHg0IC8qIFNldCB3aGVuIHN0YXJ0aW5nIGVuY3J5cHRpb24sIGNsZWFyIHdoZW4gXAorICAgICAgICAgICBleGl0IGNsZWFubHksIGVpdGhlciB0aHJvdWdoIHN1Y2Nlc3Mgb3IgIFwKKyAgICAgICAgICAgY29ycmVjdGx5IG1hcmtlZCBwYXJ0aWFsIGVuY3J5cHRpb24gKi8KKyNkZWZpbmUgQ1JZUFRfREFUQV9DT1JSVVBUICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAweDggLyogU2V0IHdoZW4gZW5jcnlwdGlvbiBpcyBmaW5lLCBidXQgdGhlIFwKKyAgICAgICAgICAgdW5kZXJseWluZyB2b2x1bWUgaXMgY29ycnVwdCAqLworI2RlZmluZSBDUllQVF9GT1JDRV9FTkNSWVBUSU9OICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIDB4MTAgLyogU2V0IHdoZW4gaXQgaXMgdGltZSB0byBlbmNyeXB0IHRoaXMgICAgICAgXAorICAgICAgICAgICAgdm9sdW1lIG9uIGJvb3QuIEV2ZXJ5dGhpbmcgaW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lZCBhdHRlbXB0cyB0byBkZWNyeXB0IGFuZAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vdW50LCBzZXQgdG8gMCBvbiBzdWNjZXNzZnVsIG1vdW50ICovCi0gIHVuc2lnbmVkIGNoYXIgY3J5cHRvX3R5cGVfbmFtZVtNQVhfQ1JZUFRPX1RZUEVfTkFNRV9MRU5dOyAvKiBUaGUgdHlwZSBvZiBlbmNyeXB0aW9uCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWVkZWQgdG8gZGVjcnlwdCB0aGlzCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0aXRpb24sIG51bGwgdGVybWluYXRlZCAqLwotICBfX2xlMzIgc3BhcmUyOyAgICAgICAgLyogaWdub3JlZCAqLwotICB1bnNpZ25lZCBjaGFyIG1hc3Rlcl9rZXlbTUFYX0tFWV9MRU5dOyAvKiBUaGUgZW5jcnlwdGVkIGtleSBmb3IgZGVjcnlwdGluZyB0aGUgZmlsZXN5c3RlbSAqLwotICB1bnNpZ25lZCBjaGFyIHNhbHRbU0FMVF9MRU5dOyAgIC8qIFRoZSBzYWx0IHVzZWQgZm9yIHRoaXMgZW5jcnlwdGlvbiAqLwotICBfX2xlNjQgcGVyc2lzdF9kYXRhX29mZnNldFsyXTsgIC8qIEFic29sdXRlIG9mZnNldCB0byBib3RoIGNvcGllcyBvZiBjcnlwdF9wZXJzaXN0X2RhdGEKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBvbiBkZXZpY2Ugd2l0aCB0aGF0IGluZm8sIGVpdGhlciB0aGUgZm9vdGVyIG9mIHRoZQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIHJlYWxfYmxrZGV2aWNlIG9yIHRoZSBtZXRhZGF0YSBwYXJ0aXRpb24uICovCisgICAgX19sZTMyIG1hZ2ljOyAvKiBTZWUgYWJvdmUgKi8KKyAgICBfX2xlMTYgbWFqb3JfdmVyc2lvbjsKKyAgICBfX2xlMTYgbWlub3JfdmVyc2lvbjsKKyAgICBfX2xlMzIgZnRyX3NpemU7ICAgICAgICAgICAgIC8qIGluIGJ5dGVzLCBub3QgaW5jbHVkaW5nIGtleSBmb2xsb3dpbmcgKi8KKyAgICBfX2xlMzIgZmxhZ3M7ICAgICAgICAgICAgICAgIC8qIFNlZSBhYm92ZSAqLworICAgIF9fbGUzMiBrZXlzaXplOyAgICAgICAgICAgICAgLyogaW4gYnl0ZXMgKi8KKyAgICBfX2xlMzIgY3J5cHRfdHlwZTsgICAgICAgICAgIC8qIGhvdyBtYXN0ZXJfa2V5IGlzIGVuY3J5cHRlZC4gTXVzdCBiZSBhCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBDUllQVF9UWVBFX1hYWCB2YWx1ZSAqLworICAgIF9fbGU2NCBmc19zaXplOyAgICAgICAgICAgICAgLyogU2l6ZSBvZiB0aGUgZW5jcnlwdGVkIGZzLCBpbiA1MTIgYnl0ZSBzZWN0b3JzICovCisgICAgX19sZTMyIGZhaWxlZF9kZWNyeXB0X2NvdW50OyAvKiBjb3VudCBvZiAjIG9mIGZhaWxlZCBhdHRlbXB0cyB0byBkZWNyeXB0IGFuZAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW91bnQsIHNldCB0byAwIG9uIHN1Y2Nlc3NmdWwgbW91bnQgKi8KKyAgICB1bnNpZ25lZCBjaGFyIGNyeXB0b190eXBlX25hbWVbTUFYX0NSWVBUT19UWVBFX05BTUVfTEVOXTsgLyogVGhlIHR5cGUgb2YgZW5jcnlwdGlvbgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWVkZWQgdG8gZGVjcnlwdCB0aGlzCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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HQgcGFyYW1ldGVycy4gU2VlIHd3dy50YXJzbmFwLmNvbS9zY3J5cHQvc2NyeXB0LnBkZiAqLworICAgIF9fbGU4IE5fZmFjdG9yOyAgICAgICAgLyogKDEgPDwgTikgKi8KKyAgICBfX2xlOCByX2ZhY3RvcjsgICAgICAgIC8qICgxIDw8IHIpICovCisgICAgX19sZTggcF9mYWN0b3I7ICAgICAgICAvKiAoMSA8PCBwKSAqLworICAgIF9fbGU2NCBlbmNyeXB0ZWRfdXB0bzsgLyogSWYgd2UgYXJlIGluIHN0YXRlIENSWVBUX0VOQ1JZUFRJT05fSU5fUFJPR1JFU1MgYW5kCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZSBoYXZlIHRvIHN0b3AgKGUuZy4gcG93ZXIgbG93KSB0aGlzIGlzIHRoZSBsYXN0CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmNyeXB0ZWQgNTEyIGJ5dGUgc2VjdG9yLiovCisgICAgX19sZTggaGFzaF9maXJzdF9ibG9ja1tTSEEyNTZfRElHRVNUX0xFTkdUSF07IC8qIFdoZW4gQ1JZUFRfRU5DUllQVElPTl9JTl9QUk9HUkVTUworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXQsIGhhc2ggb2YgZmlyc3QgYmxvY2ssIHVzZWQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG8gdmFsaWRhdGUgYmVmb3JlIGNvbnRpbnVpbmcqLwogCi0gIC8qIGtleV9tYXN0ZXIga2V5LCB1c2VkIHRvIHNpZ24gdGhlIGRlcml2ZWQga2V5IHdoaWNoIGlzIHRoZW4gdXNlZCB0byBnZW5lcmF0ZQotICAgKiB0aGUgaW50ZXJtZWRpYXRlIGtleQotICAgKiBUaGlzIGtleSBzaG91bGQgYmUgdXNlZCBmb3Igbm8gb3RoZXIgcHVycG9zZXMhIFdlIHVzZSB0aGlzIGtle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EVDIHwgTVNfTk9TVUlEOwotICAgIGNoYXIgKnRtcG1udF9vcHRzID0gKGNoYXIqKSAibm9tYmxrX2lvX3N1Ym1pdCxlcnJvcnM9cmVtb3VudC1ybyI7CisgICAgY2hhciogdG1wbW50X29wdHMgPSAoY2hhciopIm5vbWJsa19pb19zdWJtaXQsZXJyb3JzPXJlbW91bnQtcm8iOwogCiAgICAgLyoKICAgICAgKiBGaXJzdCB0cnkgdG8gbW91bnQgYW5kIHVubW91bnQgdGhlIGZpbGVzeXN0ZW0uICBXZSBkbyB0aGlzIGJlY2F1c2UKQEAgLTEwMiw3ICs5NSw4IEBACiAgICAgICAgICAgICBpZiAocmVzdWx0ID09IDApIHsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIEFMT0dXKCIlcygpOiB1bW91bnQoJXMpPSVkOiAlc1xuIiwgX19mdW5jX18sIGNfdGFyZ2V0LCByZXN1bHQsIHN0cmVycm9yKGVycm5vKSk7CisgICAgICAgICAgICBMT0coV0FSTklORykgPDwgX19mdW5jX18gPDwgIigpOiB1bW91bnQoIiA8PCBjX3RhcmdldCA8PCAiKT0iIDw8IHJlc3VsdCA8PCAiOiAiCisgICAgICAgICAgICAgICAgICAgICAgICAgPDwgc3RyZXJyb3IoZXJybm8pOwogICAgICAgICAgICAgc2xlZXAoMSk7CiAgICAgICAgIH0KICAgICB9CkBAIC0xMTIsMTAgKzEwNiwxMCBAQAogICAgICAqIChlLmcuIHJlY2VudCBTREsgc3lzdGVtIGltYWdlcykuIERldGVjdCB0aGVzZSBhbmQgc2tpcCB0aGUgY2hlY2suCiAgICAgICovCiAgICAgaWYgKGFjY2VzcyhrRnNja1BhdGgsIFhfT0spKSB7Ci0gICAgICAgIEFMT0dEKCJOb3QgcnVubmluZyAlcyBvbiAlcyAoZXhlY3V0YWJsZSBub3QgaW4gc3lzdGVtIGltYWdlKVxuIiwKLSAgICAgICAgICAgICAgICBrRnNja1BhdGgsIGNfc291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ICAgICAgICAgY21kLnB1c2hfYmFjayhzb3VyY2UpOwogCiAgICAgICAgIC8vIEZhdCBkZXZpY2VzIGFyZSBjdXJyZW50bHkgYWx3YXlzIHVudHJ1c3RlZAotICAgICAgICByYyA9IEZvcmtFeGVjdnAoY21kLCBzRnNja1VudHJ1c3RlZENvbnRleHQpOworICAgICAgICByYyA9IEZvcmtFeGVjdnAoY21kLCBudWxscHRyLCBzRnNja1VudHJ1c3RlZENvbnRleHQpOwogCiAgICAgICAgIGlmIChyYyA8IDApIHsKICAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkZpbGVzeXN0ZW0gY2hlY2sgZmFpbGVkIGR1ZSB0byBsb2d3cmFwIGVycm9yIjsKQEAgLTc5LDQzICs3NSw0MiBAQAogICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICB9CiAKLSAgICAgICAgc3dpdGNoKHJjKSB7Ci0gICAgICAgIGNhc2UgMDoKLSAgICAgICAgICAgIExPRyhJTkZPKSA8PCAiRmlsZXN5c3RlbSBjaGVjayBjb21wbGV0ZWQgT0siOwotICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgIHN3aXRjaCAocmMpIHsKKyAgICAgICAgICAgIGNhc2UgMDoKKyAgICAgICAgICAgICAgICBMT0coSU5GTykgPDwgIkZpbGVzeXN0ZW0gY2hlY2sgY29tcGxldGVkIE9LIjsKKyAgICAgICAgICAgICAgICByZXR1cm4gMDsKIAotICAgICAgICBjYXNlIDI6Ci0gICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGaWxlc3lzdGVtIGNoZWNrIGZhaWxlZCAobm90IGEgRkFUIGZpbGVzeXN0ZW0pIjsKLSAgICAgICAgICAgIGVycm5vID0gRU5PREFUQTsKLSAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAgICAgICAgIGNhc2UgMjoKKyAgICAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGaWxlc3lzdGVtIGNoZWNrIGZhaWxlZCAobm90IGEgRkFUIGZpbGVzeXN0ZW0pIjsKKyAgICAgICAgICAgICAgICBlcnJubyA9IEVOT0RBVEE7CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOwogCi0gICAgICAgIGNhc2UgNDoKLSAgICAgICAgICAgIGlmIChwYXNzKysgPD0gMykgewotICAgICAgICAgICAgICAgIExPRyhXQVJOSU5HKSA8PCAiRmlsZXN5c3RlbSBtb2RpZmllZCAtIHJlY2hlY2tpbmcgKHBhc3MgIiA8PCBwYXNzIDw8ICIpIjsKLSAgICAgICAgICAgICAgICBjb250aW51ZTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkZhaWxpbmcgY2hlY2sgYWZ0ZXIgdG9vIG1hbnkgcmVjaGVja3MiOwotICAgICAgICAgICAgZXJybm8gPSBFSU87Ci0gICAgICAgICAgICByZXR1cm4gLTE7CisgICAgICAgICAgICBjYXNlIDQ6CisgICAgICAgICAgICAgICAgaWYgKHBhc3MrKyA8PSAzKSB7CisgICAgICAgICAgICAgICAgICAgIExPRyhXQVJOSU5HKSA8PCAiRmlsZXN5c3RlbSBtb2RpZmllZCAtIHJlY2hlY2tpbmcgKHBhc3MgIiA8PCBwYXNzIDw8ICIpIjsKKyAgICAgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkZhaWxpbmcgY2hlY2sgYWZ0ZXIgdG9vIG1hbnkgcmVjaGVja3MiOworICAgICAgICAgICAgICAgIGVycm5vID0gRUlPOworICAgICAgICAgICAgICAgIHJldHVybiAtMTsKIAotICAgICAgICBjYXNlIDg6Ci0gICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGaWxlc3lzdGVtIGNoZWNrIGZhaWxlZCAobm8gZmlsZXN5c3RlbSkiOwotICAgICAgICAgICAgZXJybm8gPSBFTk9EQVRBOwotICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgY2FzZSA4OgorICAgICAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkZpbGVzeXN0ZW0gY2hlY2sgZmFpbGVkIChubyBmaWxlc3lzdGVtKSI7CisgICAgICAgICAgICAgICAgZXJybm8gPSBFTk9EQVRBOworICAgICAgICAgICAgICAgIHJldHVybiAtMTsKIAotICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiRmlsZXN5c3RlbSBjaGVjayBmYWlsZWQgKHVua25vd24gZXhpdCBjb2RlICIgPDwgcmMgPDwgIikiOwotICAgICAgICAgICAgZXJybm8gPSBFSU87Ci0gICAgICAgICAgICByZXR1cm4gLTE7CisgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkZpbGVzeXN0ZW0gY2hlY2sgZmFpbGVkICh1bmtub3duIGV4aXQgY29kZSAiIDw8IHJjIDw8ICIpIjsKKyAgICAgICAgICAgICAgICBlcnJubyA9IEVJTzsKKyAgICAgICAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgIH0KICAgICB9IHdoaWxlICgwKTsKIAogICAgIHJldHVybiAwOwogfQogCi1zdGF0dXNfdCBNb3VudChjb25zdCBzdGQ6OnN0cmluZyYgc291cmNlLCBjb25zdCBzdGQ6OnN0cmluZyYgdGFyZ2V0LCBib29sIHJvLAotICAgICAgICBib29sIHJlbW91bnQsIGJvb2wgZXhlY3V0YWJsZSwgaW50IG93bmVyVWlkLCBpbnQgb3duZXJHaWQsIGludCBwZXJtTWFzaywKLSAgICAgICAgYm9vbCBjcmVhdGVMb3N0KSB7CitzdGF0dXNfdCBNb3VudChjb25zdCBzdGQ6OnN0cmluZyYgc291cmNlLCBjb25zdCBzdGQ6OnN0cmluZyYgdGFyZ2V0LCBib29sIHJvLCBib29sIHJlbW91bnQsCisgICAgICAgICAgICAgICBib29sIGV4ZWN1dGFibGUsIGludCBvd25lclVpZCwgaW50IG93bmVyR2lkLCBpbnQgcGVybU1hc2ssIG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ZWRDb250ZXh0ID0gb3B0YXJnOyBicmVhazsKKyAgICAgICAgICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb24KICAgICAgICAgfQogICAgIH0KIApAQCAtMTY3LDMzICsxNzIsMzAgQEAKICAgICBDSEVDSyhhbmRyb2lkOjp2b2xkOjpzRnNja1VudHJ1c3RlZENvbnRleHQgIT0gbnVsbHB0cik7CiB9CiAKLXN0YXRpYyB2b2lkIGRvX2NvbGRib290KERJUiAqZCwgaW50IGx2bCkgewotICAgIHN0cnVjdCBkaXJlbnQgKmRlOworc3RhdGljIHZvaWQgZG9fY29sZGJvb3QoRElSKiBkLCBpbnQgbHZsKSB7CisgICAgc3RydWN0IGRpcmVudCogZGU7CiAgICAgaW50IGRmZCwgZmQ7CiAKICAgICBkZmQgPSBkaXJmZChkKTsKIAogICAgIGZkID0gb3BlbmF0KGRmZCwgInVldmVudCIsIE9fV1JPTkxZIHwgT19DTE9FWEVDKTsKLSAgICBpZihmZCA+PSAwKSB7CisgICAgaWYgKGZkID49IDApIHsKICAgICAgICAgd3JpdGUoZmQsICJhZGRcbiIsIDQpOwogICAgICAgICBjbG9zZShmZCk7CiAgICAgfQogCi0gICAgd2hpbGUoKGRlID0gcmVhZGRpcihkKSkpIHsKLSAgICAgICAgRElSICpkMjsKKyAgICB3aGlsZSAoKGRlID0gcmVhZGRpcihkKSkpIHsKKyAgICAgICAgRElSKiBkMjsKIAotICAgICAgICBpZiAoZGUtPmRfbmFtZVswXSA9PSAnLicpCi0gICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgaWYgKGRlLT5kX25hbWVbMF0gPT0gJy4nKSBjb250aW51ZTsKIAotICAgICAgICBpZiAoZGUtPmRfdHlwZSAhPSBEVF9ESVIgJiYgbHZsID4gMCkKLSAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICBpZiAoZGUtPmRfdHlwZSAhPSBEVF9ESVIgJiYgbHZsID4gMCkgY29udGludWU7CiAKICAgICAgICAgZmQgPSBvcGVuYXQoZGZkLCBkZS0+ZF9uYW1lLCBPX1JET05MWSB8IE9fRElSRUNUT1JZIHwgT19DTE9FWEVDKTsKLSAgICAgICAgaWYoZmQgPCAwKQotICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIGlmIChmZCA8IDApIGNvbnRpbnVlOwogCiAgICAgICAgIGQyID0gZmRvcGVuZGlyKGZkKTsKLSAgICAgICAgaWYoZDIgPT0gMCkKKyAgICAgICAgaWYgKGQyID09IDApCiAgICAgICAgICAgICBjbG9zZShmZCk7CiAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgZG9fY29sZGJvb3QoZDIsIGx2bCArIDEpOwpAQCAtMjAyLDEwICsyMDQsMTAgQEAKICAgICB9CiB9CiAKLXN0YXRpYyB2b2lkIGNvbGRib290KGNvbnN0IGNoYXIgKnBhdGgpIHsKK3N0YXRpYyB2b2lkIGNvbGRib290KGNvbnN0IGNoYXIqIHBhdGgpIHsKICAgICBBVFJBQ0VfTkFNRSgiY29sZGJvb3QiKTsKLSAgICBESVIgKmQgPSBvcGVuZGlyKHBhdGgpOwotICAgIGlmKGQpIHsKKyAgICBESVIqIGQgPSBvcGVuZGlyKHBhdGgpOworICAgIGlmIChkKSB7CiAgICAgICAgIGRvX2NvbGRib290KGQsIDApOwogICAgICAgICBjbG9zZWRpcihkKTsKICAgICB9CkBAIC0yMTUsOCArMjE3LDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCogaGFzX3Jlc2VydmVkKSB7CiAgICAgQVRSQUNFX05BTUUoInByb2Nlc3NfY29uZmlnIik7CiAKLSAgICBmc3RhYl9kZWZhdWx0ID0gZnNfbWdyX3JlYWRfZnN0YWJfZGVmYXVsdCgpOwotICAgIGlmICghZnN0YWJfZGVmYXVsdCkgeworICAgIGlmICghUmVhZERlZmF1bHRGc3RhYigmZnN0YWJfZGVmYXVsdCkpIHsKICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBvcGVuIGRlZmF1bHQgZ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sIHBhcnRpdGlvbiAiIDw8IGVudHJ5LmJsa19kZXZpY2U7CisgICAgICAgIH0KKworICAgICAgICBpZiAoZW50cnkuZnNfbWdyX2ZsYWdzLnZvbGRfbWFuYWdlZCkgeworICAgICAgICAgICAgaWYgKGVudHJ5LmZzX21ncl9mbGFncy5ub25yZW1vdmFibGUpIHsKICAgICAgICAgICAgICAgICBMT0coV0FSTklORykgPDwgIm5vbnJlbW92YWJsZSBubyBsb25nZXIgc3VwcG9ydGVkOyBpZ25vcmluZyB2b2x1bWUiOwogICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBzdGQ6OnN0cmluZyBzeXNQYXR0ZXJuKHJlYy0+YmxrX2RldmljZSk7Ci0gICAgICAgICAgICBzdGQ6OnN0cmluZyBuaWNrbmFtZShyZWMtPmxhYmVsKTsKKyAgICAgICAgICAgIHN0ZDo6c3RyaW5nIHN5c1BhdHRlcm4oZW50cnkuYmxrX2RldmljZSk7CisgICAgICAgICAgICBzdGQ6OnN0cmluZyBuaWNrbmFtZShlbnRyeS5sYWJlbCk7CiAgICAgICAgICAgICBpbnQgZmxhZ3MgPSAwOwogCi0gICAgICAgICAgICBpZiAoZnNfbWdyX2lzX2VuY3J5cHRhYmxlKHJlYykpIHsKKyAgICAgICAgICAgIGlmIChlbnRyeS5pc19lbmNyeXB0YWJsZSgpKSB7CiAgICAgICAgICAgICAgICAgZmxhZ3MgfD0gYW5kcm9pZDo6dm9sZDo6RGlzazo6RmxhZ3M6OmtBZG9wdGFibGU7CiAgICAgICAgICAgICAgICAgKmhhc19hZG9wdGFibGUgPSB0cnVlOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKGZzX21ncl9pc19ub2VtdWxhdGVkc2QocmVjKQotICAgICAgICAgICAgICAgICAgICB8fCBhbmRyb2lkOjpiYXNlOjpHZXRCb29sUHJvcGVydHkoInZvbGQuZGVidWcuZGVmYXVsdF9wcmltYXJ5IiwgZmF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vY2tTY3NpRjoKKyAgICAgICAgY2FzZSBrTWFqb3JCbG9ja1Njc2lHOiBjYXNlIGtNYWpvckJsb2NrU2NzaUg6IGNhc2Uga01ham9yQmxvY2tTY3NpSToKKyAgICAgICAgY2FzZSBrTWFqb3JCbG9ja1Njc2lKOiBjYXNlIGtNYWpvckJsb2NrU2NzaUs6IGNhc2Uga01ham9yQmxvY2tTY3NpTDoKKyAgICAgICAgY2FzZSBrTWFqb3JCbG9ja1Njc2lNOiBjYXNlIGtNYWpvckJsb2NrU2NzaU46IGNhc2Uga01ham9yQmxvY2tTY3NpTzoKKyAgICAgICAgY2FzZSBrTWFqb3JCbG9ja1Njc2lQOiB7CisgICAgICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb24KKyAgICAgICAgICAgIHN0ZDo6c3RyaW5nIHBhdGgobVN5c1BhdGggKyAiL2RldmljZS92ZW5kb3IiKTsKKyAgICAgICAgICAgIHN0ZDo6c3RyaW5nIHRtcDsKKyAgICAgICAgICAgIGlmICghUmVhZEZpbGVUb1N0cmluZyhwYXRoLCAmdG1wKSkgeworICAgICAgICAgICAgICAgIFBMT0coV0FSTklORykgPDwgIkZhaWxlZCB0byByZWFkIHZlbmRvciBmcm9tICIgPDwgcGF0aDsKKyAgICAgICAgICAgICAgICByZXR1cm4gLWVycm5vOworICAgICAgICAgICAgfQorICAgICAgICAgICAgdG1wID0gYW5kcm9pZDo6YmFzZTo6VHJpbSh0bXApOworICAgICAgICAgICAgbUxhYmVsID0gdG1wOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBrTWFqb3JCbG9ja01tYzogeworICAgICAgICAgICAgc3RkOjpzdHJpbmcgcGF0aChtU3lzUGF0aCArICIvZGV2aWNlL21hbmZpZCIpOworICAgICAgICAgICAgc3RkOjpzdHJpbmcgdG1wOworICAgICAgICAgICAgaWYgKCFSZWFkRmlsZVRvU3RyaW5nKHBhdGgsICZ0bXApKSB7CisgICAgICAgICAgICAgICAgUExPRyhXQVJOSU5HKSA8PCAiRmFpbGVkIHRvIHJlYWQgbWFudWZhY3R1cmVyIGZyb20gIiA8PCBwYXRoOworICAgICAgICAgICAgICAgIHJldHVybiAtZXJybm87CisgICAgICAgICAgICB9CisgICAgICAgICAgICB0bXAgPSBhbmRyb2lkOjpiYXNlOjpUcmltKHRtcCk7CisgICAgICAgICAgICBpbnQ2NF90IG1hbmZpZDsKKyAgICAgICAgICAgIGlmICghYW5kcm9pZDo6YmFzZTo6UGFyc2VJbnQodG1wLCAmbWFuZmlkKSkgeworICAgICAgICAgICAgICAgIFBMT0coV0FSTklORykgPDwgIkZhaWxlZCB0byBwYXJzZSBtYW51ZmFjdHVyZXIgIiA8PCB0bXA7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7CisgICAgICAgICAgICB9CisgICAgICAgICAgICAvLyBPdXIgZ29hbCBoZXJlIGlzIHRvIGdpdmUgdGhlIHVzZXIgYSBtZWFuaW5nZnVsIGxhYmVsLCBpZGVhbGx5CisgICAgICAgICAgICAvLyBtYXRjaGluZyB3aGF0ZXZlciBpcyBzaWxrLXNjcmVlbmVkIG9uIHRoZSBjYXJkLiAgVG8gcmVkdWNlCisgICAgICAgICAgICAvLyB1c2VyIGNvbmZ1c2lvbiwgdGhpcyBsaXN0IGRvZXNuJ3QgY29udGFpbiB3aGl0ZS1sYWJlbCBtYW5maWQuCisgICAgICAgICAgICBzd2l0Y2ggKG1hbmZpZCkgeworICAgICAgICAgICAgICAgIC8vIGNsYW5nLWZvcm1hdCBvZmYKKyAgICAgICAgICAgICAgICBjYXNlIDB4MDAwMDAzOiBtTGFiZWwgPSAiU2FuRGlzayI7IGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgMHgwMDAwMWI6IG1MYWJlbCA9ICJTYW1zdW5nIjsgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSAweDAwMDAyODogbUxhYmVsID0gIkxleGFyIjsgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSAweDAwMDA3NDogbUxhYmVsID0gIlRyYW5zY2VuZCI7IGJyZWFrOworICAgICAgICAgICAgICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb24KKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGRlZmF1bHQ6IHsKKyAgICAgICAgICAgIGlmIChpc1ZpcnRpb0Jsa0RldmljZShtYWpvcklkKSkgeworICAgICAgICAgICAgICAgIExPRyhERUJVRykgPDwgIlJlY29nbml6ZWQgZXhwZXJpbWVudGFsIGJsb2NrIG1ham9yIElEICIgPDwgbWFqb3JJZAorICAgICAgICAgICAgICAgICAgICAgICAgICAgPDwgIiBhcyB2aXJ0aW8tYmxrIChlbXVsYXRvcidzIHZpcnR1YWwgU0QgY2FyZCBkZXZpY2UpIjsKKyAgICAgICAgICAgICAgICBtTGFiZWwgPSAiVmlydHVhbCI7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoaXNOdm1lQmxrRGV2aWNlKG1ham9ySWQsIG1TeXNQYXRoKSkgeworICAgICAgICAgICAgICAgIHN0ZDo6c3RyaW5nIHBhdGgobVN5c1BhdGggKyAiL2RldmljZS9tb2RlbCIpOworICAgICAgICAgICAgICAgIHN0ZDo6c3RyaW5nIHRtcDsKKyAgICAgICAgICAgICAgICBpZiAoIVJlYWRGaWxlVG9TdHJpbmcocGF0aCwgJnRtcCkpIHsKKyAgICAgICAgICAgICAgICAgICAgUExPRyhXQVJOSU5HKSA8PCAiRmFpbGVkIHRvIHJlYWQgdmVuZG9yIGZyb20gIiA8PCBwYXRoOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gLWVycm5vOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBtTGFiZWwgPSB0bXA7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBMT0coV0FSTklORykgPDwgIlVu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gorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaUc6IGNhc2Uga01ham9yQmxvY2tTY3NpSDogY2FzZSBrTWFqb3JCbG9ja1Njc2lJOgorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaUo6IGNhc2Uga01ham9yQmxvY2tTY3NpSzogY2FzZSBrTWFqb3JCbG9ja1Njc2lMOgorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaU06IGNhc2Uga01ham9yQmxvY2tTY3NpTjogY2FzZSBrTWFqb3JCbG9ja1Njc2lPOgorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaVA6IHsKKyAgICAgICAgICAgIC8vIGNsYW5nLWZvcm1hdCBvbgorICAgICAgICAgICAgLy8gUGVyIERvY3VtZW50YXRpb24vZGV2aWNlcy50eHQgdGhpcyBpcyBzdGF0aWMKICAgICAgICAgICAgIHJldHVybiAxNTsKICAgICAgICAgfQotICAgIH0KKyAgICAgICAgY2FzZSBrTWFqb3JCbG9ja01tYzogeworICAgICAgICAgICAgLy8gUGVyIERvY3VtZW50YXRpb24vZGV2aWNlcy50eHQgdGhpcyBpcyBkeW5hbWljCisgICAgICAgICAgICBzdGQ6OnN0cmluZyB0bXA7CisgICAgICAgICAgICBpZiAoIVJlYWRGaWxlVG9TdHJpbmcoa1N5c2ZzTW1jTWF4TWlub3JzLCAmdG1wKSAmJgorICAgICAgICAgICAgICAgICFSZWFkRmlsZVRvU3RyaW5nKGtTeXNmc01tY01heE1pbm9yc0RlcHJlY2F0ZWQsICZ0bXApKSB7CisgICAgICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIHJlYWQgbWF4IG1pbm9ycyI7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHJldHVybiBzdGQ6OnN0b2kodG1wKTsKKyAgICAgICAgfQorICAgICAgICBkZWZhdWx0OiB7CisgICAgICAgICAgICBpZiAoaXNWaXJ0aW9CbGtEZXZpY2UobWFqb3JJZCkpIHsKKyAgICAgICAgICAgICAgICAvLyBkcml2ZXJzL2Jsb2NrL3ZpcnRpb19ibGsuYyBoYXMgIiNkZWZpbmUgUEFSVF9CSVRTIDQiLCBzbyBtYXggaXMKKyAgICAgICAgICAgICAgICAvLyAyXjQgLSAxID0gMTUKKyAgICAgICAgICAgICAgICByZXR1cm4gMTU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoaXNOdm1lQmxrRGV2aWNlKG1ham9ySWQsIG1TeXNQYXRoKSkgeworICAgICAgICAgICAgICAgIC8vIGRlc3BpdGUga2VybmVsIG52bWUgZHJpdmVyIHN1cHBvcnRzIHVwIHRvIDFNIG1pbm9ycywKKyAgICAgICAgICAgICAgICAvLyAgICAgI2RlZmluZSBOVk1FX01JTk9SUyAoMVUgPDwgTUlOT1JCSVRTKQorICAgICAgICAgICAgICAgIC8vIHNnZGlzayBjYW4gbm90IHN1cHBvcnQgbW9yZSB0aGFuIDEyNyBwYXJ0aXRpb25zLCBkdWUgdG8KKyAgICAgICAgICAgICAgICAvLyAgICAgI2RlZmluZSBNQVhfTUJSX1BBUlRTIDEyOAorICAgICAgICAgICAgICAgIHJldHVybiAxMjc7CisgICAgICAgICAgICB9CisgICAgICAgIH0KICAgICB9CiAKICAgICBMT0coRVJST1IpIDw8ICJVbnN1cHBvcnRlZCBibG9jayBtYWpvciB0eXBlICIgPDwgbWFqb3JJZDsKZGlmZiAtLWdpdCBhL21vZGVsL0Rpc2suaCBiL21vZGVsL0Rpc2suaAppbmRleCA2M2FjZjZhLi44ODllOTA2IDEwMDY0NAotLS0gYS9tb2RlbC9EaXNrLmgKKysrIGIvbW9kZWwvRGlzay5oCkBAIC0zNiw3ICszNiw3IEBACiAgKiBob3cgdG8gcmVwYXJ0aXRpb24gaXRzZWxmLgogICovCiBjbGFzcyBEaXNrIHsKLXB1YmxpYzoKKyAgcHVibGljOgogICAgIERpc2soY29uc3Qgc3RkOj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tRnVzZUZ1bGwuY19zdHIoKSwgMDcwMCwgQUlEX1JPT1QsIEFJRF9ST09UKSkgewogICAgICAgICBQTE9HKEVSUk9SKSA8PCBnZXRJZCgpIDw8ICIgZmFpbGVkIHRvIGNyZWF0ZSBtb3VudCBwb2ludHMiOwogICAgICAgICByZXR1cm4gLWVycm5vOwogICAgIH0KIAotICAgIGRldl90IGJlZm9yZSA9IEdldERldmljZShtRnVzZVdyaXRlKTsKKyAgICBkZXZfdCBiZWZvcmUgPSBHZXREZXZpY2UobUZ1c2VGdWxsKTsKIAogICAgIGlmICghKG1GdXNlUGlkID0gZm9yaygpKSkgeworICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb2ZmCiAgICAgICAgIGlmIChleGVjbChrRnVzZVBhdGgsIGtGdXNlUGF0aCwKICAgICAgICAgICAgICAgICAiLXUiLCAiMTAyMyIsIC8vIEFJRF9NRURJQV9SVwogICAgICAgICAgICAgICAgICItZyIsICIxMDIzIiwgLy8gQUlEX01FRElBX1JXCkBAIC04Nyw5ICs5MSwxMSBAQAogICAgICAgICAgICAgICAgICItdyIsCiAgICAgICAgICAgICAgICAgIi1HIiwKICAgICAgICAgICAgICAgICAiLWkiLAorICAgICAgICAgICAgICAgICItbyIsCiAgICAgICAgICAgICAgICAgbVJhd1BhdGguY19zdHIoKSwKICAgICAgICAgICAgICAgICBsYWJlbC5jX3N0cigpLAogICAgICAgICAgICAgICAgIE5VTEwpKSB7CisgICAgICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb24KICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gZXhlYyI7CiAgICAgICAgIH0KIApAQCAtMTAzLDkgKzEwOSw5IEBACiAgICAgfQogCiAgICAgbnNlY3NfdCBzdGFydCA9IHN5c3RlbVRpbWUoU1lTVEVNX1RJTUVfQk9PVFRJTUUpOwotICAgIHdoaWxlIChiZWZvcmUgPT0gR2V0RGV2aWNlKG1GdXNlV3JpdGUpKSB7Ci0gICAg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0ZS5jX3N0cigpLCAwNzAwLCBBSURfUk9PVCwgQUlEX1JPT1QpKSB7CisgICAgICAgIGZzX3ByZXBhcmVfZGlyKG1GdXNlUmVhZC5jX3N0cigpLCAwNzAwLCBBSURfUk9PVCwgQUlEX1JPT1QpIHx8CisgICAgICAgIGZzX3ByZXBhcmVfZGlyKG1GdXNlV3JpdGUuY19zdHIoKSwgMDcwMCwgQUlEX1JPT1QsIEFJRF9ST09UKSB8fAorICAgICAgICBmc19wcmVwYXJlX2RpcihtRnVzZUZ1bGwuY19zdHIoKSwgMDcwMCwgQUlEX1JPT1QsIEFJRF9ST09UKSkgewogICAgICAgICBQTE9HKEVSUk9SKSA8PCBnZXRJZCgpIDw8ICIgZmFpbGVkIHRvIGNyZWF0ZSBGVVNFIG1vdW50IHBvaW50cyI7CiAgICAgICAgIHJldHVybiAtZXJybm87CiAgICAgfQogCi0gICAgZGV2X3QgYmVmb3JlID0gR2V0RGV2aWNlKG1GdXNlV3JpdGUpOworICAgIGRldl90IGJlZm9yZSA9IEdldERldmljZShtRnVzZUZ1bGwpOwogCiAgICAgaWYgKCEobUZ1c2VQaWQgPSBmb3JrKCkpKSB7CiAgICAgICAgIGlmIChnZXRNb3VudEZsYWdzKCkgJiBNb3VudEZsYWdzOjprUHJpbWFyeSkgeworICAgICAgICAgICAgLy8gY2xhbmctZm9ybWF0IG9mZgogICAgICAgICAgICAgaWYgKGV4ZWNsKGtGdXNlUGF0aCwga0Z1c2VQYXRoLAogICAgICAgICAgICAgICAgICAgICAiLXUiLCAiMTAyMyIsIC8vIEFJRF9NRURJQV9SVwogICAgICAgICAgICAgICAgICAgICAiLWciLCAiMTAyMyIsIC8vIEFJRF9NRURJQV9SVwpAQCAtMTc2LDkgKzE3OSwxMSBAQAogICAgICAgICAgICAgICAgICAgICBtUmF3UGF0aC5jX3N0cigpLAogICAgICAgICAgICAgICAgICAgICBzdGFibGVOYW1lLmNfc3RyKCksCiAgICAgICAgICAgICAgICAgICAgIE5VTEwpKSB7CisgICAgICAgICAgICAgICAgLy8gY2xhbmctZm9ybWF0IG9uCiAgICAgICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBleGVjIjsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIC8vIGNsYW5nLWZvcm1hdCBvZmYKICAgICAgICAgICAgIGlmIChleGVjbChrRnVzZVBhdGgsIGtGdXNlUGF0aCwKICAgICAgICAgICAgICAgICAgICAgIi11IiwgIjEwMjMiLCAvLyBBSURfTUVESUFfUlcKICAgICAgICAgICAgICAgICAgICAgIi1nIiwgIjEwMjMiLCAvLyBBSURfTUVESUFfUlcKQEAgLTE4Niw2ICsxOTEsNyBAQAogICAgICAgICAgICAgICAgICAgICBtUmF3UGF0aC5jX3N0cigpLAogICAgICAgICAgICAgICAgICAgICBzdGFibGVOYW1lLmNfc3RyKCksCiAgICAgICAgICAgICAgICAgICAgIE5VTEwpKSB7CisgICAgICAgICAgICAgICAgLy8gY2xhbmctZm9ybWF0IG9uCiAgICAgICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBleGVjIjsKICAgICAgICAgICAgIH0KICAgICAgICAgfQpAQCAtMjAwLDkgKzIwNiw5IEBACiAgICAgfQogCiAgICAgbnNlY3NfdCBzdGFydCA9IHN5c3RlbVRpbWUoU1lTVEVNX1RJTUVfQk9PVFRJTUUpOwotICAgIHdoaWxlIChiZWZvcmUgPT0gR2V0RGV2aWNlKG1GdXNlV3JpdGUpKSB7Ci0gICAgICAgIExPRyhWRVJCT1NFKSA8PCAiV2FpdGluZyBmb3IgRlVTRSB0byBzcGluIHVwLi4uIjsKLSAgICAgICAgdXNsZWVwKDUwMDAwKTsgLy8gNTBtcworICAgIHdoaWxlIChiZWZvcmUgPT0gR2V0RGV2aWNlKG1GdXNlRnVsbCkpIHsKKyAgICAgICAgTE9HKERFQlVHKSA8PCAiV2FpdGluZyBmb3IgRlVTRSB0byBzcGluIH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igpLCBPX1dST05MWSB8IE9fQ0xPRVhFQywgMCkpKTsKKyAgICAgICAgaWYgKGZkID09IC0xKSB7CisgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJTZWN1cmUgZGlzY2FyZCBvcGVuIGZhaWxlZCBmb3I6ICIgPDwgdGFyZ2V0OworICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgIH0KKyAgICAgICAgX191MzIgc2V0ID0gMTsKKyAgICAgICAgaW9jdGwoZmQsIEYyRlNfSU9DX1NFVF9QSU5fRklMRSwgJnNldCk7CisKICAgICAgICAgTE9HKERFQlVHKSA8PCAiU2VjdXJlbHkgZGlzY2FyZGluZyAnIiA8PCB0YXJnZXQgPDwgIicgdW5saW5rPSIgPDwgb3B0aW9ucy51bmxpbms7CiAgICAgICAgIGlmICghc2VjZGlzY2FyZF9wYXRoKHRhcmdldCkpIHsKICAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIlNlY3VyZSBkaXNjYXJkIGZhaWxlZCBmb3I6ICIgPDwgdGFyZ2V0OwpAQCAtNjcsMzYgKzkzLDM3IEBACiAgICAgICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIlVuYWJsZSB0byB1bmxpbms6ICIgPDwgdGFyZ2V0OwogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIExPRyhERUJVRykgPDwgIkRpc2NhcmRlZDogIiA8PCB0YXJnZXQ7CisgICAgICAgIHNldCA9IDA7CisgICAgICAgIGlvY3RsKGZkLCBGMkZTX0lPQ19TRVRfUElOX0ZJTEUsICZzZXQpOwogICAgIH0KICAgICByZXR1cm4gMDsKIH0KIAogbmFtZXNwYWNlIHsKIAotYm9vbCByZWFkX2NvbW1hbmRfbGluZShpbnQgYXJnYywgY29uc3QgY2hhciAqIGNvbnN0IGFyZ3ZbXSwgT3B0aW9ucyAmb3B0aW9ucykgeworYm9vbCByZWFkX2NvbW1hbmRfbGluZShpbnQgYXJnYywgY29uc3QgY2hhciogY29uc3QgYXJndltdLCBPcHRpb25zJiBvcHRpb25zKSB7CiAgICAgZm9yIChpbnQgaSA9IDE7IGkgPCBhcmdjOyBpKyspIHsKICAgICAgICAgaWYgKCFzdHJjbXAoIi0tbm8tdW5saW5rIiwgYXJndltpXSkpIHsKICAgICAgICAgICAgIG9wdGlvbnMudW5saW5rID0gZmFsc2U7CiAgICAgICAgIH0gZWxzZSBpZiAoIXN0cmNtcCgiLS0iLCBhcmd2W2ldKSkgewotICAgICAgICAgICAgZm9yIChpbnQgaiA9IGkrMTsgaiA8IGFyZ2M7IGorKykgewotICAgICAgICAgICAgICAgIGlmIChhcmd2W2pdWzBdICE9ICcvJykgcmV0dXJuIGZhbHNlOyAvLyBNdXN0IGJlIGFic29sdXRlIHBhdGgKKyAgICAgICAgICAgIGZvciAoaW50IGogPSBpICsgMTsgaiA8IGFyZ2M7IGorKykgeworICAgICAgICAgICAgICAgIGlmIChhcmd2W2pdWzBdICE9ICcvJykgcmV0dXJuIGZhbHNlOyAgLy8gTXVzdCBiZSBhYnNvbHV0ZSBwYXRoCiAgICAgICAgICAgICAgICAgb3B0aW9ucy50YXJnZXRzLmVtcGxhY2VfYmFjayhhcmd2W2pdKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIHJldHVybiBvcHRpb25zLnRhcmdldHMuc2l6ZSgpID4gMDsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIHJldHVybiBmYWxzZTsgLy8gVW5rbm93biBvcHRpb24KKyAgICAgICAgICAgIHJldHVybiBmYWxzZTsgIC8vIFVua25vd24gb3B0aW9uCiAgICAgICAgIH0KICAgICB9Ci0gICAgcmV0dXJuIGZhbHNlOyAvLyAiLS0iIG5vdCBmb3VuZAorICAgIHJldHVybiBmYWxzZTsgIC8vICItLSIgbm90IGZvdW5kCiB9CiAKLXZvaWQgdXNhZ2UoY29uc3QgY2hhciAqcHJvZ25hbWUpIHsKK3ZvaWQgdXNhZ2UoY29uc3QgY2hhciogcHJvZ25hbWUpIHsKICAgICB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gIGtleW1hc3RlcjFfZGV2aWNlX3QgKmtleW1hc3RlcjFfZGV2ID0gMDsKKyAgICBrZXltYXN0ZXIwX2RldmljZV90KiBrZXltYXN0ZXIwX2RldiA9IDA7CisgICAga2V5bWFzdGVyMV9kZXZpY2VfdCoga2V5bWFzdGVyMV9kZXYgPSAwOwogCiAgICAgaWYgKGZ0ci0+a2V5bWFzdGVyX2Jsb2Jfc2l6ZSkgewogICAgICAgICBTTE9HSSgiQWxyZWFkeSBoYXZlIGtleSIpOwpAQCAtMTc3LDExICsxNzMsMTAgQEAKICAgICAgICAgICAgIC8qIFJhdGUtbGltaXQga2V5IHVzYWdlIGF0dGVtcHRzLCB0byByYXRlLWxpbWl0IGJydXRlIGZvcmNlICovCiAgICAgICAgICAgICBrZXltYXN0ZXJfcGFyYW1faW50KEtNX1RBR19NSU5fU0VDT05EU19CRVRXRUVOX09QUywgS0VZTUFTVEVSX0NSWVBURlNfUkFURV9MSU1JVCksCiAgICAgICAgIH07Ci0gICAgICAgIGtleW1hc3Rlcl9rZXlfcGFyYW1fc2V0X3QgcGFyYW1fc2V0ID0geyBwYXJhbXMsIHNpemVvZihwYXJhbXMpL3NpemVvZigqcGFyYW1zKSB9OworICAgICAgICBrZXltYXN0ZXJfa2V5X3BhcmFtX3NldF90IHBhcmFtX3NldCA9IHtwYXJhbXMsIHNpemVvZihwYXJhbXMpIC8gc2l6ZW9mKCpwYXJhbXMpfTsKICAgICAgICAga2V5bWFzdGVyX2tleV9ibG9iX3Qga2V5X2Jsb2I7Ci0gICAgICAgIGtleW1hc3Rlcl9lcnJvcl90IGVycm9yID0ga2V5bWFzdGVyMV9kZXYtPmdlbmVyYXRlX2tleShrZXltYXN0ZXIxX2RldiwgJnBhcmFtX3NldCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZrZXlfYmxvYiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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ICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqKnNpZ25hdHVyZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCAqc2lnbmF0dXJlX3NpemUpCi17CitzdGF0aWMgaW50IGtleW1hc3Rlcl9zaWduX29iamVjdF9vbGQoc3RydWN0IGNyeXB0X21udF9mdHIqIGZ0ciwgY29uc3QgdW5zaWduZWQgY2hhciogb2JqZWN0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNpemVfdCBvYmplY3Rfc2l6ZSwgdW5zaWduZWQgY2hhcioqIHNpZ25hdHVyZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QqIHNpZ25hdHVyZV9zaXplKSB7CiAgICAgaW50IHJjID0gMDsKLSAgICBrZXltYXN0ZXIwX2RldmljZV90ICprZXltYXN0ZXIwX2RldiA9IDA7Ci0gICAga2V5bWFzdGVyMV9kZXZpY2VfdCAqa2V5bWFzdGVyMV9kZXYgPSAwOworICAgIGtleW1hc3RlcjBfZGV2aWNlX3QqIGtleW1hc3RlcjBfZGV2ID0gMDsKKyAgICBrZXltYXN0ZXIxX2RldmljZV90KiBrZXltYXN0ZXIxX2RldiA9IDA7CiAKICAgICB1bnNpZ25lZCBjaGFyIHRvX3NpZ25bUlNBX0tFWV9TSVpFX0JZVEVTXTsKICAgICBzaXplX3QgdG9fc2lnbl9zaXplID0gc2l6ZW9mKHRvX3NpZ24pOwpAQCAtMjg0LDMyICsyNzIsMjUgQEAKICAgICAgICAgcGFyYW1zLmRpZ2VzdF90eXBlID0gRElHRVNUX05PTkU7CiAgICAgICAgIHBhcmFtcy5wYWRkaW5nX3R5cGUgPSBQQURESU5HX05PTkU7CiAKLSAgICAgICAgcmMgPSBrZXltYXN0ZXIwX2Rldi0+c2lnbl9kYXRhKGtleW1hc3RlcjBfZGV2LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmcGFyYW1zLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmdHItPmtleW1hc3Rlcl9ibG9iLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmdHItPmtleW1hc3Rlcl9ibG9iX3NpemUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvX3NpZ24sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvX3NpZ25fc2l6ZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2lnbmF0dXJlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaWduYXR1cmVfc2l6ZSk7CisgICAgICAgIHJjID0ga2V5bWFzdGVyMF9kZXYtPnNpZ25fZGF0YShrZXltYXN0ZXIwX2RldiwgJnBhcmFtcywgZnRyLT5rZXltYXN0ZXJfYmxvYiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ0ci0+a2V5bWFzdGVyX2Jsb2Jfc2l6ZSwgdG9fc2lnbiwgdG9fc2lnbl9zaXplLCBzaWduYXR1cmUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaWduYXR1cmVfc2l6ZSk7CiAgICAgICAgIGdvdG8gb3V0OwogICAgIH0gZWxzZSBpZiAoa2V5bWFzdGVyMV9kZXYpIHsKLSAgICAgICAga2V5bWFzdGVyX2tleV9ibG9iX3Qga2V5ID0geyBmdHItPmtleW1hc3Rlcl9ibG9iLCBmdHItPmtleW1hc3Rlcl9ibG9iX3NpemUgfTsKKyAgICAgICAga2V5bWFzdGVyX2tleV9ibG9iX3Qga2V5ID0ge2Z0ci0+a2V5bWFzdGVyX2Jsb2IsIGZ0ci0+a2V5bWFzdGVyX2Jsb2Jfc2l6ZX07CiAgICAgICAgIGtleW1hc3Rlcl9rZXlfcGFyYW1fdCBwYXJhbXNbXSA9IHsKICAgICAgICAgICAgIGtleW1hc3Rlcl9wYXJhbV9lbnVtKEtNX1RBR19QQURESU5HLCBLTV9QQURfTk9ORSksCiAgICAgICAgICAgICBrZXltYXN0ZXJfcGFyYW1fZW51bShLTV9UQUdfRElHRVNULCBLTV9ESUdFU1RfTk9ORSksCiAgICAgICAgIH07Ci0gICAgICAgIGtleW1hc3Rlcl9rZXlfcGFyYW1fc2V0X3QgcGFyYW1fc2V0ID0geyBwYXJhbXMsIHNpemVvZihwYXJhbXMpL3NpemVvZigqcGFyYW1zKSB9OworICAgICAgICBrZXltYXN0ZXJfa2V5X3BhcmFtX3NldF90IHBhcmFtX3NldCA9IHtwYXJhbXMsIHNpemVvZihwYXJhbXMpIC8gc2l6ZW9mKCpwYXJhbXMpfTsKICAgICAgICAga2V5bWFzdGVyX29wZXJhdGlvbl9oYW5kbGVfdCBvcF9oYW5kbGU7Ci0gICAgICAgIGtleW1hc3Rlcl9lcnJvcl90IGVycm9yID0ga2V5bWFzdGVyMV9kZXYtPmJlZ2luKGtleW1hc3RlcjFfZGV2LCBLTV9QVVJQT1NFX1NJR04sICZrZXksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZwYXJhbV9zZXQsIE5VTEwgLyogb3V0X3BhcmFtcyAqLywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJm9wX2hhbmRsZSk7CisgICAgICAgIGtleW1hc3Rlcl9lcnJvcl90IGVycm9yID0ga2V5bWFzdGVyMV9kZXYtPmJlZ2luKAorICAgICAgICAgICAga2V5bWFzdGVyMV9kZXYsIEtNX1BVUlBPU0VfU0lHTiwgJmtleSwgJnBhcmFtX3NldCwgTlVMTCAvKiBvdXRfcGFyYW1zICovLCAmb3BfaGFuZGxlKTsKICAgICAgICAgaWYgKGVycm9yID09IEtNX0VSUk9SX0tFWV9SQVRFX0xJTUlUX0VYQ0VFREVEKSB7CiAgICAgICAgICAgICAvLyBLZXkgdXNhZ2UgaGFzIGJlZW4gcmF0ZS1saW1pdGVkLiAgV2FpdCBhIGJpdCBhbmQgdHJ5IGFnYWluLgogICAgICAgICAgICAgc2xlZXAoS0VZTUFTVEVSX0NSWVBURlNfUkFURV9MSU1JVCk7Ci0gICAgICAgICAgICBlcnJvciA9IGtleW1hc3RlcjFfZGV2LT5iZWdpbihrZXltYXN0ZXIxX2RldiwgS01fUFVSUE9TRV9TSUdOLCAma2V5LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnBhcmFtX3NldCwgTlVMTCAvKiBvdXRfcGFyYW1zICovLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJm9wX2hhbmRsZSk7CisgICAgICAgICAgICBlcnJvciA9IGtleW1hc3RlcjFfZGV2LT5iZWdpbihrZXltYXN0ZXIxX2RldiwgS01fUFVSUE9TRV9TSUdOLCAma2V5LCAmcGFyYW1fc2V0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTlVMTCAvKiBvdXRfcGFyYW1zICovLCAmb3BfaGFuZGxlKTsKICAgICAgICAgfQogICAgICAgICBpZiAoZXJyb3IgIT0gS01fRVJST1JfT0spIHsKICAgICAgICAgICAgIFNMT0dFKCJFcnJvciBzdGFydGluZyBrZXltYXN0ZXIgc2lnbmF0dXJlIHRyYW5zYWN0aW9uOiAlZCIsIGVycm9yKTsKQEAgLTMxNywxMSArMjk4LDEwIEBACiAgICAgICAgICAgICBnb3RvIG91dDsKICAgICAgICAgfQogCi0gICAgICAgIGtleW1hc3Rlcl9ibG9iX3QgaW5wdXQgPSB7IHRvX3NpZ24sIHRvX3NpZ25fc2l6ZSB9OworICAgICAgICBrZXltYXN0ZXJfYmxvYl90IGlucHV0ID0ge3RvX3NpZ24sIHRvX3NpZ25fc2l6ZX07CiAgICAgICAgIHNpemVfdCBpbnB1dF9jb25zdW1lZDsKLSAgICAgICAgZXJyb3IgPSBrZXltYXN0ZXIxX2Rldi0+dXBkYXRlKGtleW1hc3RlcjFfZGV2LCBvcF9oYW5kbGUsIE5VTEwgLyogaW5fcGFyYW1zICovLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJmlucHV0LCAmaW5wdXRfY29uc3VtZWQsIE5VTEwgLyogb3V0X3BhcmFtcyAqLywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5VTEwgLyogb3V0cHV0ICovKTsKKyAgICAgICAgZXJyb3IgPSBrZXltYXN0ZXIxX2Rldi0+dXBkYXRlKGtleW1hc3RlcjFfZGV2LCBvcF9oYW5kbGUsIE5VTEwgLyogaW5fcGFyYW1zICovLCAmaW5wdXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmaW5wdXRfY29uc3VtZWQsIE5VTEwgLyogb3V0X3BhcmFtcyAqLywgTlVMTCAvKiBvdXRwdXQgKi8pOwogICAgICAgICBpZiAoZXJyb3IgIT0gS01fRVJST1JfT0spIHsKICAgICAgICAgICAgIFNMT0dFKCJFcnJvciBzZW5kaW5nIGRhdGEgdG8ga2V5bWFzdGVyIHNpZ25hdHVyZSB0cmFuc2FjdGlvbjogJWQiLCBlcnJvcik7CiAgICAgICAgICAgICByYyA9IC0xOwpAQCAtMzM3LDggKzMxNyw3IEBACiAKICAgICAgICAga2V5bWFzdGVyX2Jsb2JfdCB0bXBfc2lnOwogICAgICAgICBlcnJvciA9IGtleW1hc3RlcjFfZGV2LT5maW5pc2goa2V5bWFzdGVyMV9kZXYsIG9wX2hhbmRsZSwgTlVMTCAvKiBpbl9wYXJhbXMgKi8sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBOVUxMIC8qIHZlcmlmeSBzaWduYXR1cmUgKi8sIE5VTEwgLyogb3V0X3BhcmFtcyAqLywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZ0bXBfc2ln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Sw5IEBACiAjZW5kaWYKIAogLyogVGhpcyBzaWducyB0aGUgZ2l2ZW4gb2JqZWN0IHVzaW5nIHRoZSBrZXltYXN0ZXIga2V5LiAqLwotc3RhdGljIGludCBrZXltYXN0ZXJfc2lnbl9vYmplY3RfbmV3KHN0cnVjdCBjcnlwdF9tbnRfZnRyICpmdHIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bnNpZ25lZCBjaGFyICpvYmplY3QsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplX3Qgb2JqZWN0X3NpemUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICoqc2lnbmF0dXJlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90ICpzaWduYXR1cmVfc2l6ZSkKLXsKK3N0YXRpYyBpbnQga2V5bWFzdGVyX3NpZ25fb2JqZWN0X25ldyhzdHJ1Y3QgY3J5cHRfbW50X2Z0ciogZnRyLCBjb25zdCB1bnNpZ25lZCBjaGFyKiBvYmplY3QsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2l6ZV90IG9iamVjdF9zaXplLCB1bnNpZ25lZCBjaGFyKiogc2lnbmF0dXJlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCogc2lnbmF0dXJlX3NpemUpIHsKICAgICB1bnNpZ25lZCBjaGFyIHRvX3NpZ25bUlNBX0tFWV9TSVpFX0JZVEVTXTsKICAgICBzaXplX3QgdG9fc2lnbl9zaXplID0gc2l6ZW9mKHRvX3NpZ24pOwogICAgIG1lbXNldCh0b19zaWduLCAwLCBSU0FfS0VZX1NJWkVfQllURVMpOwpAQCAtNDQzLDEyICs0MTUsMTAgQEAKIG5hbWVzcGFjZSBhbmRyb2lkIHsKIAogY2xhc3MgQ3J5cHRGc1Rlc3QgOiBwdWJsaWMgdGVzdG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