ZGlmZiAtLWdpdCBhL0FuZHJvaWQuYnAgYi9BbmRyb2lkLmJwCmluZGV4IDU1Njc4NGYuLmFmNzdjZWYgMTAwNjQ0Ci0tLSBhL0FuZHJvaWQuYnAKKysrIGIvQW5kcm9pZC5icApAQCAtMzksNiArMzksNyBAQAogICAgIHNoYXJlZF9saWJzOiBbCiAgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmtleW1hc3RlckAzLjAiLAogICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5rZXltYXN0ZXJANC4wIiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuYm9vdEAxLjAiLAogICAgICAgICAibGliYmFzZSIsCiAgICAgICAgICJsaWJiaW5kZXIiLAogICAgICAgICAibGliY3J5cHRvIiwKQEAgLTk1LDYgKzk2LDcgQEAKICAgICBzcmNzOiBbCiAgICAgICAgICJCZW5jaG1hcmsuY3BwIiwKICAgICAgICAgIkNoZWNrRW5jcnlwdGlvbi5jcHAiLAorICAgICAgICAiQ2hlY2twb2ludC5jcHAiLAogICAgICAgICAiRGV2bWFwcGVyLmNwcCIsCiAgICAgICAgICJFbmNyeXB0SW5wbGFjZS5jcHAiLAogICAgICAgICAiRXh0NENyeXB0LmNwcCIsCkBAIC0xMzgsNyArMTQwLDEzIEBACiAgICAgICAgICAgICAgICAgImxpYmFyY29iYnZvbHVtZSIsCiAgICAgICAgICAgICBdLAogICAgICAgICB9LAorICAgICAgICBkZWJ1Z2dhYmxlOiB7CisgICAgICAgICAgICBjcHBmbGFnczogWyItRF9fQU5EUk9JRF9ERUJVR0dBQkxFX18iXSwKKyAgICAgICAgfSwKICAgICB9LAorICAgIHNoYXJlZF9saWJzOiBbCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmhlYWx0aC5zdG9yYWdlQDEuMCIsCisgICAgXSwKIH0KIAogY2NfYmluYXJ5IHsKQEAgLTE2OCw2ICsxNzYsMTEgQEAKICAgICAgICAgInZvbGRfcHJlcGFyZV9zdW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FzZTo6UmVtb3ZlRmlsZUlmRXhpc3RzKGtNZXRhZGF0YUNQRmlsZSk7Cit9CisKK3ZvaWQgY3BfYWJvcnRDaGFuZ2VzKCkgeworICAgIGFuZHJvaWRfcmVib290KEFORFJPSURfUkJfUkVTVEFSVDIsIDAsIG51bGxwdHIpOworfQorCitib29sIGNwX25lZWRzUm9sbGJhY2soKSB7CisgICAgc3RkOjpzdHJpbmcgY29udGVudDsKKyAgICBib29sIHJldDsKKworICAgIHJldCA9IGFuZHJvaWQ6OmJhc2U6OlJlYWRGaWxlVG9TdHJpbmcoa01ldGFkYXRhQ1BGaWxlLCAmY29udGVudCk7CisgICAgaWYgKHJldCkgeworICAgICAgICBpZiAoY29udGVudCA9PSAiMCIpIHJldHVybiB0cnVlOworICAgICAgICBpZiAoY29udGVudC5zdWJzdHIoMCwgMykgPT0gIi0xICIpIHsKKyAgICAgICAgICAgIHN0ZDo6c3RyaW5nIG9sZFN1ZmZpeCA9IGNvbnRlbnQuc3Vic3RyKDMpOworICAgICAgICAgICAgc3A8SUJvb3RDb250cm9sPiBtb2R1bGUgPSBJQm9vdENvbnRyb2w6OmdldFNlcnZpY2UoKTsKKyAgICAgICAgICAgIHN0ZDo6c3RyaW5nIG5ld1N1ZmZpeDsKKworICAgICAgICAgICAgaWYgKG1vZHVsZSkgeworICAgICAgICAgICAgICAgIGF1dG8gY2IgPSBbJm5ld1N1ZmZpeF0oaGlkbF9zdHJpbmcgcykgeyBuZXdTdWZmaXggPSBzOyB9OworICAgICAgICAgICAgICAgIG1vZHVsZS0+Z2V0U3VmZml4KG1vZHVsZS0+Z2V0Q3VycmVudFNsb3QoKSwgY2IpOworICAgICAgICAgICAgICAgIGlmIChvbGRTdWZmaXggPT0gbmV3U3VmZml4KSByZXR1cm4gdHJ1ZTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gZmFsc2U7Cit9CisKK2Jvb2wgY3BfbmVlZHNDaGVja3BvaW50KHZv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IGNvbnN0IGZzdGFiX3JlYyogbW91bnRfcmVjID0gJm1vdW50cy0+cmVjc1tpXTsKKyAgICAgICAgY29uc3QgZnN0YWJfcmVjKiBmc3RhYl9yZWMgPQorICAgICAgICAgICAgZnNfbWdyX2dldF9lbnRyeV9mb3JfbW91bnRfcG9pbnQoZnN0YWJfZGVmYXVsdC5nZXQoKSwgbW91bnRfcmVjLT5tb3VudF9wb2ludCk7CisgICAgICAgIGlmICghZnN0YWJfcmVjKSBjb250aW51ZTsKKworICAgICAgICBpZiAoZnNfbWdyX2lzX2NoZWNrcG9pbnRfYmxrKGZzdGFiX3JlYykpIHsKKyAgICAgICAgICAgIGFuZHJvaWQ6OmJhc2U6OnVuaXF1ZV9mZCBmZCgKKyAgICAgICAgICAgICAgICBURU1QX0ZBSUxVUkVfUkVUUlkob3Blbihtb3VudF9yZWMtPm1vdW50X3BvaW50LCBPX1JET05MWSB8IE9fQ0xPRVhFQykpKTsKKyAgICAgICAgICAgIGlmICghZmQpIHsKKyAgICAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIG9wZW4gbW91bnQgcG9pbnQiIDw8IG1vdW50X3JlYy0+bW91bnRfcG9pbnQ7CisgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHN0cnVjdCBmc3RyaW1fcmFuZ2UgcmFuZ2UgPSB7fTsKKyAgICAgICAgICAgIHJhbmdlLmxlbiA9IFVMTE9OR19NQVg7CisgICAgICAgICAgICBpZiAoaW9jdGwoZmQsIEZJVFJJTSwgJnJhbmdlKSkgeworICAgICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gdHJpbSAiIDw8IG1vdW50X3JlYy0+bW91bnRfcG9pbnQ7CisgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHNldEJvd1N0YXRlKG1vdW50X3JlYy0+YmxrX2RldmljZSwgIj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orICAgICAgICAweDA1MDA1NzEzLCAweDk1QkY0QTgyLCAweEUyQjg3QTE0LCAweDdCQjEyQkFFLCAweDBDQjYxQjM4LCAweDkyRDI4RTlCLCAweEU1RDVCRTBELAorICAgICAgICAweDdDRENFRkI3LCAweDBCREJERjIxLCAweDg2RDNEMkQ0LCAweEYxRDRFMjQyLCAweDY4RERCM0Y4LCAweDFGREE4MzZFLCAweDgxQkUxNkNELAorICAgICAgICAweEY2QjkyNjVCLCAweDZGQjA3N0UxLCAweDE4Qjc0Nzc3LCAweDg4MDg1QUU2LCAweEZGMEY2QTcwLCAweDY2MDYzQkNBLCAweDExMDEwQjVDLAorICAgICAgICAweDhGNjU5RUZGLCAweEY4NjJBRTY5LCAweDYxNkJGRkQzLCAweDE2NkNDRjQ1LCAweEEwMEFFMjc4LCAweEQ3MEREMkVFLCAweDRFMDQ4MzU0LAorICAgICAgICAweDM5MDNCM0MyLCAweEE3NjcyNjYxLCAweEQwNjAxNkY3LCAweDQ5Njk0NzRELCAweDNFNkU3N0RCLCAweEFFRDE2QTRBLCAweEQ5RDY1QURDLAorICAgICAgICAweDQwREYwQjY2LCAweDM3RDgzQkYwLCAweEE5QkNBRTUzLCAweERFQkI5RUM1LCAweDQ3QjJDRjdGLCAweDMwQjVGRkU5LCAweEJEQkRGMjFDLAorICAgICAgICAweENBQkFDMjhBLCAweDUzQjM5MzMwLCAweDI0QjRBM0E2LCAweEJBRDAzNjA1LCAweENERDcwNjkzLCAweDU0REU1NzI5LCAweDIzRDk2N0JGLAorICAgICAgICAweEIzNjY3QTJFLCAweEM0NjE0QUI4LCAweDVENjgxQjAyLCAweDJBNkYyQjk0LCAweEI0MEJCRTM3LCAweEMzMEM4RUExLCAweDVBMDVERjFCLAorICAgICAgICAweDJEMDJFRjhEfTsKKworICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgbl9ieXRlczsgKytpKSB7CisgICAgICAgICpjcmMgXj0gKCh1aW50OF90KilkYXRhKVtpXTsKKyAgICA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TaXplKTsKKyAgICAgICAgbG9nX3NlY3RvciYgbHMgPSAqKGxvZ19zZWN0b3IqKWJ1ZmZlcjsKKyAgICAgICAgaWYgKGxzLm1hZ2ljICE9IGtNYWdpYykgeworICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiTm8gbWFnaWMhIjsKKyAgICAgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICAgICAgfQorCisgICAgICAgIGlmICgoaW50KWxzLnNlcXVlbmNlICE9IHNlcXVlbmNlKSB7CisgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJFeHBlY3RpbmcgbG9nIHNlY3RvciAiIDw8IHNlcXVlbmNlIDw8ICIgYnV0IGdvdCAiIDw8IGxzLnNlcXVlbmNlOworICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICB9CisKKyAgICAgICAgTE9HKElORk8pIDw8ICJSZXN0b3JpbmcgZnJvbSBsb2cgc2VjdG9yICIgPDwgbHMuc2VxdWVuY2U7CisKKyAgICAgICAgZm9yIChsb2dfZW50cnkqIGxlID0gJmxzLmVudHJpZXNbbHMuY291bnQgLSAxXTsgbGUgPj0gbHMuZW50cmllczsgLS1sZSkgeworICAgICAgICAgICAgTE9HKElORk8pIDw8ICJSZXN0b3JpbmcgIiA8PCBsZS0+c2l6ZSA8PCAiIGJ5dGVzIGZyb20gc2VjdG9yICIgPDwgbGUtPmRlc3QgPDwgIiB0byAiCisgICAgICAgICAgICAgICAgICAgICAgPDwgbGUtPnNvdXJjZSA8PCAiIHdpdGggY2hlY2tzdW0gIiA8PCBzdGQ6OmhleCA8PCBsZS0+Y2hlY2tzdW07CisgICAgICAgICAgICBzdGQ6OnZlY3RvcjxjaGFyPiBidWZmZXIobGUtPnNpemUpOworICAgICAgICAgICAgZGV2aWNlLnNlZWtnKGxlLT5kZXN0ICoga1NlY3RvclNpemUpOworICAgICAgICAgICAgZGV2aWNlLnJlYWQoJmJ1ZmZlclswXSwgbGUtPnNpemUpOworCisgICAgICAgICAgICB1a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ICAgICAgaWYgKHJldCAhPSAoaW50KWluZm8uYmxvY2tfc2l6ZSkgewpAQCAtMjE1LDggKzIwNCw5IEBACiAgICAgICAgIGRhdGEtPmNvdW50ID0gMDsKIAogICAgICAgICBmb3IgKGJsb2NrID0gMDsgYmxvY2sgPCBibG9ja19jb3VudDsgYmxvY2srKykgewotICAgICAgICAgICAgaW50IHVzZWQgPSAoYXV4X2luZm8uYmdfZGVzY1tpXS5iZ19mbGFncyAmIEVYVDRfQkdfQkxPQ0tfVU5JTklUKSA/Ci0gICAgICAgICAgICAgICAgICAgIDAgOiBiaXRtYXBfZ2V0X2JpdChibG9ja19iaXRtYXAsIGJsb2NrKTsKKyAgICAgICAgICAgIGludCB1c2VkID0gKGF1eF9pbmZvLmJnX2Rlc2NbaV0uYmdfZmxhZ3MgJiBFWFQ0X0JHX0JMT0NLX1VOSU5JVCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgID8gMAorICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBiaXRtYXBfZ2V0X2JpdChibG9ja19iaXRtYXAsIGJsb2NrKTsKICAgICAgICAgICAgIHVwZGF0ZV9wcm9ncmVzcyhkYXRhLCB1c2VkKTsKICAgICAgICAgICAgIGlmICh1c2VkKSB7CiAgICAgICAgICAgICAgICAgaWYgKGRhdGEtPmNvdW50ID09IDApIHsKQEAgLTIzMiw4ICsyMjIsOCBAQAogICAgICAgICAgICAgb2Zmc2V0ICs9IGluZm8uYmxvY2tfc2l6ZTsKIAogICAgICAgICAgICAgLyogV3JpdGUgZGF0YSBpZiB3ZSBhcmUgYWxpZ25lZCBvciBidWZmZXIgc2l6ZSByZWFjaGVkICovCi0gICAgICAgICAgICBpZiAob2Zmc2V0ICUgKGluZm8uYmxvY2tfc2l6ZSAqIEJMT0NLU19BVF9BX1RJTUUpID09IDAKLSAgICAgICAgICAgICAgICB8fCBkYXRhLT5jb3VudCA9PSBCTE9DS1NfQVRfQV9USU1FKSB7CisgICAgICAgICAgICBpZiAob2Zm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RlNJWkU7CkBAIC00MzgsNyArNDI1LDcgQEAKICAgICBkYXRhLnRpbWVfc3RhcnRlZCA9IHRpbWUoTlVMTCk7CiAgICAgZGF0YS5yZW1haW5pbmdfdGltZSA9IC0xOwogCi0gICAgZGF0YS5idWZmZXIgPSAoY2hhciopIG1hbGxvYyhmMmZzX2luZm8tPmJsb2NrX3NpemUpOworICAgIGRhdGEuYnVmZmVyID0gKGNoYXIqKW1hbGxvYyhmMmZzX2luZm8tPmJsb2NrX3NpemUpOwogICAgIGlmICghZGF0YS5idWZmZXIpIHsKICAgICAgICAgTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIGFsbG9jYXRlIGNyeXB0byBidWZmZXIiOwogICAgICAgICBnb3RvIGVycm91dDsKQEAgLTQ3NSwxOCArNDYyLDE4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmY2NF90IHByZXZpb3VzbHlfZW5jcnlwdGVkX3VwdG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIHNldF9wcm9ncmVzc19wcm9wZXJ0aWVzKSB7CiAgICAgaW50IHJlYWxmZCwgY3J5cHRvZmQ7Ci0gICAgY2hhciAqYnVmW0NSWVBUX0lOUExBQ0VfQlVGU0laRV07CisgICAgY2hhciogYnVmW0NSWVBUX0lOUExBQ0VfQlVGU0laRV07CiAgICAgaW50IHJjID0gRU5BQkxFX0lOUExBQ0VfRVJSX09USEVSOwogICAgIG9mZjY0X3QgbnVtYmxvY2tzLCBpLCByZW1haW5kZXI7CiAgICAgb2ZmNjRfdCBvbmVfcGN0LCBjdXJfcGN0LCBuZXdfcGN0OwogICAgIG9mZjY0X3QgYmxvY2tzX2FscmVhZHlfZG9uZSwgdG90X251bWJsb2NrczsKIAotICAgIGlmICggKHJlYWxmZCA9IG9wZW4ocmVhbF9ibGtkZXYsIE9fUkRPTkxZfE9fQ0xPRVhFQykpIDwgMCkgeworICAgIGlmICgocmVhbGZkID0g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ZSAoKG1udCA9IGdldG1udGVudChtbnRzLmdldCgpKSkgIT0gbnVsbHB0cikgewogICAgICAgICBhdXRvIGwgPSBzdHJsZW4obW50LT5tbnRfZGlyKTsKLSAgICAgICAgaWYgKGwgPiBiZXN0X2xlbmd0aCAmJgotICAgICAgICAgICAgcGF0aC5zaXplKCkgPiBsICYmCi0gICAgICAgICAgICBwYXRoW2xdID09ICcvJyAmJgorICAgICAgICBpZiAobCA+IGJlc3RfbGVuZ3RoICYmIHBhdGguc2l6ZSgpID4gbCAmJiBwYXRoW2xdID09ICcvJyAmJgogICAgICAgICAgICAgcGF0aC5jb21wYXJlKDAsIGwsIG1udC0+bW50X2RpcikgPT0gMCkgewotICAgICAgICAgICAgICAgIHJlc3VsdCA9IG1udC0+bW50X2ZzbmFtZTsKLSAgICAgICAgICAgICAgICBiZXN0X2xlbmd0aCA9IGw7CisgICAgICAgICAgICByZXN1bHQgPSBtbnQtPm1udF9mc25hbWU7CisgICAgICAgICAgICBiZXN0X2xlbmd0aCA9IGw7CiAgICAgICAgIH0KICAgICB9CiAgICAgaWYgKHJlc3VsdC5lbXB0eSgpKSB7Ci0gICAgICAgIExPRyhFUlJPUikgPDwiRGlkbid0IGZpbmQgYSBtb3VudHBvaW50IHRvIG1hdGNoIHBhdGggIiA8PCBwYXRoOworICAgICAgICBMT0coRVJST1IpIDw8ICJEaWRuJ3QgZmluZCBhIG1vdW50cG9pbnQgdG8gbWF0Y2ggcGF0aCAiIDw8IHBhdGg7CiAgICAgICAgIHJldHVybiAiIjsKICAgICB9CiAgICAgTE9HKERFQlVHKSA8PCAiRm9yIHBhdGggIiA8PCBwYXRoIDw8ICIgYmxvY2sgZGV2aWNlIGlzICIgPDwgcmVzdWx0OwogICAgIHJldHVybiByZXN1bHQ7CiB9CiAKLXN0ZDo6dW5pcXVlX3B0cjxzdHJ1Y3QgZmllbWFwPiBQYXRoRmllbWFwKGNvbnN0IHN0ZDo6c3RyaW5nICZwYXRoLCB1aW50MzJfdCBleH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MSwxMCArMTM1LDExIEBACiAgICAgICAgIH0gZWxzZSBpZiAocGF0aF90eXBlID09IFBhdGhUeXBlczo6a0Jsa0RldmljZSkgewogICAgICAgICAgICAgc3RkOjpzdHJpbmcgZ2NfcGF0aDsKICAgICAgICAgICAgIGlmIChzdGQ6OnN0cmluZyhmc3RhYi0+cmVjc1tpXS5mc190eXBlKSA9PSAiZjJmcyIgJiYKLSAgICAgICAgICAgICAgICBSZWFscGF0aChhbmRyb2lkOjp2b2xkOjpCbG9ja0RldmljZUZvclBhdGgoCi0gICAgICAgICAgICAgICAgICAgIHN0ZDo6c3RyaW5nKGZzdGFiLT5yZWNzW2ldLm1vdW50X3BvaW50KSArICIvIiksICZnY19wYXRoKSkgewotICAgICAgICAgICAgICAgIHBhdGhzLT5wdXNoX2JhY2soc3RkOjpzdHJpbmcoIi9zeXMvZnMvIikgKyBmc3RhYi0+cmVjc1tpXS5mc190eXBlICsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIvIiArIEJhc2VuYW1lKGdjX3BhdGgpKTsKKyAgICAgICAgICAgICAgICBSZWFscGF0aCgKKyAgICAgICAgICAgICAgICAgICAgYW5kcm9pZDo6dm9sZDo6QmxvY2tEZXZpY2VGb3JQYXRoKHN0ZDo6c3RyaW5nKGZzdGFiLT5yZWNzW2ldLm1vdW50X3BvaW50KSArICIvIiksCisgICAgICAgICAgICAgICAgICAgICZnY19wYXRoKSkgeworICAgICAgICAgICAgICAgIHBhdGhzLT5wdXNoX2JhY2soc3RkOjpzdHJpbmcoIi9zeXMvZnMvIikgKyBmc3RhYi0+cmVjc1tpXS5mc190eXBlICsgIi8iICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEJhc2VuYW1lKGdjX3BhdGgpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCkBAIC0xNzcsOCArMTgyLDggQEAKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIG5zZWNzX3QgdGltZSA9IHN5c3RlbVRpbWUoU1lTVEVNX1RJTUVfQk9PVFRJTUUpIC0gc3RhcnQ7Ci0gICAgICAgICAgICBMT0coSU5GTykgPDwgIlRyaW1tZWQgIiA8PCByYW5nZS5sZW4gPDwgIiBieXRlcyBvbiAiIDw8IHBhdGgKLSAgICAgICAgICAgICAgICAgICAgPDwgIiBpbiAiIDw8IG5hbm9zZWNvbmRzX3RvX21pbGxpc2Vjb25kcyh0aW1lKSA8PCAibXMiOworICAgICAgICAgICAgTE9HKElORk8pIDw8ICJUcmltbWVkICIgPDwgcmFuZ2UubGVuIDw8ICIgYnl0ZXMgb24gIiA8PCBwYXRoIDw8ICIgaW4gIgorICAgICAgICAgICAgICAgICAgICAgIDw8IG5hbm9zZWNvbmRzX3RvX21pbGxpc2Vjb25kcyh0aW1lKSA8PCAibXMiOwogICAgICAgICAgICAgZXh0cmFzLnB1dExvbmcoU3RyaW5nMTYoImJ5dGVzIiksIHJhbmdlLmxlbik7CiAgICAgICAgICAgICBleHRyYXMucHV0TG9uZyhTdHJpbmcxNigidGltZSIpLCB0aW1lKTsKICAgICAgICAgICAgIGlmIChsaXN0ZW5lcikgewpAQCAtMjIzLDggKzIyOCw4IEBACiAgICAgICAgIH0KIAogICAgICAgICBsay5sb2NrKCk7Ci0gICAgICAgIGFib3J0ZWQgPSBjdl9hYm9ydC53YWl0X2ZvcihsaywgMTBzLCBbXXsKLSAgICAgICAgICAgIHJldHVybiBpZGxlX21haW50X3N0YXQgPT0gSWRsZU1haW50U3RhdHM6OmtBYm9ydDt9KTsKKyAgICAgICAgYWJvcnRlZCA9CisgICAgICAgICAgICBjdl9hYm9ydC53YWl0X2ZvcihsaywgMTBzLCBbXSB7IHJldHVybiBpZGxlX21haW50X3N0YXQgPT0gSWRsZU1haW50U3RhdHM6OmtBYm9ydDsgfSk7CiAgICAgICAgIGxrLnVubG9jaygpOwogICAgIH0KIApAQCAtMjU3LDEwICsyNjIsMTAgQEAKICAgICByZXR1cm4gYW5kcm9pZDo6T0s7CiB9CiAKLXN0YXRpYyB2b2lkIHJ1bkRldkdjKHZvaWQpIHsKK3N0YXRpYyB2b2lkIHJ1bkRldkdjRnN0YWIodm9pZCkgewogICAgIHN0ZDo6dW5pcXVlX3B0cjxmc3RhYiwgZGVjbHR5cGUoJmZzX21ncl9mcmVlX2ZzdGFiKT4gZnN0YWIoZnNfbWdyX3JlYWRfZnN0YWJfZGVmYXVsdCgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnNfbWdyX2ZyZWVfZnN0YWIpOwotICAgIHN0cnVjdCBmc3RhYl9yZWMgKnJlYyA9IE5VTEw7CisgICAgc3RydWN0IGZzdGFiX3JlYyogcmVjID0gTlVMTDsKIAogICAgIGZvciAoaW50IGkgPSAwOyBpIDwgZnN0YWItPm51bV9lbnRyaWVzOyBpKyspIHsKICAgICAgICAgaWYgKGZzX21ncl9oYXNfc3lzZnNfcGF0aCgmZnN0YWItPnJlY3NbaV0pKSB7CkBAIC0yODQsNyArMjg5LDcgQEAKICAgICAgICAgICAgIFBMT0coV0FSTklORykgPDwgIlJlYWRpbmcgbWFudWFsX2djIGZhaWxlZCBpbiAiIDw8IHBhdGg7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQotCisgICAgICAgIHJlcXVpcmUgPSBhbmRyb2lkOjpiYXNlOjpUcmltKHJlcXVpcmUpOwogICAgICAgICBpZiAocmVxdWlyZSA9PSAiIiB8fCByZXF1aXJlID09ICJvZmYiIHx8IHJlcXVpcmUgPT0gImRpc2FibGVkIikgewogICAgICAgICAgICAgTE9HKERFQlVHKSA8PCAiTm8gbW9yZSB0byBkbyBEZXYgR0MiOwogICAgICAgICAgICAgYnJlYWs7CkBAIC0zMDksNiArMzE0LDU3IEBACiAgICAgcmV0dXJuOwogfQogCitjbGFzcyBHY0NhbGxiYWNrIDogcHVibGljIElHYXJiYWdlQ29sbGVjdENhbGxiYWNrIHsKKyAgcHVibGljOgorICAgIFJldHVybjx2b2lkPiBvbkZpbmlzaChSZXN1bHQgcmVzdWx0KSBvdmVycmlkZSB7CisgICAgICAgIHN0ZDo6dW5pcXVlX2xvY2s8c3RkOjptdXRleD4gbG9jayhtTXV0ZXgpOworICAgICAgICBtRmluaXNoZWQgPSB0cnVlOworICAgICAgICBtUmVzdWx0ID0gcmVzdWx0OworICAgICAgICBsb2NrLnVubG9jaygpOworICAgICAgICBtQ3Yubm90aWZ5X2FsbCgpOworICAgICAgICByZXR1cm4gVm9pZCgpOworICAgIH0KKyAgICB2b2lkIHdhaXQodWludDY0X3Qgc2Vjb25kcykgeworICAgICAgICBzdGQ6OnVuaXF1ZV9sb2NrPHN0ZDo6bXV0ZXg+IGxvY2sobU11dGV4KTsKKyAgICAgICAgbUN2LndhaXRfZm9yKGxvY2ssIHN0ZDo6Y2hyb25vOjpzZWNvbmRzKHNlY29uZHMpLCBbdGhpc10geyByZXR1cm4gbUZpbmlzaGVkOyB9KTsKKworICAgICAgICBpZiAoIW1GaW5pc2hlZCkgeworICAgICAgICAgICAgTE9HKFdBUk5JTkcpIDw8ICJEZXYgR0Mgb24gSEFMIHRpbWVvdXQiOworICAgICAgICB9IGVsc2UgaWYgKG1SZXN1bHQgIT0gUmVzdWx0OjpTVUNDRVNTKSB7CisgICAgICAgICAgICBMT0coV0FSTklORykgPDwgIkRldiBHQyBvbiBIQUwgZmFpbGVkIHdpdGggIiA8PCB0b1N0cmluZyhtUmVzdWx0KTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIExPRyhJTkZPKSA8PCAiRGV2IEdDIG9uIEhBTCBzdWNjZXNzZnVsIjsKKyAgICAgICAgfQorICAgIH0KKworICBwcml2YXRlOgorICAgIHN0ZDo6bXV0ZXggbU11dGV4OworICAgIHN0ZDo6Y29uZGl0aW9uX3ZhcmlhYmxlIG1DdjsKKyAgICBib29sIG1GaW5pc2hlZHtmYWxzZX07CisgICAgUmVzdWx0IG1SZ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S2V5KGJvb2wgY3JlYXRlX2lmX2Fic2VudCwgY29uc3Qgc3RkOjpzdHJpbmcmIGtleV9wYXRoLAotICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgdG1wX3BhdGgsIEtleUJ1ZmZlcioga2V5KSB7Citib29sIHJldHJpZXZlS2V5KGJvb2wgY3JlYXRlX2lmX2Fic2VudCwgY29uc3Qgc3RkOjpzdHJpbmcmIGtleV9wYXRoLCBjb25zdCBzdGQ6OnN0cmluZyYgdG1wX3BhdGgsCisgICAgICAgICAgICAgICAgIEtleUJ1ZmZlcioga2V5KSB7CiAgICAgaWYgKHBhdGhFeGlzdHMoa2V5X3BhdGgpKSB7CiAgICAgICAgIExPRyhERUJVRykgPDwgIktleSBleGlzdHMsIHVzaW5nOiAiIDw8IGtleV9wYXRoOwogICAgICAgICBpZiAoIXJldHJpZXZlS2V5KGtleV9wYXRoLCBrRW1wdHlBdXRoZW50aWNhdGlvbiwga2V5KSkgcmV0dXJuIGZhbHNlOwogICAgIH0gZWxzZSB7CiAgICAgICAgIGlmICghY3JlYXRlX2lmX2Fic2VudCkgewotICAgICAgICAgICBMT0coRVJST1IpIDw8ICJObyBrZXkgZm91bmQgaW4gIiA8PCBrZXlfcGF0aDsKLSAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiTm8ga2V5IGZvdW5kIGluICIgPDwga2V5X3BhdGg7CisgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgIH0KICAgICAgICAgTE9HKElORk8pIDw8ICJDcmVhdGluZyBuZXcga2V5IGluICIgPDwga2V5X3BhdGg7CiAgICAgICAgIGlmICghcmFuZG9tS2V5KGtleSkpIHJldHVybiBmYWxzZTsKLSAgICAgICAgaWYgKCFzdG9yZUtleUF0b21pY2FsbHkoa2V5X3BhdGgsIHRtcF9wYXRoLAotICAgICAgICAgICAgICAgIGtFbXB0eUF1dGhlbnRpY2F0aW9uLCA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xMiArMzYsMTMgQEAKICNpbmNsdWRlIDxjdXRpbHMvZnMuaD4KICNpbmNsdWRlIDxmc19tZ3IuaD4KIAorI2luY2x1ZGUgIkNoZWNrcG9pbnQuaCIKICNpbmNsdWRlICJFbmNyeXB0SW5wbGFjZS5oIgogI2luY2x1ZGUgIktleVN0b3JhZ2UuaCIKICNpbmNsdWRlICJLZXlVdGlsLmgiCi0jaW5jbHVkZSAic2Vjb250ZXh0LmgiCiAjaW5jbHVkZSAiVXRpbHMuaCIKICNpbmNsdWRlICJWb2xkVXRpbC5oIgorI2luY2x1ZGUgInNlY29udGV4dC5oIgogCiAjZGVmaW5lIERNX0NSWVBUX0JVRl9TSVpFIDQwOTYKICNkZWZpbmUgVEFCTEVfTE9BRF9SRVRSSUVTIDEwCkBAIC01OSw3ICs2MCw4IEBACiAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICB9CiAgICAgYXV0byBtb3VudF9yYyA9IGZzX21ncl9kb19tb3VudChmc3RhYl9kZWZhdWx0LCBjb25zdF9jYXN0PGNoYXIqPihtb3VudF9wb2ludCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdF9jYXN0PGNoYXIqPihibGtfZGV2aWNlKSwgbnVsbHB0cik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdF9jYXN0PGNoYXIqPihibGtfZGV2aWNlKSwgbnVsbHB0ciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuZHJvaWQ6OnZvbGQ6OmNwX25lZWRzQ2hlY2twb2ludCgpKTsKICAgICBpZiAoc2V0ZXhlY2NvbihudWxscHRyKSkgewogICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIGNsZWFyIHNldGV4ZWNjb24iOwogICAgICAgICByZXR1cm4gZmFsc2U7CkBAIC05OSwzMyArMTAxLDIyIEBACiAgICAgcmV0dXJuIHJlczsKIH0KIAotc3RhdGljIGJvb2wgZ2V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ldICsgIiAiOwogICAgICAgICBpZiAoaSA9PSAwKSB7Ci0gICAgICAgICAgICBMT0coVkVSQk9TRSkgPDwgYXJnc1tpXTsKKyAgICAgICAgICAgIExPRyhERUJVRykgPDwgYXJnc1tpXTsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIExPRyhWRVJCT1NFKSA8PCAiICAgICIgPDwgYXJnc1tpXTsKKyAgICAgICAgICAgIExPRyhERUJVRykgPDwgIiAgICAiIDw8IGFyZ3NbaV07CiAgICAgICAgIH0KICAgICB9CiAgICAgb3V0cHV0LmNsZWFyKCk7CkBAIC0zMTQsNyArMzE2LDcgQEAKICAgICAgICAgICAgIGFib3J0KCk7CiAgICAgICAgIH0KICAgICB9Ci0gICAgRklMRSogZnAgPSBwb3BlbihjbWQuY19zdHIoKSwgInIiKTsgLy8gTk9MSU5UCisgICAgRklMRSogZnAgPSBwb3BlbihjbWQuY19zdHIoKSwgInIiKTsgIC8vIE5PTElOVAogICAgIGlmIChjb250ZXh0KSB7CiAgICAgICAgIGlmIChzZXRleGVjY29uKG51bGxwdHIpKSB7CiAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gc2V0ZXhlY2NvbiI7CkBAIC0zMjgsNyArMzMwLDcgQEAKICAgICB9CiAgICAgY2hhciBsaW5lWzEwMjRdOwogICAgIHdoaWxlIChmZ2V0cyhsaW5lLCBzaXplb2YobGluZSksIGZwKSAhPSBudWxscHRyKSB7Ci0gICAgICAgIExPRyhWRVJCT1NFKSA8PCBsaW5lOworICAgICAgICBMT0coREVCVUcpIDw8IGxpbmU7CiAgICAgICAgIG91dHB1dC5wdXNoX2JhY2soc3RkOjpzdHJpbmcobGluZSkpOwogICAgIH0KICAgICBpZiAocGNsb3NlKGZwKSAhPSAwKSB7CkBAIC0zNDEsMTMgKzM0MywxMyBAQAogCiBwaWRfdCBGb3JrRXhlY3ZwQXN5bmMoY29uc3Qgc3RkOjp2ZWN0b3I8c3RkOjpzdHJpb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g4MDsgIC8qIHNldCB0byBJRVRGIHZhcmlhbnQgICovCisgICAgICAgIG91dFs2XSAmPSAweDBmOyAvKiBjbGVhciB2ZXJzaW9uICAgICAgICAqLworICAgICAgICBvdXRbNl0gfD0gMHg0MDsgLyogc2V0IHRvIHZlcnNpb24gNCAgICAgKi8KKyAgICAgICAgb3V0WzhdICY9IDB4M2Y7IC8qIGNsZWFyIHZhcmlhbnQgICAgICAgICovCisgICAgICAgIG91dFs4XSB8PSAweDgwOyAvKiBzZXQgdG8gSUVURiB2YXJpYW50ICAqLwogICAgIH0KICAgICByZXR1cm4gcmVzOwogfQpAQCAtNDE1LDI0ICs0MTcsMjYgQEAKICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IGhleC5zaXplKCk7IGkrKykgewogICAgICAgICBpbnQgdmFsID0gMDsKICAgICAgICAgc3dpdGNoIChoZXhbaV0pIHsKLSAgICAgICAgY2FzZSAnICc6IGNhc2UgJy0nOiBjYXNlICc6JzogY29udGludWU7Ci0gICAgICAgIGNhc2UgJ2YnOiBjYXNlICdGJzogdmFsID0gMTU7IGJyZWFrOwotICAgICAgICBjYXNlICdlJzogY2FzZSAnRSc6IHZhbCA9IDE0OyBicmVhazsKLSAgICAgICAgY2FzZSAnZCc6IGNhc2UgJ0QnOiB2YWwgPSAxMzsgYnJlYWs7Ci0gICAgICAgIGNhc2UgJ2MnOiBjYXNlICdDJzogdmFsID0gMTI7IGJyZWFrOwotICAgICAgICBjYXNlICdiJzogY2FzZSAnQic6IHZhbCA9IDExOyBicmVhazsKLSAgICAgICAgY2FzZSAnYSc6IGNhc2UgJ0EnOiB2YWwgPSAxMDsgYnJlYWs7Ci0gICAgICAgIGNhc2UgJzknOiB2YWwgPSA5OyBicmVhazsKLSAgICAgICAgY2FzZSAnOCc6IHZhbCA9IDg7IGJyZWFrOwotICAgICAgICBjYXNlICc3JzogdmFsID0gNzsgYnJlYWs7Ci0gICAgICAgIGNhc2UgJzYnOiB2YWwgPSA2OyBicmVhazsKLSAgICAgICAgY2FzZSAnNSc6IHZhbCA9IDU7IGJyZWFrOwotICAgICAgICBjYXNlICc0JzogdmFsID0gNDsgYnJlYWs7Ci0gICAgICAgIGNhc2UgJzMnOiB2YWwgPSAzOyBicmVhazsKLSAgICAgICAgY2FzZSAnMic6IHZhbCA9IDI7IGJyZWFrOwotICAgICAgICBjYXNlICcxJzogdmFsID0gMTsgYnJlYWs7Ci0gICAgICAgIGNhc2UgJzAnOiB2YWwgPSAwOyBicmVhazsKLSAgICAgICAgZGVmYXVsdDogcmV0dXJuIC1FSU5WQUw7CisgICAgICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb2ZmCisgICAgICAgICAgICBjYXNlICcgJzogY2FzZSAnLSc6IGNhc2UgJzonOiBjb250aW51ZTsKKyAgICAgICAgICAgIGNhc2UgJ2YnOiBjYXNlICdGJzogdmFsID0gMTU7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnZSc6IGNhc2UgJ0UnOiB2YWwgPSAxNDsgYnJlYWs7CisgICAgICAgICAgICBjYXNlICdkJzogY2FzZSAnRCc6IHZhbCA9IDEzOyBicmVhazsKKyAgICAgICAgICAgIGNhc2UgJ2MnOiBjYXNlICdDJzogdmFsID0gMTI7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnYic6IGNhc2UgJ0InOiB2YWwgPSAxMTsgYnJlYWs7CisgICAgICAgICAgICBjYXNlICdhJzogY2FzZSAnQSc6IHZhbCA9IDEwOyBicmVhazsKKyAgICAgICAgICAgIGNhc2UgJzknOiB2YWwgPSA5OyBicmVhazsKKyAgICAgICAgICAgIGNhc2UgJzgnOiB2YWwgPSA4OyBicmVhazsKKyAgICAgICAgICAgIGNhc2UgJzcnOiB2YWwgPSA3OyBicmVhazsKKyAgICAgICAgICAgIGNhc2UgJzYnOiB2YWwgPSA2OyBicmVhazsKKyAgICAgICAgICAgIGNhc2UgJzUnOiB2YWwgPSA1OyBicmVhazsKKyAgICAgICAgICAgIGNhc2UgJzQnOiB2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RfdCBjYWxjdWxhdGVfZGlyX3NpemUoaW50IGRmZCkgewogICAgIGludDY0X3Qgc2l6ZSA9IDA7CiAgICAgc3RydWN0IHN0YXQgczsKLSAgICBESVIgKmQ7Ci0gICAgc3RydWN0IGRpcmVudCAqZGU7CisgICAgRElSKiBkOworICAgIHN0cnVjdCBkaXJlbnQqIGRlOwogCiAgICAgZCA9IGZkb3BlbmRpcihkZmQpOwogICAgIGlmIChkID09IE5VTEwpIHsKQEAgLTUxNCw3ICs1NTQsNyBAQAogICAgIH0KIAogICAgIHdoaWxlICgoZGUgPSByZWFkZGlyKGQpKSkgewotICAgICAgICBjb25zdCBjaGFyICpuYW1lID0gZGUtPmRfbmFtZTsKKyAgICAgICAgY29uc3QgY2hhciogbmFtZSA9IGRlLT5kX25hbWU7CiAgICAgICAgIGlmIChmc3RhdGF0KGRmZCwgbmFtZSwgJnMsIEFUX1NZTUxJTktfTk9GT0xMT1cpID09IDApIHsKICAgICAgICAgICAgIHNpemUgKz0gc3RhdF9zaXplKCZzKTsKICAgICAgICAgfQpAQCAtNTIzLDEwICs1NjMsOCBAQAogCiAgICAgICAgICAgICAvKiBhbHdheXMgc2tpcCAiLiIgYW5kICIuLiIgKi8KICAgICAgICAgICAgIGlmIChuYW1lWzBdID09ICcuJykgewotICAgICAgICAgICAgICAgIGlmIChuYW1lWzFdID09IDApCi0gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwotICAgICAgICAgICAgICAgIGlmICgobmFtZVsxXSA9PSAnLicpICYmIChuYW1lWzJdID09IDApKQotICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAgICBpZiAobmFtZVsxXSA9PSAwKSBjb250aW51ZTsKKyAgICAgICAgICAgICAgICBpZiAoKG5hbWVbMV0gPT0gJy4nKSAmJiAobmFtZVsyXSA9PSAwKSkgY29udGludWU7CiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIHN1YmZkID0gb3BlbmF0KGRmZCwgbmFtZSw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3QgVW5tb3VudFRyZWUoY29uc3Qgc3RkOjpzdHJpbmcmIHByZWZpeCkgeworICAgIEZJTEUqIGZwID0gc2V0bW50ZW50KCIvcHJvYy9tb3VudHMiLCAiciIpOworICAgIGlmIChmcCA9PSBOVUxMKSB7CisgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gb3BlbiAvcHJvYy9tb3VudHMiOworICAgICAgICByZXR1cm4gLWVycm5vOworICAgIH0KKworICAgIC8vIFNvbWUgdm9sdW1lcyBjYW4gYmUgc3RhY2tlZCBvbiBlYWNoIG90aGVyLCBzbyBmb3JjZSB1bm1vdW50IGluCisgICAgLy8gcmV2ZXJzZSBvcmRlciB0byBnaXZlIHVzIHRoZSBiZXN0IGNoYW5jZSBvZiBzdWNjZXNzLgorICAgIHN0ZDo6bGlzdDxzdGQ6OnN0cmluZz4gdG9Vbm1vdW50OworICAgIG1udGVudCogbWVudHJ5OworICAgIHdoaWxlICgobWVudHJ5ID0gZ2V0bW50ZW50KGZwKSkgIT0gTlVMTCkgeworICAgICAgICBhdXRvIHRlc3QgPSBzdGQ6OnN0cmluZyhtZW50cnktPm1udF9kaXIpICsgIi8iOworICAgICAgICBpZiAoYW5kcm9pZDo6YmFzZTo6U3RhcnRzV2l0aCh0ZXN0LCBwcmVmaXgpKSB7CisgICAgICAgICAgICB0b1VubW91bnQucHVzaF9mcm9udCh0ZXN0KTsKKyAgICAgICAgfQorICAgIH0KKyAgICBlbmRtbnRlbnQoZnApOworCisgICAgZm9yIChjb25zdCBhdXRvJiBwYXRoIDogdG9Vbm1vdW50KSB7CisgICAgICAgIGlmICh1bW91bnQyKHBhdGguY19zdHIoKSwgTU5UX0RFVEFDSCkpIHsKKyAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gdW5tb3VudCAiIDw8IHBhdGg7CisgICAgICAgIH0KKyAgICB9CisgICAgcmV0dXJuIE9LOworfQorCiB9ICAvLyBuYW1lc3BhY2Ugdm9sZA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gICAgICAgIHJldHVybiBvaygpOwogICAgIH0gZWxzZSB7CiAgICAgICAgIHJldHVybiBleGNlcHRpb24oYmluZGVyOjpTdGF0dXM6OkVYX1NFQ1VSSVRZLAotICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiVUlEICVkIC8gUElEICVkIGxhY2tzIHBlcm1pc3Npb24gJXMiLCB1aWQsIHBpZCwgcGVybWlzc2lvbikpOworICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiVUlEICVkIC8gUElEICVkIGxhY2tzIHBlcm1pc3Npb24gJXMiLCB1aWQsIHBpZCwgcGVybWlzc2lvbikpOwogICAgIH0KIH0KIApAQCAtOTcsNyArOTgsNyBAQAogICAgICAgICByZXR1cm4gb2soKTsKICAgICB9IGVsc2UgewogICAgICAgICByZXR1cm4gZXhjZXB0aW9uKGJpbmRlcjo6U3RhdHVzOjpFWF9TRUNVUklUWSwKLSAgICAgICAgICAgICAgICBTdHJpbmdQcmludGYoIlVJRCAlZCBpcyBub3QgZXhwZWN0ZWQgVUlEICVkIiwgdWlkLCBleHBlY3RlZFVpZCkpOworICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiVUlEICVkIGlzIG5vdCBleHBlY3RlZCBVSUQgJWQiLCB1aWQsIGV4cGVjdGVkVWlkKSk7CiAgICAgfQogfQogCkBAIC0xMDgsNyArMTA5LDcgQEAKICAgICBmb3IgKGNvbnN0IGNoYXImIGMgOiBpZCkgewogICAgICAgICBpZiAoIXN0ZDo6aXNhbG51bShjKSAmJiBjICE9ICc6JyAmJiBjICE9ICcsJykgewogICAgICAgICAgICAgcmV0dXJuIGV4Y2VwdGlvbihiaW5kZXI6OlN0YXR1czo6RVhfSUxMRUdBTF9BUkdVTUVOVCwKLSAgICAgICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJJRCAlcyBpcyBtYWxmb3JtZWQiLCBpZC5jX3N0cigpKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiSUQgJXMgaXMgbWFsZm9ybWVkIiwgaWQuY19zdHIoKSkpOwogICAgICAgICB9CiAgICAgfQogICAgIHJldHVybiBvaygpOwpAQCAtMTIwLDE2ICsxMjEsMTYgQEAKICAgICB9CiAgICAgaWYgKHBhdGhbMF0gIT0gJy8nKSB7CiAgICAgICAgIHJldHVybiBleGNlcHRpb24oYmluZGVyOjpTdGF0dXM6OkVYX0lMTEVHQUxfQVJHVU1FTlQsCi0gICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJQYXRoICVzIGlzIHJlbGF0aXZlIiwgcGF0aC5jX3N0cigpKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJQYXRoICVzIGlzIHJlbGF0aXZlIiwgcGF0aC5jX3N0cigpKSk7CiAgICAgfQogICAgIGlmICgocGF0aCArICcvJykuZmluZCgiLy4uLyIpICE9IHN0ZDo6c3RyaW5nOjpucG9zKSB7CiAgICAgICAgIHJldHVybiBleGNlcHRpb24oYmluZGVyOjpTdGF0dXM6OkVYX0lMTEVHQUxfQVJHVU1FTlQsCi0gICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJQYXRoICVzIGlzIHNoYWR5IiwgcGF0aC5jX3N0cigpKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJQYXRoICVzIGlzIHNoYWR5IiwgcGF0aC5jX3N0cigpKSk7CiAgICAgfQogICAgIGZvciAoY29uc3QgY2hhciYgYyA6IHBhdGgpIHsKICAgICAgICAgaWYgKGMgPT0gJ1wwJyB8fCBjID09ICdcbicpIHsKICAgICAgICAgICAgIHJldHVybiBleGNlcHRpb24oYmluZGVyOjpTdGF0dXM6OkVYX0lMTEVHQUxfQVJHVU1FTlQsCi0gICAgICAgICAgICAgICAgICAgIFN0cmluZ1ByaW50ZigiUGF0aCAlcyBpcyBtYWxmb3JtZWQiLCBwYXRoLmNfc3RyKCkpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nUHJpbnRmKCJQYXRoICVzIGlzIG1hbGZvcm1lZCIsIHBhdGguY19zdHIoKSkpOwogICAgICAgICB9CiAgICAgfQogICAgIHJldHVybiBvaygpOwpAQCAtMTQwLDQ1ICsxNDEsNDkgQEAKICAgICBmb3IgKGNvbnN0IGNoYXImIGMgOiBoZXgpIHsKICAgICAgICAgaWYgKCFzdGQ6OmlzeGRpZ2l0KGMpICYmIGMgIT0gJzonICYmIGMgIT0gJy0nKSB7CiAgICAgICAgICAgICByZXR1cm4gZXhjZXB0aW9uKGJpbmRlcjo6U3RhdHVzOjpFWF9JTExFR0FMX0FSR1VNRU5ULAotICAgICAgICAgICAgICAgICAgICBTdHJpbmdQcmludGYoIkhleCAlcyBpcyBtYWxmb3JtZWQiLCBoZXguY19zdHIoKSkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmdQcmludGYoIkhleCAlcyBpcyBtYWxmb3JtZWQiLCBoZXguY19zdHIoKSkpOwogICAgICAgICB9CiAgICAgfQogICAgIHJldHVybiBvaygpOwogfQogCi0jZGVmaW5lIEVORk9SQ0VfVUlEKHVpZCkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gY2hlY2tVaWQoKHVpZCkpOyAgICAgICAgICAgICAgICBcCi0gICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgIHJldHVybiBzdGF0dXM7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi19CisjZGVmaW5lIEVORk9SQ0VfVUlEKHVpZCkgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gY2hlY2tVaWQoKHVpZCkpOyBcCisgICAgICAgIGlmICghc3RhdHVzLmlzT2soKSkgeyAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICAgICAgcmV0dXJuIHN0YXR1czsgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgfQogCi0jZGVmaW5lIENIRUNLX0FSR1VNRU5UX0lEKGlkKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gY2hlY2tBcmd1bWVudElkKChpZCkpOyAgICAgICAgICBcCi0gICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgIHJldHVybiBzdGF0dXM7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi19CisjZGVmaW5lIENIRUNLX0FSR1VNRU5UX0lEKGlkKSAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gY2hlY2tBcmd1bWVudElkKChpZCkpOyBcCisgICAgICAgIGlmICghc3RhdHVzLmlzT2soKSkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICAgICAgcmV0dXJuIHN0YXR1czsgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgfQogCi0jZGVmaW5lIENIRUNLX0FSR1VNRU5UX1BBVEgocGF0aCkgeyAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gY2hlY2tBcmd1bWVudFBhdGgoKHBhdGgpKTsgICAgICBcCi0gICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgIHJldHVybiBzdGF0dXM7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi19CisjZGVmaW5lIENIRUNLX0FSR1VNRU5UX1BBVEgocGF0aCkgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICBiaW5kZXI6OlN0YXR1cyBzdGF0dXMgPSBjaGVja0FyZ3VtZW50UGF0aCgocGF0aCkpOyBcCisgICAgICAgIGlmICghc3RhdHVzLmlzT2soKSkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgIHJldHVybiBzdGF0dXM7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICB9ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgfQogCi0jZGVmaW5lIENIRUNLX0FSR1VNRU5UX0hFWChoZXgpIHsgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gY2hlY2tBcmd1bWVudEhleCgoaGV4KSk7ICAgICAgICBcCi0gICAgaWYgKCFzdGF0dXMuaXNPaygpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgIHJldHVybiBzdGF0dXM7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi19CisjZGVmaW5lIENIRUNLX0FSR1VNRU5UX0hFWChoZXgpICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIGJpbmRlcjo6U3RhdHVzIHN0YXR1cyA9IGNoZWNrQXJndW1lbnRIZXgoKGhleCkpOyBcCisgICAgICAgIGlmICghc3RhdHVzLmlzT2soKSkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgICAgICByZXR1cm4gc3RhdHVzOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIH0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgfQogCi0jZGVmaW5lIEFDUVVJUkVfTE9DSyBcCisjZGVmaW5lIEFDUVVJUkVfTE9DSyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAogICAgIHN0ZDo6bG9ja19ndWFyZDxzdGQ6Om11dGV4PiBsb2NrKFZvbHVtZU1hbmFnZXI6Okluc3RhbmNlKCktPmdldExvY2soKSk7IFwKICAgICBBVFJBQ0VfQ0FMTCgpOwogCi0jZGVmaW5lIEFDUVVJUkVfQ1JZUFRfTE9DSyBcCisjZGVmaW5lIEFDUVVJUkVfQ1JZUFRfTE9DSyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgc3RkOjpsb2NrX2d1YXJkPHN0ZDo6bXV0ZXg+IGxvY2soVm9sdW1lTWFuYWdlcjo6SW5zdGFuY2UoKS0+Z2V0Q3J5cHRMb2NrKCkpOyBcCiAgICAgQVRSQUNFX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BQQVJUSVRJT05fVFlQRV9QVUJMSUM6CisgICAgICAgICAgICByZXR1cm4gdHJhbnNsYXRlKGRpc2stPnBhcnRpdGlvblB1YmxpYygpKTsKKyAgICAgICAgY2FzZSBQQVJUSVRJT05fVFlQRV9QUklWQVRFOgorICAgICAgICAgICAgcmV0dXJuIHRyYW5zbGF0ZShkaXNrLT5wYXJ0aXRpb25Qcml2YXRlKCkpOworICAgICAgICBjYXNlIFBBUlRJVElPTl9UWVBFX01JWEVEOgorICAgICAgICAgICAgcmV0dXJuIHRyYW5zbGF0ZShkaXNrLT5wYXJ0aXRpb25NaXhlZChyYXRpbykpOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgcmV0dXJuIGVycm9yKCJVbmtub3duIHR5cGUgIiArIHN0ZDo6dG9fc3RyaW5nKHBhcnRpdGlvblR5cGUpKTsKICAgICB9CiB9CiAKIGJpbmRlcjo6U3RhdHVzIFZvbGROYXRpdmVTZXJ2aWNlOjpmb3JnZXRQYXJ0aXRpb24oY29uc3Qgc3RkOjpzdHJpbmcmIHBhcnRHdWlkLAotICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgZnNVdWlkKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nJiBmc1V1aWQpIHsKICAgICBFTkZPUkNFX1VJRChBSURfU1lTVEVNKTsKICAgICBDSEVDS19BUkdVTUVOVF9IRVgocGFydEd1aWQpOwogICAgIENIRUNLX0FSR1VNRU5UX0hFWChmc1V1aWQpOwpAQCAtMzExLDcgKzMxNiw3IEBACiB9CiAKIGJpbmRlcjo6U3RhdHVzIFZvbGROYXRpdmVTZXJ2aWNlOjptb3VudChjb25zdCBzdGQ6OnN0cmluZyYgdm9sSWQsIGludDMyX3QgbW91bnRGbGFncywKLSAgICAgICAgaW50MzJfdCBtb3VudFVzZXJJZCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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W50TW9kZSkpOworICAgICAgICBjYXNlIFJFTU9VTlRfTU9ERV9OT05FOgorICAgICAgICAgICAgdG1wID0gIm5vbmUiOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgUkVNT1VOVF9NT0RFX0RFRkFVTFQ6CisgICAgICAgICAgICB0bXAgPSAiZGVmYXVsdCI7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBSRU1PVU5UX01PREVfUkVBRDoKKyAgICAgICAgICAgIHRtcCA9ICJyZWFkIjsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFJFTU9VTlRfTU9ERV9XUklURToKKyAgICAgICAgICAgIHRtcCA9ICJ3cml0ZSI7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIHJldHVybiBlcnJvcigiVW5rbm93biBtb2RlICIgKyBzdGQ6OnRvX3N0cmluZyhyZW1vdW50TW9kZSkpOwogICAgIH0KICAgICByZXR1cm4gdHJhbnNsYXRlKFZvbHVtZU1hbmFnZXI6Okluc3RhbmNlKCktPnJlbW91bnRVaWQodWlkLCB0bXApKTsKIH0KQEAgLTQ0OSwxNCArNDYwLDE1IEBACiB9CiAKIGJpbmRlcjo6U3RhdHVzIFZvbGROYXRpdmVTZXJ2aWNlOjpjcmVhdGVPYmIoY29uc3Qgc3RkOjpzdHJpbmcmIHNvdXJjZVBhdGgsCi0gICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nJiBzb3VyY2VLZXksIGludDMyX3Qgb3duZXJHaWQsIHN0ZDo6c3RyaW5nKiBfYWlkbF9yZXR1cm4pIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIHNvdXJjZUtleSwgaW50MzJfdCBvd25lckdpZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjpzdHJpbmcqIF9haWRs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NlOjpjcmVhdGVVc2VyS2V5KGludDMyX3QgdXNlcklkLCBpbnQzMl90IHVzZXJTZXJpYWwsIGJvb2wgZXBoZW1lcmFsKSB7CiAgICAgRU5GT1JDRV9VSUQoQUlEX1NZU1RFTSk7CiAgICAgQUNRVUlSRV9DUllQVF9MT0NLOwogCkBAIC03MDgsNyArNzExLDggQEAKIH0KIAogYmluZGVyOjpTdGF0dXMgVm9sZE5hdGl2ZVNlcnZpY2U6OmFkZFVzZXJLZXlBdXRoKGludDMyX3QgdXNlcklkLCBpbnQzMl90IHVzZXJTZXJpYWwsCi0gICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nJiB0b2tlbiwgY29uc3Qgc3RkOjpzdHJpbmcmIHNlY3JldCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nJiB0b2tlbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgc2VjcmV0KSB7CiAgICAgRU5GT1JDRV9VSUQoQUlEX1NZU1RFTSk7CiAgICAgQUNRVUlSRV9DUllQVF9MT0NLOwogCkBAIC03MjMsNyArNzI3LDggQEAKIH0KIAogYmluZGVyOjpTdGF0dXMgVm9sZE5hdGl2ZVNlcnZpY2U6OnVubG9ja1VzZXJLZXkoaW50MzJfdCB1c2VySWQsIGludDMyX3QgdXNlclNlcmlhbCwKLSAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIHRva2VuLCBjb25zdCBzdGQ6OnN0cmluZyYgc2VjcmV0KSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgdG9rZW4sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgc2VjcmV0KSB7CiAgICAgRU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worICAgIEFDUVVJUkVfTE9DSzsKKworICAgICpfYWlkbF9yZXR1cm4gPSBjcF9jb21taXRDaGFuZ2VzKCk7CisgICAgcmV0dXJuIG9rKCk7Cit9CisKK2JpbmRlcjo6U3RhdHVzIFZvbGROYXRpdmVTZXJ2aWNlOjpwcmVwYXJlRHJpdmVGb3JDaGVja3BvaW50KGNvbnN0IHN0ZDo6c3RyaW5nJiBtb3VudFBvaW50LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCogX2FpZGxfcmV0dXJuKSB7CisgICAgRU5GT1JDRV9VSUQoQUlEX1NZU1RFTSk7CisgICAgQ0hFQ0tfQVJHVU1FTlRfUEFUSChtb3VudFBvaW50KTsKKyAgICBBQ1FVSVJFX0xPQ0s7CisKKyAgICAqX2FpZGxfcmV0dXJuID0gY3BfcHJlcGFyZURyaXZlRm9yQ2hlY2twb2ludChtb3VudFBvaW50KTsKKyAgICByZXR1cm4gb2soKTsKK30KKworYmluZGVyOjpTdGF0dXMgVm9sZE5hdGl2ZVNlcnZpY2U6OnJlc3RvcmVDaGVja3BvaW50KGNvbnN0IHN0ZDo6c3RyaW5nJiBtb3VudFBvaW50LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wqIF9haWRsX3JldHVybikgeworICAgIEVORk9SQ0VfVUlEKEFJRF9TWVNURU0pOworICAgIENIRUNLX0FSR1VNRU5UX1BBVEgobW91bnRQb2ludCk7CisgICAgQUNRVUlSRV9MT0NLOworCisgICAgKl9haWRsX3JldHVybiA9IGNwX3Jlc3RvcmVDaGVja3BvaW50KG1vdW50UG9pbnQpOworICAgIHJldHVybiBvaygpOworfQorCitiaW5kZXI6OlN0YXR1cyBWb2xkTmF0aXZlU2VydmljZTo6bWFya0Jvb3RBdHRlbXB0KGJvb2wqIF9haWRsX3JldHVybikgeworICAgIEVORk9SQ0VfVUlEKEFJRF9TW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3RkOjpzdHJpbmcgZGV2VHlwZShldnQtPmZpbmRQYXJhbSgiREVWVFlQRSIpID8gZXZ0LT5maW5kUGFyYW0oIkRFVlRZUEUiKSA6ICIiKTsKIAogICAgIGlmIChkZXZUeXBlICE9ICJkaXNrIikgcmV0dXJuOwogCkBAIC0xOTIsNDMgKzE5Miw0MiBAQAogICAgIGRldl90IGRldmljZSA9IG1ha2VkZXYobWFqb3IsIG1pbm9yKTsKIAogICAgIHN3aXRjaCAoZXZ0LT5nZXRBY3Rpb24oKSkgewotICAgIGNhc2UgTmV0bGlua0V2ZW50OjpBY3Rpb246OmtBZGQ6IHsKLSAgICAgICAgZm9yIChjb25zdCBhdXRvJiBzb3VyY2UgOiBtRGlza1NvdXJjZXMpIHsKLSAgICAgICAgICAgIGlmIChzb3VyY2UtPm1hdGNoZXMoZXZlbnRQYXRoKSkgewotICAgICAgICAgICAgICAgIC8vIEZvciBub3csIGFzc3VtZSB0aGF0IE1NQyBhbmQgdmlydGlvLWJsayAodGhlIGxhdHRlciBpcwotICAgICAgICAgICAgICAgIC8vIGVtdWxhdG9yLXNwZWNpZmljOyBzZWUgRGlzay5jcHAgZm9yIGRldGFpbHMpIGRldmljZXMgYXJlIFNELAotICAgICAgICAgICAgICAgIC8vIGFuZCB0aGF0IGV2ZXJ5dGhpbmcgZWxzZSBpcyBVU0IKLSAgICAgICAgICAgICAgICBpbnQgZmxhZ3MgPSBzb3VyY2UtPmdldEZsYWdzKCk7Ci0gICAgICAgICAgICAgICAgaWYgKG1ham9yID09IGtNYWpvckJsb2NrTW1jCi0gICAgICAgICAgICAgICAgICAgIHx8IChhbmRyb2lkOjp2b2xkOjpJc1J1bm5pbmdJbkVtdWxhdG9yKCkKLSAgICAgICAgICAgICAgICAgICAgJiYgbWFqb3IgPj0gKGludCkga01ham9yQmxvY2tFeHBlcmltZW50YWxNaW4KLSAgICAgICAgICAgICAgICAgICAgJiYgbWFqb3IgPD0gKGludCkga01ham9yQmxvY2tFeHBlcmltZW50YWxNYXgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGZsYWdzIHw9IGFuZHJvaWQ6OnZvbGQ6OkRpc2s6OkZsYWdzOjprU2Q7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgZmxhZ3MgfD0gYW5kcm9pZDo6dm9sZDo6RGlzazo6RmxhZ3M6OmtVc2I7Ci0gICAgICAgICAgICAgICAgfQorICAgICAgICBjYXNlIE5ldGxpbmtFdmVudDo6QWN0aW9uOjprQWRkOiB7CisgICAgICAgICAgICBmb3IgKGNvbnN0IGF1dG8mIHNvdXJjZSA6IG1EaXNrU291cmNlcykgeworICAgICAgICAgICAgICAgIGlmIChzb3VyY2UtPm1hdGNoZXMoZXZlbnRQYXRoKSkgeworICAgICAgICAgICAgICAgICAgICAvLyBGb3Igbm93LCBhc3N1bWUgdGhhdCBNTUMgYW5kIHZpcnRpby1ibGsgKHRoZSBsYXR0ZXIgaXMKKyAgICAgICAgICAgICAgICAgICAgLy8gZW11bGF0b3Itc3BlY2lmaWM7IHNlZSBEaXNrLmNwcCBmb3IgZGV0YWlscykgZGV2aWNlcyBhcmUgU0QsCisgICAgICAgICAgICAgICAgICAgIC8vIGFuZCB0aGF0IGV2ZXJ5dGhpbmcgZWxzZSBpcyBVU0IKKyAgICAgICAgICAgICAgICAgICAgaW50IGZsYWdzID0gc291cmNlLT5nZXRGbGFncygpOworICAgICAgICAgICAgICAgICAgICBpZiAobWFqb3IgPT0ga01ham9yQmxvY2tNbWMgfHwgKGFuZHJvaWQ6OnZvbGQ6OklzUnVubmluZ0luRW11bGF0b3IoKSAmJgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ham9yID49IChpbnQpa01ham9yQmxvY2tFeHBlcmltZW50YWxNaW4gJiYKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYWpvciA8PSAoaW50KWtNYWpvckJsb2NrRXhwZXJpbWVudGFsTWF4KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgZmxhZ3MgfD0gYW5kcm9pZDo6dm9sZDo6RGlzazo6RmxhZ3M6OmtTZDsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZsYWdzIHw9IGFuZHJvaWQ6OnZvbGQ6OkRpc2s6OkZsYWdzOjprVXNiOworICAgICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBhdXRvIGRpc2sgPSBuZXcgYW5kcm9pZDo6dm9sZDo6RGlzayhldmVudFBhdGgsIGRldmljZSwKLSAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZS0+Z2V0Tmlja25hbWUoKSwgZmxhZ3MpOwotICAgICAgICAgICAgICAgIGhhbmRsZURpc2tBZGRlZChzdGQ6OnNoYXJlZF9wdHI8YW5kcm9pZDo6dm9sZDo6RGlzaz4oZGlzaykpOwotICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBhdXRvIGRpc2sgPQorICAgICAgICAgICAgICAgICAgICAgICAgbmV3IGFuZHJvaWQ6OnZvbGQ6OkRpc2soZXZlbnRQYXRoLCBkZXZpY2UsIHNvdXJjZS0+Z2V0Tmlja25hbWUoKSwgZmxhZ3MpOworICAgICAgICAgICAgICAgICAgICBoYW5kbGVEaXNrQWRkZWQoc3RkOjpzaGFyZWRfcHRyPGFuZHJvaWQ6OnZvbGQ6OkRpc2s+KGRpc2spKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQorICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KLSAgICAgICAgYnJlYWs7Ci0gICAgfQotICAgIGNhc2UgTmV0bGlua0V2ZW50OjpBY3Rpb246OmtDaGFuZ2U6IHsKLSAgICAgICAgTE9HKERFQlVHKSA8PCAiRGlzayBhdCAiIDw8IG1ham9yIDw8ICI6IiA8PCBtaW5vciA8PCAiIGNoYW5nZWQiOwotICAgICAgICBoYW5kbGVEaXNrQ2hhbmdlZChkZXZpY2UpOwotICAgICAgICBicmVhazsKLSAgICB9Ci0gICAgY2FzZSBOZXRsaW5rRXZlbnQ6OkFjdGlvbjo6a1JlbW92ZTogewotICAgICAgICBoYW5kbGVEaXNrUmVtb3ZlZChkZXZpY2UpOwotICAgICAgICBicmVhazsKLSAgICB9Ci0gICAgZGVmYXVsdDogewotICAgICAgICBMT0coV0FSTklORykgPDwgIlVuZXhwZWN0ZWQgYmxvY2sgZXZlbnQgYWN0aW9uICIgPDwgKGludCkgZXZ0LT5nZXRBY3Rpb24oKTsKLSAgICAgICAgYnJlYWs7Ci0gICAgfQorICAgICAgICBjYXNlIE5ldGxpbmtFdmVudDo6QWN0aW9uOjprQ2hhbmdlOiB7CisgICAgICAgICAgICBMT0coREVCVUcpIDw8ICJEaXNrIGF0ICIgPDwgbWFqb3IgPDwgIjoiIDw8IG1pbm9yIDw8ICIgY2hhbmdlZCI7CisgICAgICAgICAgICBoYW5kbGVEaXNrQ2hhbmdlZChkZXZpY2UpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBOZXRsaW5rRXZlbnQ6OkFjdGlvbjo6a1JlbW92ZTogeworICAgICAgICAgICAgaGFuZGxlRGlza1JlbW92ZWQoZGV2aWNlKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGRlZmF1bHQ6IHsKKyAgICAgICAgICAgIExPRyhXQVJOSU5HKSA8PCAiVW5leHBlY3RlZCBibG9jayBldmVudCBhY3Rpb24gIiA8PCAoaW50KWV2dC0+Z2V0QWN0aW9uKCk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQogICAgIH0KIH0KIApAQCAtMjM3LDcgKzIzNiw3IEBACiAgICAgLy8gdW50aWwgdGhlIHVzZXIgdW5sb2NrcyB0aGUgZGV2aWNlIHR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vc3RvcmFnZSIsCi0gICAgICAgICAgICAgICAgICAgIE5VTEwsIE1TX0JJTkQgfCBNU19SRUMsIE5VTEwpKSA9PSAtMSkgewotICAgICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gbW91bnQgIiA8PCBzdG9yYWdlU291cmNlIDw8ICIgZm9yICIKLSAgICAgICAgICAgICAgICAgICAgICAgIDw8IGRlLT5kX25hbWU7CisgICAgICAgICAgICBpZiAoVEVNUF9GQUlMVVJFX1JFVFJZKAorICAgICAgICAgICAgICAgICAgICBtb3VudChzdG9yYWdlU291cmNlLmNfc3RyKCksICIvc3RvcmFnZSIsIE5VTEwsIE1TX0JJTkQgfCBNU19SRUMsIE5VTEwpKSA9PSAtMSkgeworICAgICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gbW91bnQgIiA8PCBzdG9yYWdlU291cmNlIDw8ICIgZm9yICIgPDwgZGUtPmRfbmFtZTsKICAgICAgICAgICAgICAgICBfZXhpdCgxKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChURU1QX0ZBSUxVUkVfUkVUUlkobW91bnQoTlVMTCwgIi9zdG9yYWdlIiwgTlVMTCwKLSAgICAgICAgICAgICAgICAgICAgTVNfUkVDIHwgTVNfU0xBVkUsIE5VTEwpKSA9PSAtMSkgewotICAgICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gc2V0IE1TX1NMQVZFIHRvIC9zdG9yYWdlIGZvciAiCi0gICAgICAgICAgICAgICAgICAgICAgICA8PCBkZS0+ZF9uYW1lOworICAgICAgICAgICAgaWYgKFRFTVBfRkFJTFVSRV9SRVRSWShtb3VudChOVUxMLCAiL3N0b3JhZ2UiLCBOVUxMLCBNU19SRUMgfCBNU19TTEFWRSwgTlVMTCkpID09IC0xKSB7CisgICAgICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBzZXQgTVNfU0xBVkUgdG8gL3N0b3JhZ2UgZm9yICIgPDwgZGUtPmRfbmFtZTsKICAgICAgICAgICAgICAgICBfZXhpdCgxKTsKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgLy8gTW91bnQgdXNlci1zcGVjaWZpYyBzeW1saW5rIGhlbHBlciBpbnRvIHBsYWNlCiAgICAgICAgICAgICB1c2VyaWRfdCB1c2VyX2lkID0gbXVsdGl1c2VyX2dldF91c2VyX2lkKHVpZCk7CiAgICAgICAgICAgICBzdGQ6OnN0cmluZyB1c2VyU291cmNlKFN0cmluZ1ByaW50ZigiL21udC91c2VyLyVkIiwgdXNlcl9pZCkpOwotICAgICAgICAgICAgaWYgKFRFTVBfRkFJTFVSRV9SRVRSWShtb3VudCh1c2VyU291cmNlLmNfc3RyKCksICIvc3RvcmFnZS9zZWxmIiwKLSAgICAgICAgICAgICAgICAgICAgTlVMTCwgTVNfQklORCwgTlVMTCkpID09IC0xKSB7Ci0gICAgICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byBtb3VudCAiIDw8IHVzZXJTb3VyY2UgPDwgIiBmb3IgIgotICAgICAgICAgICAgICAgICAgICAgICAgPDwgZGUtPmRfbmFtZTsKKyAgICAgICAgICAgIGlmIChURU1QX0ZBSUxVUkVfUkVUUlkoCisgICAgICAgICAgICAgICAgICAgIG1vdW50KHVzZXJTb3VyY2UuY19zdHIoKSwgIi9zdG9yYWdlL3NlbGYiLCBOVUxMLCBNU19CSU5ELCBOVUxMKSkgPT0gLTEpIHsKKyAgICAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIG1vdW50ICIgPDwgdXNlclNvdXJjZSA8PCAiIGZvciAiIDw8IGRlLT5kX25hbWU7CiAgICAgICAgICAgICAgICAgX2V4aXQoMSk7CiAgICAgICAgICAgICB9CiAKQEAgLTU1NSw3ICs1MjIsNyBAQAogICAgICAgICAgICAgVEVNUF9GQUlMVVJFX1JFVFJZKHdhaXRwaWQoY2h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50ZigiL21udC9hcHBmdXNlLyVkXyVzIiwgdWlkLCBuYW1lLmNfc3RyKCkpOwogICAgIHJldHVybiBhbmRyb2lkOjpPSzsKIH0KIApAQCAtNjcxLDIxICs2NDEsMTkgQEAKICAgICAvLyBSZW1vdmUgZXhpc3RpbmcgbW91bnQuCiAgICAgYW5kcm9pZDo6dm9sZDo6Rm9yY2VVbm1vdW50KHBhdGgpOwogCi0gICAgY29uc3QgYXV0byBvcHRzID0gYW5kcm9pZDo6YmFzZTo6U3RyaW5nUHJpbnRmKAotICAgICAgICAgICAgImZkPSVpLCIKLSAgICAgICAgICAgICJyb290bW9kZT00MDAwMCwiCi0gICAgICAgICAgICAiZGVmYXVsdF9wZXJtaXNzaW9ucywiCi0gICAgICAgICAgICAiYWxsb3dfb3RoZXIsIgotICAgICAgICAgICAgInVzZXJfaWQ9JWQsZ3JvdXBfaWQ9JWQsIgotICAgICAgICAgICAgImNvbnRleHQ9XCJ1Om9iamVjdF9yOmFwcF9mdXNlX2ZpbGU6czBcIiwiCi0gICAgICAgICAgICAiZnNjb250ZXh0PXU6b2JqZWN0X3I6YXBwX2Z1c2VmczpzMCIsCi0gICAgICAgICAgICBkZXZpY2VfZmQsCi0gICAgICAgICAgICB1aWQsCi0gICAgICAgICAgICB1aWQpOworICAgIGNvbnN0IGF1dG8gb3B0cyA9IFN0cmluZ1ByaW50ZigKKyAgICAgICAgImZkPSVpLCIKKyAgICAgICAgInJvb3Rtb2RlPTQwMDAwLCIKKyAgICAgICAgImRlZmF1bHRfcGVybWlzc2lvbnMsIgorICAgICAgICAiYWxsb3dfb3RoZXIsIgorICAgICAgICAidXNlcl9pZD0lZCxncm91cF9pZD0lZCwiCisgICAgICAgICJjb250ZXh0PVwidTpvYmplY3RfcjphcHBfZnVzZV9maWxlOnMwXCIsIgorICAgICAgICAiZnNjb250ZXh0PXU6b2JqZWN0X3I6YXBwX2Z1c2VmczpzMCIsCisgICAgICAgIGRldmljZV9mZCwgdWlkLCB1aWQpOwogCi0gICAgY29uc3QgaW50IHJlc3VsdCA9IFRFTVBfRkFJTFVSRV9SRVRSWShtb3VudCgKLSAgICAgICAgICAgICIvZGV2L2Z1c2UiLCBwYXRoLmNfc3RyKCksICJmdXNlIiwKLSAgICAgICAgICAgIE1TX05PU1VJRCB8IE1TX05PREVWIHwgTVNfTk9FWEVDIHwgTVNfTk9BVElNRSwgb3B0cy5jX3N0cigpKSk7CisgICAgY29uc3QgaW50IHJlc3VsdCA9CisgICAgICAgIFRFTVBfRkFJTFVSRV9SRVRSWShtb3VudCgiL2Rldi9mdXNlIiwgcGF0aC5jX3N0cigpLCAiZnVzZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNU19OT1NVSUQgfCBNU19OT0RFViB8IE1TX05PRVhFQyB8IE1TX05PQVRJTUUsIG9wdHMuY19zdHIoKSkpOwogICAgIGlmIChyZXN1bHQgIT0gMCkgewogICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIG1vdW50ICIgPDwgcGF0aDsKICAgICAgICAgcmV0dXJuIC1lcnJubzsKQEAgLTY5NCwxMSArNjYyLDggQEAKICAgICByZXR1cm4gYW5kcm9pZDo6T0s7CiB9CiAKLXN0YXRpYyBhbmRyb2lkOjpzdGF0dXNfdCBydW5Db21tYW5kSW5OYW1lc3BhY2UoY29uc3Qgc3RkOjpzdHJpbmcmIGNvbW1hbmQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpZF90IHVpZCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGlkX3QgcGlkLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgcGF0aCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGRldmljZV9mZCkgeworc3RhdGljIGFuZHJvaWQ6OnN0YXR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m9jLyIgPDwgcGlkOwogICAgICAgICByZXR1cm4gLWVycm5vOwpAQCAtNzI5LDcgKzY5Myw3IEBACiAgICAgICAgIH0KICAgICAgICAgaWYgKHNiLnN0X3VpZCAhPSBBSURfU1lTVEVNKSB7CiAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJPbmx5IHN5c3RlbSBjYW4gbW91bnQgYXBwZnVzZS4gVUlEIGV4cGVjdGVkPSIgPDwgQUlEX1NZU1RFTQotICAgICAgICAgICAgICAgICAgICA8PCAiLCBhY3R1YWw9IiA8PCBzYi5zdF91aWQ7CisgICAgICAgICAgICAgICAgICAgICAgIDw8ICIsIGFjdHVhbD0iIDw8IHNiLnN0X3VpZDsKICAgICAgICAgICAgIHJldHVybiAtRVBFUk07CiAgICAgICAgIH0KICAgICB9CkBAIC03MzgsOCArNzAyLDggQEAKICAgICB7CiAgICAgICAgIHN0ZDo6c3RyaW5nIHJvb3ROYW1lOwogICAgICAgICBzdGQ6OnN0cmluZyBwaWROYW1lOwotICAgICAgICBpZiAoIWFuZHJvaWQ6OnZvbGQ6OlJlYWRsaW5rYXQoZGlyLmdldCgpLCAiMS9ucy9tbnQiLCAmcm9vdE5hbWUpCi0gICAgICAgICAgICAgICAgfHwgIWFuZHJvaWQ6OnZvbGQ6OlJlYWRsaW5rYXQocGlkX2ZkLmdldCgpLCAibnMvbW50IiwgJnBpZE5hbWUpKSB7CisgICAgICAgIGlmICghYW5kcm9pZDo6dm9sZDo6UmVhZGxpbmthdChkaXIuZ2V0KCksICIxL25zL21udCIsICZyb290TmFtZSkgfHwKKyAgICAgICAgICAgICFhbmRyb2lkOjp2b2xkOjpSZWFkbGlua2F0KHBpZF9mZC5nZXQoKSwgIm5zL21udCIsICZwaWROYW1lKSkgewogICAgICAgICAgICAgUExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byByZWFkIG5hbWVzcGFjZXMiOwogICAgICAgICAgICAgcmV0dXJuIC1FUEVSTTsKICAgICAgICAgfQpAQCAtNzUwL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cHVibGljOgotICAgICAgICBEaXNrU291cmNlKGNvbnN0IHN0ZDo6c3RyaW5nJiBzeXNQYXR0ZXJuLCBjb25zdCBzdGQ6OnN0cmluZyYgbmlja25hbWUsIGludCBmbGFncykgOgotICAgICAgICAgICAgICAgIG1TeXNQYXR0ZXJuKHN5c1BhdHRlcm4pLCBtTmlja25hbWUobmlja25hbWUpLCBtRmxhZ3MoZmxhZ3MpIHsKLSAgICAgICAgfQorICAgICAgcHVibGljOgorICAgICAgICBEaXNrU291cmNlKGNvbnN0IHN0ZDo6c3RyaW5nJiBzeXNQYXR0ZXJuLCBjb25zdCBzdGQ6OnN0cmluZyYgbmlja25hbWUsIGludCBmbGFncykKKyAgICAgICAgICAgIDogbVN5c1BhdHRlcm4oc3lzUGF0dGVybiksIG1OaWNrbmFtZShuaWNrbmFtZSksIG1GbGFncyhmbGFncykge30KIAogICAgICAgICBib29sIG1hdGNoZXMoY29uc3Qgc3RkOjpzdHJpbmcmIHN5c1BhdGgpIHsKICAgICAgICAgICAgIHJldHVybiAhZm5tYXRjaChtU3lzUGF0dGVybi5jX3N0cigpLCBzeXNQYXRoLmNfc3RyKCksIDApOwpAQCAtNzQsNyArNzMsNyBAQAogICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgZ2V0Tmlja25hbWUoKSB7IHJldHVybiBtTmlja25hbWU7IH0KICAgICAgICAgaW50IGdldEZsYWdzKCkgeyByZXR1cm4gbUZsYWdzOyB9CiAKLSAgICBwcml2YXRlOgorICAgICAgcHJpdmF0ZToKICAgICAgICAgc3RkOjpzdHJpbmcgbVN5c1BhdHRlcm47CiAgICAgICAgIHN0ZDo6c3RyaW5nIG1OaWNrbmFtZTsKICAgICAgICAgaW50IG1GbGFnczsKQEAgLTExMCw3ICsxMDksNyBAQAogICAgIGludCB1cGRhdGVWaXJ0dWFsRGlzaygpOwogICAgIGludCBzZXREZWJ1Zyhib29sIGVuYWJsZSk7CiAKLSAgICBzdGF0aWMgVm9sdW1lTWFuYWdl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VyZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCAqc2lnbmF0dXJlX3NpemUpCi17CitzdGF0aWMgaW50IGtleW1hc3Rlcl9zaWduX29iamVjdChzdHJ1Y3QgY3J5cHRfbW50X2Z0ciogZnRyLCBjb25zdCB1bnNpZ25lZCBjaGFyKiBvYmplY3QsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplX3Qgb2JqZWN0X3NpemUsIHVuc2lnbmVkIGNoYXIqKiBzaWduYXR1cmUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QqIHNpZ25hdHVyZV9zaXplKSB7CiAgICAgdW5zaWduZWQgY2hhciB0b19zaWduW1JTQV9LRVlfU0laRV9CWVRFU107CiAgICAgc2l6ZV90IHRvX3NpZ25fc2l6ZSA9IHNpemVvZih0b19zaWduKTsKICAgICBtZW1zZXQodG9fc2lnbiwgMCwgUlNBX0tFWV9TSVpFX0JZVEVTKTsKQEAgLTIyNSwyMSArMjI0LDIwIEBACiBzdGF0aWMgaW50IHBhc3N3b3JkX2V4cGlyeV90aW1lID0gMDsKIHN0YXRpYyBjb25zdCBpbnQgcGFzc3dvcmRfbWF4X2FnZV9zZWNvbmRzID0gNjA7CiAKLWVudW0gY2xhc3MgUmVib290VHlwZSB7cmVib290LCByZWNvdmVyeSwgc2h1dGRvd259Owotc3RhdGljIHZvaWQgY3J5cHRmc19yZWJvb3QoUmVib290VHlwZSBydCkKLXsKLSAgc3dpdGNoIChydCkgewotICAgICAgY2FzZSBSZWJvb3RUeXBlOjpyZWJvb3Q6Ci0gICAgICAgICAgcHJvcGVydHlfc2V0KEFORFJPSURfUkJfUFJPUEVSVFksICJyZWJvb3QiKTsKLSAgICAgICAgICBicmVhazsKK2VudW0gY2xhc3MgUmVib290VHlwZSB7IHJlYm9vdCwgcmVjb3ZlcnksIHNodXRkb3duIH07CitzdGF0aWMgdm9pZCBjcnlwdGZzX3JlYm9vdChSZWJvb3RUeXBlIHJ0KSB7CisgICAgc3dpdGNoIChydCkgeworICAgICAgICBjYXNlIFJlYm9vdFR5cGU6OnJlYm9vdDoKKyAgICAgICAgICAgIHByb3BlcnR5X3NldChBTkRST0lEX1JCX1BST1BFUlRZLCAicmVib290Iik7CisgICAgICAgICAgICBicmVhazsKIAotICAgICAgY2FzZSBSZWJvb3RUeXBlOjpyZWNvdmVyeToKLSAgICAgICAgICBwcm9wZXJ0eV9zZXQoQU5EUk9JRF9SQl9QUk9QRVJUWSwgInJlYm9vdCxyZWNvdmVyeSIpOwotICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFJlYm9vdFR5cGU6OnJlY292ZXJ5OgorICAgICAgICAgICAgcHJvcGVydHlfc2V0KEFORFJPSURfUkJfUFJPUEVSVFksICJyZWJvb3QscmVjb3ZlcnkiKTsKKyAgICAgICAgICAgIGJyZWFrOwogCi0gICAgICBjYXNlIFJlYm9vdFR5cGU6OnNodXRkb3duOgotICAgICAgICAgIHByb3BlcnR5X3NldChBTkRST0lEX1JCX1BST1BFUlRZLCAic2h1dGRvd24iKTsKLSAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBSZWJvb3RUeXBlOjpzaHV0ZG93bjoKKyAgICAgICAgICAgIHByb3BlcnR5X3NldChBTkRST0lEX1JCX1BST1BFUlRZLCAic2h1dGRvd24iKTsKKyAgICAgICAgICAgIGJyZWFrOwogICAgIH0KIAogICAgIHNsZWVwKDIwKTsKQEAgLTI0OCw4ICsyNDYsNyBAQAogICAgIHJldHVybjsKIH0KIAotc3RhdGljIHZvaWQgaW9jdGxfaW5pdChzdHJ1Y3QgZG1faW9jdGwgKmlvLCBzaXplX3QgZGF0YVNpemUsIGNvbnN0IGNoYXIgKm5hbWUsIHVuc2lnbmVkIGZsYWdzKQoteworc3RhdGljIHZvaWQgaW9jdGxfaW5pdChzdHJ1Y3QgZG1faW9jdGwqIGlvLCBzaXplX3QgZGF0YVNpemUsIGNvbnN0IG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jYWNoZWRfbWV0YWRhdGFfZm5hbWUsIHJlYWxfYmxrZGV2LCBzaXplb2YoY2FjaGVkX21ldGFkYXRhX2ZuYW1lKSk7CisgICAgICAgICAgICAgICAgY2FjaGVkX29mZiAtPSBDUllQVF9GT09URVJfT0ZGU0VUOworICAgICAgICAgICAgICAgIGNhY2hlZF9kYXRhID0gMTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgU0xPR0UoIkNhbm5vdCBnZXQgc2l6ZSBvZiBibG9jayBkZXZpY2UgJXNcbiIsIHJlYWxfYmxrZGV2KTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIHN0cmxjcHkoY2FjaGVkX21ldGFkYXRhX2ZuYW1lLCBrZXlfbG9jLCBzaXplb2YoY2FjaGVkX21ldGFkYXRhX2ZuYW1lKSk7CisgICAgICAgICAgICBjYWNoZWRfb2ZmID0gMDsKKyAgICAgICAgICAgIGNhY2hlZF9kYXRhID0gMTsKKyAgICAgICAgfQogICAgIH0KLSAgfQogCi0gIGlmIChjYWNoZWRfZGF0YSkgewotICAgIGlmIChtZXRhZGF0YV9mbmFtZSkgewotICAgICAgICAqbWV0YWRhdGFfZm5hbWUgPSBjYWNoZWRfbWV0YWRhdGFfZm5hbWU7CisgICAgaWYgKGNhY2hlZF9kYXRhKSB7CisgICAgICAgIGlmIChtZXRhZGF0YV9mbmFtZSkgeworICAgICAgICAgICAgKm1ldGFkYXRhX2ZuYW1lID0gY2FjaGVkX21ldGFkYXRhX2ZuYW1lOworICAgICAgICB9CisgICAgICAgIGlmIChvZmYpIHsKKyAgICAgICAgICAgICpvZmYgPSBjYWNoZWRfb2ZmOworICAgICAgICB9CisgICAgICAgIHJjID0gMDsKICAgICB9Ci0gICAgaWYgKG9mZikgewotICAgICAgICAqb2ZmID0gY2FjaGVkX29mZjsKLSAgICB9Ci0gICAgcmMgPSAwOwotICB9CiAKLSAgcmV0dXJuIHJjOworICAg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0YXRpYyB2b2lkIGNvbnZlcnRfa2V5X3RvX2hleF9hc2NpaShjb25zdCB1bnNpZ25lZCBjaGFyICptYXN0ZXJfa2V5LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCBrZXlzaXplLCBjaGFyICptYXN0ZXJfa2V5X2FzY2lpKSB7CitzdGF0aWMgdm9pZCBjb252ZXJ0X2tleV90b19oZXhfYXNjaWkoY29uc3QgdW5zaWduZWQgY2hhciogbWFzdGVyX2tleSwgdW5zaWduZWQgaW50IGtleXNpemUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhciogbWFzdGVyX2tleV9hc2NpaSkgewogICAgIHVuc2lnbmVkIGludCBpLCBhOwogICAgIHVuc2lnbmVkIGNoYXIgbmliYmxlOwogCi0gICAgZm9yIChpPTAsIGE9MDsgaTxrZXlzaXplOyBpKyssIGErPTIpIHsKKyAgICBmb3IgKGkgPSAwLCBhID0gMDsgaSA8IGtleXNpemU7IGkrKywgYSArPSAyKSB7CiAgICAgICAgIC8qIEZvciBlYWNoIGJ5dGUsIHdyaXRlIG91dCB0d28gYXNjaWkgaGV4IGRpZ2l0cyAqLwogICAgICAgICBuaWJibGUgPSAobWFzdGVyX2tleVtpXSA+PiA0KSAmIDB4ZjsKICAgICAgICAgbWFzdGVyX2tleV9hc2NpaVthXSA9IG5pYmJsZSArIChuaWJibGUgPiA5ID8gMHgzNyA6IDB4MzApOwogCiAgICAgICAgIG5pYmJsZSA9IG1hc3Rlcl9rZXlbaV0gJiAweGY7Ci0gICAgICAgIG1hc3Rlcl9rZXlfYXNjaWlbYSsxXSA9IG5pYmJsZSArIChuaWJibGUgPiA5ID8gMHgzNyA6IDB4MzApOworICAgICAgICBtYXN0ZXJfa2V5X2FzY2lpW2EgKyAxXSA9IG5pYmJsZSArIChuaWJibGUgPiA5ID8gMHgzNyA6IDB4MzApOwogICAgIH0KIAogICAgIC8qIEFkZCB0aGUgbnVsbC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qLworICAgIGNsb3NlKGZkKTsgLyogSWYgZmQgaXMgPDAgZnJvbSBhIGZhaWxlZCBvcGVuIGNhbGwsIGl0J3Mgc2FmZSB0byBqdXN0IGlnbm9yZSB0aGUgY2xvc2UgZXJyb3IgKi8KIAotICByZXR1cm4gcmV0dmFsOwotCisgICAgcmV0dXJuIHJldHZhbDsKIH0KIAotc3RhdGljIGludCBwYmtkZjIoY29uc3QgY2hhciAqcGFzc3dkLCBjb25zdCB1bnNpZ25lZCBjaGFyICpzYWx0LAotICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqaWtleSwgdm9pZCAqcGFyYW1zIFVOVVNFRCkKLXsKK3N0YXRpYyBpbnQgcGJrZGYyKGNvbnN0IGNoYXIqIHBhc3N3ZCwgY29uc3QgdW5zaWduZWQgY2hhciogc2FsdCwgdW5zaWduZWQgY2hhciogaWtleSwKKyAgICAgICAgICAgICAgICAgIHZvaWQqIHBhcmFtcyBVTlVTRUQpIHsKICAgICBTTE9HSSgiVXNpbmcgcGJrZGYyIGZvciBjcnlwdGZzIEtERiIpOwogCiAgICAgLyogVHVybiB0aGUgcGFzc3dvcmQgaW50byBhIGtleSBhbmQgSVYgdGhhdCBjYW4gZGVjcnlwdCB0aGUgbWFzdGVyIGtleSAqLwotICAgIHJldHVybiBQS0NTNV9QQktERjJfSE1BQ19TSEExKHBhc3N3ZCwgc3RybGVuKHBhc3N3ZCksIHNhbHQsIFNBTFRfTEVOLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEhBU0hfQ09VTlQsIElOVEVSTUVESUFURV9CVUZfU0laRSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpa2V5KSAhPSAxOworICAgIHJldHVybiBQS0NTNV9QQktERjJfSE1BQ19TSEExKHBhc3N3ZCwgc3RybGVuKHBhc3N3ZCksIHNhbHQsIFNBTFRfTEVOLCBIQVNIX0NPVU5ULAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEl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NBTFRfTEVOLCBOLCByLCBwLCBpa2V5LAorICAgIHJjID0gY3J5cHRvX3NjcnlwdCgoY29uc3QgdWludDhfdCopcGFzc3dkLCBzdHJsZW4ocGFzc3dkKSwgc2FsdCwgU0FMVF9MRU4sIE4sIHIsIHAsIGlrZXksCiAgICAgICAgICAgICAgICAgICAgICAgIElOVEVSTUVESUFURV9CVUZfU0laRSk7CiAKICAgICBpZiAocmMpIHsKQEAgLTEyMjYsMTQgKzExODIsMTMgQEAKICAgICAgICAgcmV0dXJuIC0xOwogICAgIH0KIAotICAgIGlmIChrZXltYXN0ZXJfc2lnbl9vYmplY3QoZnRyLCBpa2V5LCBJTlRFUk1FRElBVEVfQlVGX1NJWkUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmc2lnbmF0dXJlLCAmc2lnbmF0dXJlX3NpemUpKSB7CisgICAgaWYgKGtleW1hc3Rlcl9zaWduX29iamVjdChmdHIsIGlrZXksIElOVEVSTUVESUFURV9CVUZfU0laRSwgJnNpZ25hdHVyZSwgJnNpZ25hdHVyZV9zaXplKSkgewogICAgICAgICBTTE9HRSgiU2lnbmluZyBmYWlsZWQiKTsKICAgICAgICAgcmV0dXJuIC0xOwogICAgIH0KIAotICAgIHJjID0gY3J5cHRvX3NjcnlwdChzaWduYXR1cmUsIHNpZ25hdHVyZV9zaXplLCBzYWx0LCBTQUxUX0xFTiwKLSAgICAgICAgICAgICAgICAgICAgICAgTiwgciwgcCwgaWtleSwgSU5URVJNRURJQVRFX0JVRl9TSVpFKTsKKyAgICByYyA9IGNyeXB0b19zY3J5cHQoc2lnbmF0dXJlLCBzaWduYXR1cmVfc2l6ZSwgc2FsdCwgU0FMVF9MRU4sIE4sIHIsIHAsIGlrZXksCisgICAgICAgICAgICAgICAgICAgICAgIElOVEVSTUVESUFURV9CVUZfU0laRSk7CiAgICAgZnJlZShzaWduYXR1cmUpOwogCiAgICAgaWYgKHJjKSB7CkBAIC0xMjQ0LDEyICsxMTk5LDEwIEBACi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jcnlwdF9mdHItPmtkZl90eXBlKSB7Ci0gICAgY2FzZSBLREZfU0NSWVBUX0tFWU1BU1RFUjoKLSAgICAgICAgaWYgKGtleW1hc3Rlcl9jcmVhdGVfa2V5KGNyeXB0X2Z0cikpIHsKLSAgICAgICAgICAgIFNMT0dFKCJrZXltYXN0ZXJfY3JlYXRlX2tleSBmYWlsZWQiKTsKLSAgICAgICAgICAgIHJldHVybiAtMTsKLSAgICAgICAgfQorICAgICAgICBjYXNlIEtERl9TQ1JZUFRfS0VZTUFTVEVSOgorICAgICAgICAgICAgaWYgKGtleW1hc3Rlcl9jcmVhdGVfa2V5KGNyeXB0X2Z0cikpIHsKKyAgICAgICAgICAgICAgICBTTE9HRSgia2V5bWFzdGVyX2NyZWF0ZV9rZXkgZmFpbGVkIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgfQogCi0gICAgICAgIGlmIChzY3J5cHRfa2V5bWFzdGVyKHBhc3N3ZCwgc2FsdCwgaWtleSwgY3J5cHRfZnRyKSkgewotICAgICAgICAgICAgU0xPR0UoInNjcnlwdCBmYWlsZWQiKTsKLSAgICAgICAgICAgIHJldHVybiAtMTsKLSAgICAgICAgfQotICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGlmIChzY3J5cHRfa2V5bWFzdGVyKHBhc3N3ZCwgc2FsdCwgaWtleSwgY3J5cHRfZnRyKSkgeworICAgICAgICAgICAgICAgIFNMT0dFKCJzY3J5cHQgZmFpbGVkIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgfQorICAgICAgICAgICAgYnJlYWs7CiAKLSAgICBjYXNlIEtERl9TQ1JZUFQ6Ci0gICAgICAgIGlmIChzY3J5cHQocGFzc3dkLCBzYWx0LCBpa2V5LCBjcnlwdF9mdHIpKSB7Ci0gICAgICAgICAgICBTTE9HRSgic2NyeXB0IGZhaWxlZCIpOwotICAgICAgICAgICAgcmV0dXJuIC0xOwotICAgICAgICB9Ci0gICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIEtERl9TQ1JZUFQ6CisgICAgICAgICAgICBpZiAoc2NyeXB0KHBhc3N3ZCwgc2FsdCwgaWtleSwgY3J5cHRfZnRyKSkgeworICAgICAgICAgICAgICAgIFNMT0dFKCJzY3J5cHQgZmFpbGVkIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgfQorICAgICAgICAgICAgYnJlYWs7CiAKLSAgICBkZWZhdWx0OgotICAgICAgICBTTE9HRSgiSW52YWxpZCBrZGZfdHlwZSIpOwotICAgICAgICByZXR1cm4gLTE7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBTTE9HRSgiSW52YWxpZCBrZGZfdHlwZSIpOworICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgIH0KIAogICAgIC8qIEluaXRpYWxpemUgdGhlIGRlY3J5cHRpb24gZW5naW5lICovCiAgICAgRVZQX0NJUEhFUl9DVFhfaW5pdCgmZV9jdHgpOwotICAgIGlmICghIEVWUF9FbmNyeXB0SW5pdF9leCgmZV9jdHgsIEVWUF9hZXNfMTI4X2NiYygpLCBOVUxMLCBpa2V5LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpa2V5K0lOVEVSTUVESUFURV9LRVlfTEVOX0JZVEVTKSkgeworICAgIGlmICghRVZQX0VuY3J5cHRJbml0X2V4KCZlX2N0eCwgRVZQX2Flc18xMjhfY2JjKCksIE5VTEwsIGlrZXksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWtleSArIElOVEVSTUVESUFURV9LRVlfTEVOX0JZVEVTKSkgewogICAgICAgICBTTE9HRSgiRVZQX0VuY3J5cHRJbml0IGZhaWxlZFxuIik7CiAgICAgICAgIHJldHVybiAtMTsKICAgICB9CiAgICAgRVZQX0NJUEhFUl9DVFhfc2V0X3BhZGRpbmcoJmVfY3R4LCAwKTsgLyogVHVybiBvZmYgcGFkZGluZyBhcyBvdXIgZGF0YSBpcyBibG9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2V5c2l6ZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICpkZWNyeXB0ZWRfbWFzdGVyX2tleSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZGZfZnVuYyBrZGYsIHZvaWQgKmtkZl9wYXJhbXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhcioqIGludGVybWVkaWF0ZV9rZXksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90KiBpbnRlcm1lZGlhdGVfa2V5X3NpemUpCi17Ci0gIHVuc2lnbmVkIGNoYXIgaWtleVtJTlRFUk1FRElBVEVfQlVGX1NJWkVdID0geyAwIH07Ci0gIEVWUF9DSVBIRVJfQ1RYIGRfY3R4OwotICBpbnQgZGVjcnlwdGVkX2xlbiwgZmluYWxfbGVuOworc3RhdGljIGludCBkZWNyeXB0X21hc3Rlcl9rZXlfYXV4KGNvbnN0IGNoYXIqIHBhc3N3ZCwgdW5zaWduZWQgY2hhciogc2FsdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bnNpZ25lZCBjaGFyKiBlbmNyeXB0ZWRfbWFzdGVyX2tleSwgc2l6ZV90IGtleXNpemUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciogZGVjcnlwdGVkX21hc3Rlcl9rZXksIGtkZl9mdW5jIGtkZiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2b2lkKiBrZGZfcGFyYW1zLCB1bnNpZ25lZCBjaGFyKiogaW50ZXJtZWRpYXRlX2tleSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QqIGludGVybWVkaWF0ZV9rZXlfc2l6ZSkgeworICAgIHVuc2lnbmVkIGNoYXIgaWtleVtJTlRFUk1FRElBVEVfQlVGX1NJWkVdID0gezB9OworIC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llURVMpOworICAgICAgICBpZiAoKmludGVybWVkaWF0ZV9rZXkpIHsKKyAgICAgICAgICAgIG1lbWNweSgqaW50ZXJtZWRpYXRlX2tleSwgaWtleSwgSU5URVJNRURJQVRFX0tFWV9MRU5fQllURVMpOworICAgICAgICAgICAgKmludGVybWVkaWF0ZV9rZXlfc2l6ZSA9IElOVEVSTUVESUFURV9LRVlfTEVOX0JZVEVTOworICAgICAgICB9CisgICAgfQorCisgICAgRVZQX0NJUEhFUl9DVFhfY2xlYW51cCgmZF9jdHgpOworCisgICAgcmV0dXJuIDA7CiB9CiAKLXN0YXRpYyB2b2lkIGdldF9rZGZfZnVuYyhzdHJ1Y3QgY3J5cHRfbW50X2Z0ciAqZnRyLCBrZGZfZnVuYyAqa2RmLCB2b2lkKioga2RmX3BhcmFtcykKLXsKK3N0YXRpYyB2b2lkIGdldF9rZGZfZnVuYyhzdHJ1Y3QgY3J5cHRfbW50X2Z0ciogZnRyLCBrZGZfZnVuYyoga2RmLCB2b2lkKioga2RmX3BhcmFtcykgewogICAgIGlmIChmdHItPmtkZl90eXBlID09IEtERl9TQ1JZUFRfS0VZTUFTVEVSKSB7CiAgICAgICAgICprZGYgPSBzY3J5cHRfa2V5bWFzdGVyOwogICAgICAgICAqa2RmX3BhcmFtcyA9IGZ0cjsKQEAgLTEzOTYsMjAgKzEzNDUsMTcgQEAKICAgICB9CiB9CiAKLXN0YXRpYyBpbnQgZGVjcnlwdF9tYXN0ZXJfa2V5KGNvbnN0IGNoYXIgKnBhc3N3ZCwgdW5zaWduZWQgY2hhciAqZGVjcnlwdGVkX21hc3Rlcl9rZXksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJ1Y3QgY3J5cHRfbW50X2Z0ciAqY3J5cHRfZnRyLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhcioqIGludGVybWVkaWF0ZV9rZXksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QqIGludG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QEAgLTE1OTgsNyArMTUzNyw5IEBACiAgICAgICAgIHByb3BlcnR5X2dldCgicm8uY3J5cHRvLnJlYWRvbmx5Iiwgcm9fcHJvcCwgIiIpOwogICAgICAgICBpZiAoc3RybGVuKHJvX3Byb3ApID4gMCAmJiBzdGQ6OnN0b2kocm9fcHJvcCkpIHsKICAgICAgICAgICAgIHN0cnVjdCBmc3RhYl9yZWMqIHJlYyA9IGZzX21ncl9nZXRfZW50cnlfZm9yX21vdW50X3BvaW50KGZzdGFiX2RlZmF1bHQsIERBVEFfTU5UX1BPSU5UKTsKLSAgICAgICAgICAgIHJlYy0+ZmxhZ3MgfD0gTVNfUkRPTkxZOworICAgICAgICAgICAgaWYgKHJlYykgeworICAgICAgICAgICAgICAgIHJlYy0+ZmxhZ3MgfD0gTVNfUkRPTkxZOworICAgICAgICAgICAgfQogICAgICAgICB9CiAKICAgICAgICAgLyogSWYgdGhhdCBzdWNjZWVkZWQsIHRoZW4gbW91bnQgdGhlIGRlY3J5cHRlZCBmaWxlc3lzdGVtICovCkBAIC0xNjA5LDE5ICsxNTUwLDE4IEBACiAgICAgICAgICAqIGZzX21ncl9kb19tb3VudCBydW5zIGZzY2suIFVzZSBzZXRleGVjY29uIHRvIHJ1biB0cnVzdGVkCiAgICAgICAgICAqIHBhcnRpdGlvbnMgaW4gdGhlIGZzY2sgZG9tYWluLgogICAgICAgICAgKi8KLSAgICAgICAgaWYgKHNldGV4ZWNjb24oc2Vjb250ZXh0RnNjaygpKSl7CisgICAgICAgIGlmIChzZXRleGVjY29uKHNlY29udGV4dEZzY2soKSkpIHsKICAgICAgICAgICAgIFNMT0dFKCJGYWlsZWQgdG8gc2V0ZXhlY2NvbiIpOwogICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICB9Ci0gICAgICAgIHdoaWxlICgobW91bnRfcmMgPSBmc19tZ3JfZG9fbW91bnQoZnN0YWJfZGVmYXVsdCwgREFUQV9NTlRfUE9JTlQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3J5cHRvX2Jsa2RldiwgMCkpCi0gICAgICAgICAgICAgICAhPSAwKSB7CisgICAgICAgIGJvb2wgbmVlZHNfY3AgPSBhbmRyb2lkOjp2b2xkOjpjcF9uZWVkc0NoZWNrcG9pbnQoKTsKKyAgICAgICAgd2hpbGUgKChtb3VudF9yYyA9IGZzX21ncl9kb19tb3VudChmc3RhYl9kZWZhdWx0LCBEQVRBX01OVF9QT0lOVCwgY3J5cHRvX2Jsa2RldiwgMCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWVkc19jcCkpICE9IDApIHsKICAgICAgICAgICAgIGlmIChtb3VudF9yYyA9PSBGU19NR1JfRE9NTlRfQlVTWSkgewogICAgICAgICAgICAgICAgIC8qIFRPRE86IGludm9rZSBzb21ldGhpbmcgc2ltaWxhciB0bwogICAgICAgICAgICAgICAgICAgIFByb2Nlc3M6OmtpbGxQcm9jZXNzV2l0aE9wZW5GaWxlcyhEQVRBX01OVF9QT0lOVCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0cmllcyA+IFJFVFJZX01PVU5UX0FUVEVNUFQvMiA/IDEgOiAyICkgKi8KLSAgICAgICAgICAgICAgICBTTE9HSSgiRmFpbGVkIHRvIG1vdW50ICVzIGJlY2F1c2UgaXQgaXMgYnVzeSAtIHdhaXRpbmciLAotICAgICAgICAgICAgICAgICAgICAgIGNyeXB0b19ibGtkZXYpOworICAgICAgICAgICAgICAgIFNMT0dJKCJGYWlsZWQgdG8gbW91bnQgJXMgYmVjYXVzZSBpdCBpcyBidXN5IC0gd2FpdGluZyIsIGNyeXB0b19ibGtkZXYpOwogICAgICAgICAgICAgICAgIGlmICgtLXJldHJpZXMpIHsKICAgICAgICAgICAgICAgICAgICAgc2xlZXAoUkVUUllfTU9VTlRfREVMQVlfU0VDT05EUyk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTE2Nj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AgICAgICAgIHJjID0gKytjcnlwdF9mdHItPmZhaWxlZF9kZWNyeXB0X2NvdW50OworICAgICAgICAgICAgcHV0X2NyeXB0X2Z0cl9hbmRfa2V5KGNyeXB0X2Z0cik7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAvKiBTdWNjZXNzISAqLworICAgICAgICAgICAgU0xPR0koIlBhc3N3b3JkIGRpZCBub3QgbWF0Y2ggYnV0IGRlY3J5cHRlZCBkcml2ZSBtb3VudGVkIC0gY29udGludWUiKTsKKyAgICAgICAgICAgIHVtb3VudCh0bXBfbW91bnRfcG9pbnQpOworICAgICAgICAgICAgcmMgPSAwOwogICAgICAgICB9CiAgICAgfQotICB9CiAKLSBlcnJvdXQ6Ci0gIGlmIChpbnRlcm1lZGlhdGVfa2V5KSB7Ci0gICAgbWVtc2V0KGludGVybWVkaWF0ZV9rZXksIDAsIGludGVybWVkaWF0ZV9rZXlfc2l6ZSk7Ci0gICAgZnJlZShpbnRlcm1lZGlhdGVfa2V5KTsKLSAgfQotICByZXR1cm4gcmM7CisgICAgaWYgKHJjID09IDApIHsKKyAgICAgICAgY3J5cHRfZnRyLT5mYWlsZWRfZGVjcnlwdF9jb3VudCA9IDA7CisgICAgICAgIGlmIChvcmlnX2ZhaWxlZF9kZWNyeXB0X2NvdW50ICE9IDApIHsKKyAgICAgICAgICAgIHB1dF9jcnlwdF9mdHJfYW5kX2tleShjcnlwdF9mdHIpOworICAgICAgICB9CisKKyAgICAgICAgLyogU2F2ZSB0aGUgbmFtZSBvZiB0aGUgY3J5cHRvIGJsb2NrIGRldmljZQorICAgICAgICAgKiBzbyB3ZSBjYW4gbW91bnQgaXQgd2hlbiByZXN0YXJ0aW5nIHRoZSBmcmFtZXdvcmsuICovCisgICAgICAgIHByb3BlcnR5X3NldCgicm8uY3J5cHRvLmZzX2NyeXB0b19ibGtkZXYiLCBjcnlwdG9fYmxrZGV2KTsKKworICAgICAgICAvKiBBbHNvIHNhdmUgYSB0aGUgbWFzd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a2RmX3R5cGUgPSBLREZfU0NSWVBUOworICAgICAgICAgICAgdXBncmFkZSA9IDE7CisgICAgICAgIH0KKworICAgICAgICBpZiAodXBncmFkZSkgeworICAgICAgICAgICAgcmMgPSBlbmNyeXB0X21hc3Rlcl9rZXkocGFzc3dkLCBjcnlwdF9mdHItPnNhbHQsIHNhdmVkX21hc3Rlcl9rZXksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcnlwdF9mdHItPm1hc3Rlcl9rZXksIGNyeXB0X2Z0cik7CisgICAgICAgICAgICBpZiAoIXJjKSB7CisgICAgICAgICAgICAgICAgcmMgPSBwdXRfY3J5cHRfZnRyX2FuZF9rZXkoY3J5cHRfZnRyKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIFNMT0dEKCJLZXkgRGVyaXZhdGlvbiBGdW5jdGlvbiB1cGdyYWRlOiByYz0lZFxuIiwgcmMpOworCisgICAgICAgICAgICAvLyBEbyBub3QgZmFpbCBldmVuIGlmIHVwZ3JhZGUgZmFpbGVkIC0gbWFjaGluZSBpcyBib290YWJsZQorICAgICAgICAgICAgLy8gTm90ZSB0aGF0IGlmIHRoaXMgY29kZSBpcyBldmVyIGhpdCwgdGhlcmUgaXMgYSAqc2VyaW91cyogcHJvYmxlbQorICAgICAgICAgICAgLy8gc2luY2UgS0RGcyBzaG91bGQgbmV2ZXIgZmFpbC4gWW91ICptdXN0KiBmaXggdGhlIGtkZiBiZWZvcmUKKyAgICAgICAgICAgIC8vIHByb2NlZWRpbmchCisgICAgICAgICAgICBpZiAocmMpIHsKKyAgICAgICAgICAgICAgICBTTE9HVygKKyAgICAgICAgICAgICAgICAgICAgIlVwZ3JhZGUgZmFpbGVkIHdpdGggZXJyb3IgJWQsIgorICAgICAgICAgICAgICAgICAgICAiIGJ1dCBjb250aW51aW5nIHdpdGggcHJldmlvdXMgc3RhdGUiLAorICAgICAgICAgICAgICAgICAgICByYyk7CisgICAgICAgICAgICAgICAgcmMgPSAwOworIC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b3QoUmVib290VHlwZTo6cmVib290KTsKIAogICAgIC8qIHNob3VsZG4ndCBnZXQgaGVyZSAqLwpAQCAtMjQ5Niw4ICsyNDA2LDcgQEAKICAgICByZXR1cm4gY3J5cHRmc19lbmFibGVfaW50ZXJuYWwoQ1JZUFRfVFlQRV9ERUZBVUxULCBERUZBVUxUX1BBU1NXT1JELCBub191aSk7CiB9CiAKLWludCBjcnlwdGZzX2NoYW5nZXB3KGludCBjcnlwdF90eXBlLCBjb25zdCBjaGFyICpuZXdwdykKLXsKK2ludCBjcnlwdGZzX2NoYW5nZXB3KGludCBjcnlwdF90eXBlLCBjb25zdCBjaGFyKiBuZXdwdykgewogICAgIGlmIChlNGNyeXB0X2lzX25hdGl2ZSgpKSB7CiAgICAgICAgIFNMT0dFKCJjcnlwdGZzX2NoYW5nZXB3IG5vdCB2YWxpZCBmb3IgZmlsZSBlbmNyeXB0aW9uIik7CiAgICAgICAgIHJldHVybiAtMTsKQEAgLTI1MjUsMTIgKzI0MzQsOCBAQAogCiAgICAgY3J5cHRfZnRyLmNyeXB0X3R5cGUgPSBjcnlwdF90eXBlOwogCi0gICAgcmMgPSBlbmNyeXB0X21hc3Rlcl9rZXkoY3J5cHRfdHlwZSA9PSBDUllQVF9UWVBFX0RFRkFVTFQgPyBERUZBVUxUX1BBU1NXT1JECi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogbmV3cHcsCi0gICAgICAgICAgICAgICAgICAgICAgIGNyeXB0X2Z0ci5zYWx0LAotICAgICAgICAgICAgICAgICAgICAgICBzYXZlZF9tYXN0ZXJfa2V5LAotICAgICAgICAgICAgICAgICAgICAgICBjcnlwdF9mdHIubWFzdGVyX2tleSwKLSAgICAgICAgICAgICAgICAgICAgICAgJmNyeXB0X2Z0cik7CisgICAgcmMgPSBlbmNyeXB0X21hc3Rlcl9rZXkoY3J5cHRfdHlwZSA9PSBDUllQVF9UWVBFX0RFRkFVTFQgPyBERU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KHRlbXBfZmllbGQpKSB7CisgICAgICAgICAgICAgICAgKGludClzaXplb2YodGVtcF9maWVsZCkpIHsKICAgICAgICAgICAgICAgICAvLyBJZiB0aGUgZmllbGRuYW1lIGlzIHZlcnkgbG9uZywgd2Ugc3RvcCBhcyBzb29uIGFzIGl0IGJlZ2lucyB0byBvdmVyZmxvdyB0aGUKICAgICAgICAgICAgICAgICAvLyBtYXhpbXVtIGZpZWxkIGxlbmd0aC4gQXQgdGhpcyBwb2ludCB3ZSBoYXZlIGluIGZhY3QgZnVsbHkgcmVhZCBvdXQgdGhlIG9yaWdpbmFsCiAgICAgICAgICAgICAgICAgLy8gdmFsdWUgYmVjYXVzZSBjcnlwdGZzX3NldGZpZWxkIHdvdWxkIG5vdCBhbGxvdyBmaWVsZHMgd2l0aCBsb25nZXIgbmFtZXMgdG8gYmUKQEAgLTI3NDYsMTEgKzI2NDYsMTEgQEAKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGlmICghcGVyc2lzdF9nZXRfa2V5KHRlbXBfZmllbGQsIHRlbXBfdmFsdWUpKSB7Ci0gICAgICAgICAgICAgICAgICBpZiAoc3RybGNhdCh2YWx1ZSwgdGVtcF92YWx1ZSwgbGVuKSA+PSAodW5zaWduZWQpbGVuKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgLy8gdmFsdWUgdG9vIHNtYWxsLgotICAgICAgICAgICAgICAgICAgICAgIHJjID0gQ1JZUFRPX0dFVEZJRUxEX0VSUk9SX0JVRl9UT09fU01BTEw7Ci0gICAgICAgICAgICAgICAgICAgICAgZ290byBvdXQ7Ci0gICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKHN0cmxjYXQodmFsdWUsIHRlbXBfdmFsdWUsIGxlbikgPj0gKHVuc2lnbmVkKWxlbikgeworICAgICAgICAgICAgICAgICAgICAvLyB2YWx1ZSB0b28gc21hbGwuCisgICAgICAgICAgICAgICAgICAgIHJjID0gQ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ZWl0aGVyIHRocm91Z2ggc3VjY2VzcyBvcgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcnJlY3RseSBtYXJrZWQgcGFydGlhbCBlbmNyeXB0aW9uICovCi0jZGVmaW5lIENSWVBUX0RBVEFfQ09SUlVQVCAweDggLyogU2V0IHdoZW4gZW5jcnlwdGlvbiBpcyBmaW5lLCBidXQgdGhlCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kZXJseWluZyB2b2x1bWUgaXMgY29ycnVwdCAqLwotI2RlZmluZSBDUllQVF9GT1JDRV9FTkNSWVBUSU9OIDB4MTAgLyogU2V0IHdoZW4gaXQgaXMgdGltZSB0byBlbmNyeXB0IHRoaXMKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvbHVtZSBvbiBib290LiBFdmVyeXRoaW5nIGluIHRoaXMKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cnVjdHVyZSBpcyBzZXQgdXAgY29ycmVjdGx5IGFzCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aG91Z2ggZGV2aWNlIGlzIGVuY3J5cHRlZCBleGNlcHQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQgdGhlIG1hc3RlciBrZXkgaXMgZW5jcnlwdGVkIHdpdGggdGhlCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0IHBhc3N3b3JkLiAqLwotI2RlZmluZSBDUllQVF9GT1JDRV9DT01QTEVURSAweDIwIC8qIFNldCB3aGVuIHRoZSBhYm92ZSBlbmNyeXB0aW9uIGN5Y2xlIGlzCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcGxldGUuIE9uIG5leHQgY3J5cHRrZWVwZXIgZW50cnksIG1hdGNoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhlIHBhc3N3b3JkLiBJZiBpdCBtYXRjaGVzIGZpeCB0aGUgbWFzdGVyCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5IGFuZCByZW1vdmUgdGhpcyBmbGFnLiAqLworI2RlZmluZSBDUllQVF9FTkNSWVBUSU9OX0lOX1BST0dSRVNTICAgICAgIFwKKyAgICAweDIgLyogRW5jcnlwdGlvbiBwYXJ0aWFsbHkgY29tcGxldGVkLCBcCisgICAgICAgICAgIGVuY3J5cHRlZF91cHRvIHZhbGlkKi8KKyNkZWZpbmUgQ1JZUFRfSU5DT05TSVNURU5UX1NUQVRFICAgICAgICAgICAgICAgICAgICBcCisgICAgMHg0IC8qIFNldCB3aGVuIHN0YXJ0aW5nIGVuY3J5cHRpb24sIGNsZWFyIHdoZW4gXAorICAgICAgICAgICBleGl0IGNsZWFubHksIGVpdGhlciB0aHJvdWdoIHN1Y2Nlc3Mgb3IgIFwKKyAgICAgICAgICAgY29ycmVjdGx5IG1hcmtlZCBwYXJ0aWFsIGVuY3J5cHRpb24gKi8KKyNkZWZpbmUgQ1JZUFRfREFUQV9DT1JSVVBUICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAweDggLyogU2V0IHdoZW4gZW5jcnlwdGlvbiBpcyBmaW5lLCBidXQgdGhlIFwKKyAgICAgICAgICAgdW5kZXJseWluZyB2b2x1bWUgaXMgY29ycnVwdCAqLworI2RlZmluZSBDUllQVF9GT1JDRV9FTkNSWVBUSU9OICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIDB4MTAgLyogU2V0IHdoZW4gaXQgaXMgdGltZSB0byBlbmNyeXB0IHRoaXMgICAgICAgXAorICAgICAgICAgICAgdm9sdW1lIG9uIGJvb3QuIEV2ZXJ5dGhpbmcgaW4gdGhpcyAgICAgICAgXAorICAgICAgICAgICAgc3RydWN0dXJlIGlzIHNldCB1cCBjb3JyZWN0bHkgYXMgICAgICAgICAgXAorICAgICAgICAgICAgdGhvdWdoI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AgICBfX2xlMzIgZnRyX3NpemU7ICAgICAgICAgICAgIC8qIGluIGJ5dGVzLCBub3QgaW5jbHVkaW5nIGtleSBmb2xsb3dpbmcgKi8KKyAgICBfX2xlMzIgZmxhZ3M7ICAgICAgICAgICAgICAgIC8qIFNlZSBhYm92ZSAqLworICAgIF9fbGUzMiBrZXlzaXplOyAgICAgICAgICAgICAgLyogaW4gYnl0ZXMgKi8KKyAgICBfX2xlMzIgY3J5cHRfdHlwZTsgICAgICAgICAgIC8qIGhvdyBtYXN0ZXJfa2V5IGlzIGVuY3J5cHRlZC4gTXVzdCBiZSBhCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBDUllQVF9UWVBFX1hYWCB2YWx1ZSAqLworICAgIF9fbGU2NCBmc19zaXplOyAgICAgICAgICAgICAgLyogU2l6ZSBvZiB0aGUgZW5jcnlwdGVkIGZzLCBpbiA1MTIgYnl0ZSBzZWN0b3JzICovCisgICAgX19sZTMyIGZhaWxlZF9kZWNyeXB0X2NvdW50OyAvKiBjb3VudCBvZiAjIG9mIGZhaWxlZCBhdHRlbXB0cyB0byBkZWNyeXB0IGFuZAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW91bnQsIHNldCB0byAwIG9uIHN1Y2Nlc3NmdWwgbW91bnQgKi8KKyAgICB1bnNpZ25lZCBjaGFyIGNyeXB0b190eXBlX25hbWVbTUFYX0NSWVBUT19UWVBFX05BTUVfTEVOXTsgLyogVGhlIHR5cGUgb2YgZW5jcnlwdGlvbgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWVkZWQgdG8gZGVjcnlwdCB0aGlzCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnRpdGlvbiwgbnVsbCB0ZXJtaW5hdGVkICovCisgICAgX19sZTMyIHNwYXJlMjsgICAgICAgICAgICA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ogKDEgPDwgTikgKi8KKyAgICBfX2xlOCByX2ZhY3RvcjsgICAgICAgIC8qICgxIDw8IHIpICovCisgICAgX19sZTggcF9mYWN0b3I7ICAgICAgICAvKiAoMSA8PCBwKSAqLworICAgIF9fbGU2NCBlbmNyeXB0ZWRfdXB0bzsgLyogSWYgd2UgYXJlIGluIHN0YXRlIENSWVBUX0VOQ1JZUFRJT05fSU5fUFJPR1JFU1MgYW5kCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZSBoYXZlIHRvIHN0b3AgKGUuZy4gcG93ZXIgbG93KSB0aGlzIGlzIHRoZSBsYXN0CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmNyeXB0ZWQgNTEyIGJ5dGUgc2VjdG9yLiovCisgICAgX19sZTggaGFzaF9maXJzdF9ibG9ja1tTSEEyNTZfRElHRVNUX0xFTkdUSF07IC8qIFdoZW4gQ1JZUFRfRU5DUllQVElPTl9JTl9QUk9HUkVTUworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXQsIGhhc2ggb2YgZmlyc3QgYmxvY2ssIHVzZWQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG8gdmFsaWRhdGUgYmVmb3JlIGNvbnRpbnVpbmcqLwogCi0gIC8qIGtleV9tYXN0ZXIga2V5LCB1c2VkIHRvIHNpZ24gdGhlIGRlcml2ZWQga2V5IHdoaWNoIGlzIHRoZW4gdXNlZCB0byBnZW5lcmF0ZQotICAgKiB0aGUgaW50ZXJtZWRpYXRlIGtleQotICAgKiBUaGlzIGtleSBzaG91bGQgYmUgdXNlZCBmb3Igbm8gb3RoZXIgcHVycG9zZXMhIFdlIHVzZSB0aGlzIGtleSB0byBzaWduIHVucGFkZGVkIAotICAgKiBkYXRhLCB3aGljaCBpcyBhY2NlcHRhYmxlIGJ1dCBvbmx5IGlmIHRoZSBrZXkgaXMgbm90IHJldXNlZC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AgIHN3aXRjaChyYykgewotICAgICAgICBjYXNlIDA6Ci0gICAgICAgICAgICBMT0coSU5GTykgPDwgIkZpbGVzeXN0ZW0gY2hlY2sgY29tcGxldGVkIE9LIjsKLSAgICAgICAgICAgIHJldHVybiAwOworICAgICAgICBzd2l0Y2ggKHJjKSB7CisgICAgICAgICAgICBjYXNlIDA6CisgICAgICAgICAgICAgICAgTE9HKElORk8pIDw8ICJGaWxlc3lzdGVtIGNoZWNrIGNvbXBsZXRlZCBPSyI7CisgICAgICAgICAgICAgICAgcmV0dXJuIDA7CiAKLSAgICAgICAgY2FzZSAyOgotICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiRmlsZXN5c3RlbSBjaGVjayBmYWlsZWQgKG5vdCBhIEZBVCBmaWxlc3lzdGVtKSI7Ci0gICAgICAgICAgICBlcnJubyA9IEVOT0RBVEE7Ci0gICAgICAgICAgICByZXR1cm4gLTE7CisgICAgICAgICAgICBjYXNlIDI6CisgICAgICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiRmlsZXN5c3RlbSBjaGVjayBmYWlsZWQgKG5vdCBhIEZBVCBmaWxlc3lzdGVtKSI7CisgICAgICAgICAgICAgICAgZXJybm8gPSBFTk9EQVRBOworICAgICAgICAgICAgICAgIHJldHVybiAtMTsKIAotICAgICAgICBjYXNlIDQ6Ci0gICAgICAgICAgICBpZiAocGFzcysrIDw9IDMpIHsKLSAgICAgICAgICAgICAgICBMT0coV0FSTklORykgPDwgIkZpbGVzeXN0ZW0gbW9kaWZpZWQgLSByZWNoZWNraW5nIChwYXNzICIgPDwgcGFzcyA8PCAiKSI7Ci0gICAgICAgICAgICAgICAgY29udGludWU7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGYWlsaW5nIGNoZWNrIGFmdGVyIHRvbyBtYW55IHJlY2hlY2tzIjsKLSAgICAgICAgICAgIGVycm5vID0gRUlPOwotICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgY2FzZSA0OgorICAgICAgICAgICAgICAgIGlmIChwYXNzKysgPD0gMykgeworICAgICAgICAgICAgICAgICAgICBMT0coV0FSTklORykgPDwgIkZpbGVzeXN0ZW0gbW9kaWZpZWQgLSByZWNoZWNraW5nIChwYXNzICIgPDwgcGFzcyA8PCAiKSI7CisgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGYWlsaW5nIGNoZWNrIGFmdGVyIHRvbyBtYW55IHJlY2hlY2tzIjsKKyAgICAgICAgICAgICAgICBlcnJubyA9IEVJTzsKKyAgICAgICAgICAgICAgICByZXR1cm4gLTE7CiAKLSAgICAgICAgY2FzZSA4OgotICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiRmlsZXN5c3RlbSBjaGVjayBmYWlsZWQgKG5vIGZpbGVzeXN0ZW0pIjsKLSAgICAgICAgICAgIGVycm5vID0gRU5PREFUQTsKLSAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAgICAgICAgIGNhc2UgODoKKyAgICAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGaWxlc3lzdGVtIGNoZWNrIGZhaWxlZCAobm8gZmlsZXN5c3RlbSkiOworICAgICAgICAgICAgICAgIGVycm5vID0gRU5PREFUQTsKKyAgICAgICAgICAgICAgICByZXR1cm4gLTE7CiAKLSAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkZpbGVzeXN0ZW0gY2hlY2sgZmFpbGVkICh1bmtub3duIGV4aXQgY29kZSAiIDw8IHJjIDw8ICIpIjsKLSAgICAgICAgICAgIGVycm5vID0gRUlPOwotICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGaWxlc3lzdGVtIGNoZWNrIGZhaWxlZCAodW5rbm93biBleGl0IG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kIGRvX2NvbGRib290KERJUiogZCwgaW50IGx2bCkgeworICAgIHN0cnVjdCBkaXJlbnQqIGRlOwogICAgIGludCBkZmQsIGZkOwogCiAgICAgZGZkID0gZGlyZmQoZCk7CiAKICAgICBmZCA9IG9wZW5hdChkZmQsICJ1ZXZlbnQiLCBPX1dST05MWSB8IE9fQ0xPRVhFQyk7Ci0gICAgaWYoZmQgPj0gMCkgeworICAgIGlmIChmZCA+PSAwKSB7CiAgICAgICAgIHdyaXRlKGZkLCAiYWRkXG4iLCA0KTsKICAgICAgICAgY2xvc2UoZmQpOwogICAgIH0KIAotICAgIHdoaWxlKChkZSA9IHJlYWRkaXIoZCkpKSB7Ci0gICAgICAgIERJUiAqZDI7CisgICAgd2hpbGUgKChkZSA9IHJlYWRkaXIoZCkpKSB7CisgICAgICAgIERJUiogZDI7CiAKLSAgICAgICAgaWYgKGRlLT5kX25hbWVbMF0gPT0gJy4nKQotICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIGlmIChkZS0+ZF9uYW1lWzBdID09ICcuJykgY29udGludWU7CiAKLSAgICAgICAgaWYgKGRlLT5kX3R5cGUgIT0gRFRfRElSICYmIGx2bCA+IDApCi0gICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgaWYgKGRlLT5kX3R5cGUgIT0gRFRfRElSICYmIGx2bCA+IDApIGNvbnRpbnVlOwogCiAgICAgICAgIGZkID0gb3BlbmF0KGRmZCwgZGUtPmRfbmFtZSwgT19SRE9OTFkgfCBPX0RJUkVDVE9SWSB8IE9fQ0xPRVhFQyk7Ci0gICAgICAgIGlmKGZkIDwgMCkKLSAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICBpZiAoZmQgPCAwKSBjb250aW51ZTsKIAogICAgICAgICBkMiA9IGZkb3BlbmRpcihmZCk7Ci0gICAgICAgIGlmKGQyID09IDApCisgICAgICAgIGlmIChkMiA9PSAwKQogICAgICAgICAgICAgY2xvc2UoZmQpOwogICAgICAgICBlbHNlIHsKICAgICA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aGF0ZXZlciBpcyBzaWxrLXNjcmVlbmVkIG9uIHRoZSBjYXJkLiAgVG8gcmVkdWNlCi0gICAgICAgIC8vIHVzZXIgY29uZnVzaW9uLCB0aGlzIGxpc3QgZG9lc24ndCBjb250YWluIHdoaXRlLWxhYmVsIG1hbmZpZC4KLSAgICAgICAgc3dpdGNoIChtYW5maWQpIHsKLSAgICAgICAgY2FzZSAweDAwMDAwMzogbUxhYmVsID0gIlNhbkRpc2siOyBicmVhazsKLSAgICAgICAgY2FzZSAweDAwMDAxYjogbUxhYmVsID0gIlNhbXN1bmciOyBicmVhazsKLSAgICAgICAgY2FzZSAweDAwMDAyODogbUxhYmVsID0gIkxleGFyIjsgYnJlYWs7Ci0gICAgICAgIGNhc2UgMHgwMDAwNzQ6IG1MYWJlbCA9ICJUcmFuc2NlbmQiOyBicmVhazsKLSAgICAgICAgfQotICAgICAgICBicmVhazsKLSAgICB9Ci0gICAgZGVmYXVsdDogewotICAgICAgICBpZiAoaXNWaXJ0aW9CbGtEZXZpY2UobWFqb3JJZCkpIHsKLSAgICAgICAgICAgIExPRyhERUJVRykgPDwgIlJlY29nbml6ZWQgZXhwZXJpbWVudGFsIGJsb2NrIG1ham9yIElEICIgPDwgbWFqb3JJZAotICAgICAgICAgICAgICAgICAgICA8PCAiIGFzIHZpcnRpby1ibGsgKGVtdWxhdG9yJ3MgdmlydHVhbCBTRCBjYXJkIGRldmljZSkiOworICAgICAgICBjYXNlIGtNYWpvckJsb2NrTG9vcDogewogICAgICAgICAgICAgbUxhYmVsID0gIlZpcnR1YWwiOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KLSAgICAgICAgTE9HKFdBUk5JTkcpIDw8ICJVbnN1cHBvcnRlZCBibG9jayBtYWpvciB0eXBlICIgPDwgbWFqb3JJZDsKLSAgICAgICAgcmV0dXJuIC1FTk9UU1VQOwotICAgIH0KKyAgICAgICAgLy8gY2xhbmctZm9ybWF0IG9mZgorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaUE6IGNhc2Uga01ham9yQmxvY2tTY3NpQjogY2FzZSBrTWFqb3JCbG9ja1Njc2lDOgorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaUQ6IGNhc2Uga01ham9yQmxvY2tTY3NpRTogY2FzZSBrTWFqb3JCbG9ja1Njc2lGOgorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaUc6IGNhc2Uga01ham9yQmxvY2tTY3NpSDogY2FzZSBrTWFqb3JCbG9ja1Njc2lJOgorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaUo6IGNhc2Uga01ham9yQmxvY2tTY3NpSzogY2FzZSBrTWFqb3JCbG9ja1Njc2lMOgorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaU06IGNhc2Uga01ham9yQmxvY2tTY3NpTjogY2FzZSBrTWFqb3JCbG9ja1Njc2lPOgorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaVA6IHsKKyAgICAgICAgICAgIC8vIGNsYW5nLWZvcm1hdCBvbgorICAgICAgICAgICAgc3RkOjpzdHJpbmcgcGF0aChtU3lzUGF0aCArICIvZGV2aWNlL3ZlbmRvciIpOworICAgICAgICAgICAgc3RkOjpzdHJpbmcgdG1wOworICAgICAgICAgICAgaWYgKCFSZWFkRmlsZVRvU3RyaW5nKHBhdGgsICZ0bXApKSB7CisgICAgICAgICAgICAgICAgUExPRyhXQVJOSU5HKSA8PCAiRmFpbGVkIHRvIHJlYWQgdmVuZG9yIGZyb20gIiA8PCBwYXRoOworICAgICAgICAgICAgICAgIHJldHVybiAtZXJybm87CisgICAgICAgICAgICB9CisgICAgICAgICAgICB0bXAgPSBhbmRyb2lkOjpiYXNlOjpUcmltKHRtcCk7CisgICAgICAgICAgICBtTGFiZWwgPSB0bXA7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIGtNYWpvckJsb2NrTW1jOiB7CisgICAgICAgICAgICBzdGQ6OnN0cmluZy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aXNrIjsgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSAweDAwMDAxYjogbUxhYmVsID0gIlNhbXN1bmciOyBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIDB4MDAwMDI4OiBtTGFiZWwgPSAiTGV4YXIiOyBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIDB4MDAwMDc0OiBtTGFiZWwgPSAiVHJhbnNjZW5kIjsgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIC8vIGNsYW5nLWZvcm1hdCBvbgorICAgICAgICAgICAgfQorICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgZGVmYXVsdDogeworICAgICAgICAgICAgaWYgKGlzVmlydGlvQmxrRGV2aWNlKG1ham9ySWQpKSB7CisgICAgICAgICAgICAgICAgTE9HKERFQlVHKSA8PCAiUmVjb2duaXplZCBleHBlcmltZW50YWwgYmxvY2sgbWFqb3IgSUQgIiA8PCBtYWpvcklkCisgICAgICAgICAgICAgICAgICAgICAgICAgICA8PCAiIGFzIHZpcnRpby1ibGsgKGVtdWxhdG9yJ3MgdmlydHVhbCBTRCBjYXJkIGRldmljZSkiOworICAgICAgICAgICAgICAgIG1MYWJlbCA9ICJWaXJ0dWFsIjsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChpc052bWVCbGtEZXZpY2UobWFqb3JJZCwgbVN5c1BhdGgpKSB7CisgICAgICAgICAgICAgICAgc3RkOjpzdHJpbmcgcGF0aChtU3lzUGF0aCArICIvZGV2aWNlL21vZGVsIik7CisgICAgICAgICAgICAgICAgc3RkOjpzdHJpbmcgdG1wOworICAgICAgICAgICAgICAgIGlmICghUmVhZEZpbGVUb1N0cmluZyhwYXRoLCAmdG1wKSkgeworICAgICAgICAgICAgICAgICAgICBQTE9HKFdBUk5JTkcpIDw8ICJGYWlsZWQgdG8gcmVhZCB2ZW5kb3IgZnJvbSAiIDw8IHBhdGg7Cisg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NYWpvckJsb2NrU2NzaUs6IGNhc2Uga01ham9yQmxvY2tTY3NpTDoKKyAgICAgICAgY2FzZSBrTWFqb3JCbG9ja1Njc2lNOiBjYXNlIGtNYWpvckJsb2NrU2NzaU46IGNhc2Uga01ham9yQmxvY2tTY3NpTzoKKyAgICAgICAgY2FzZSBrTWFqb3JCbG9ja1Njc2lQOiB7CisgICAgICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb24KKyAgICAgICAgICAgIC8vIFBlciBEb2N1bWVudGF0aW9uL2RldmljZXMudHh0IHRoaXMgaXMgc3RhdGljCiAgICAgICAgICAgICByZXR1cm4gMTU7CiAgICAgICAgIH0KLSAgICB9CisgICAgICAgIGNhc2Uga01ham9yQmxvY2tNbWM6IHsKKyAgICAgICAgICAgIC8vIFBlciBEb2N1bWVudGF0aW9uL2RldmljZXMudHh0IHRoaXMgaXMgZHluYW1pYworICAgICAgICAgICAgc3RkOjpzdHJpbmcgdG1wOworICAgICAgICAgICAgaWYgKCFSZWFkRmlsZVRvU3RyaW5nKGtTeXNmc01tY01heE1pbm9ycywgJnRtcCkgJiYKKyAgICAgICAgICAgICAgICAhUmVhZEZpbGVUb1N0cmluZyhrU3lzZnNNbWNNYXhNaW5vcnNEZXByZWNhdGVkLCAmdG1wKSkgeworICAgICAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkZhaWxlZCB0byByZWFkIG1heCBtaW5vcnMiOworICAgICAgICAgICAgICAgIHJldHVybiAtZXJybm87CisgICAgICAgICAgICB9CisgICAgICAgICAgICByZXR1cm4gc3RkOjpzdG9pKHRtcCk7CisgICAgICAgIH0KKyAgICAgICAgZGVmYXVsdDogeworICAgICAgICAgICAgaWYgKGlzVmlydGlvQmxrRGV2aWNlKG1ham9ySWQpKSB7CisgICAgICAgICAgICAgICAgLy8gZHJpdmVycy9ibG9jay92aXJ0aW9fYmxrLmMgaGFzICIjZGVmaW5lIFBBUlRfQklUUyA0Iiwgc28gbWF4IGlzCisgICAgICAgICAgICAgIC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gICAgICAgICAgIG1SYXdQYXRoLmNfc3RyKCksCiAgICAgICAgICAgICAgICAgbGFiZWwuY19zdHIoKSwKICAgICAgICAgICAgICAgICBOVUxMKSkgeworICAgICAgICAgICAgLy8gY2xhbmctZm9ybWF0IG9uCiAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIGV4ZWMiOwogICAgICAgICB9CiAKQEAgLTEwNCw4ICsxMDUsOCBAQAogCiAgICAgbnNlY3NfdCBzdGFydCA9IHN5c3RlbVRpbWUoU1lTVEVNX1RJTUVfQk9PVFRJTUUpOwogICAgIHdoaWxlIChiZWZvcmUgPT0gR2V0RGV2aWNlKG1GdXNlV3JpdGUpKSB7Ci0gICAgICAgIExPRyhWRVJCT1NFKSA8PCAiV2FpdGluZyBmb3IgRlVTRSB0byBzcGluIHVwLi4uIjsKLSAgICAgICAgdXNsZWVwKDUwMDAwKTsgLy8gNTBtcworICAgICAgICBMT0coREVCVUcpIDw8ICJXYWl0aW5nIGZvciBGVVNFIHRvIHNwaW4gdXAuLi4iOworICAgICAgICB1c2xlZXAoNTAwMDApOyAgLy8gNTBtcwogCiAgICAgICAgIG5zZWNzX3Qgbm93ID0gc3lzdGVtVGltZShTWVNURU1fVElNRV9CT09UVElNRSk7CiAgICAgICAgIGlmIChuYW5vc2Vjb25kc190b19taWxsaXNlY29uZHMobm93IC0gc3RhcnQpID4gNTAwMCkgewpAQCAtMTE0LDggKzExNSw4IEBACiAgICAgICAgIH0KICAgICB9CiAgICAgLyogc2RjYXJkZnMgd2lsbCBoYXZlIGV4aXRlZCBhbHJlYWR5LiBGVVNFIHdpbGwgc3RpbGwgYmUgcnVubmluZyAqLwotICAgIGlmIChURU1QX0ZBSUxVUkVfUkVUUlkod2FpdHBpZChtRnVzZVBpZCwgbnVsbHB0ciwgV05PSEFORykpID09IG1GdXNlUGlkKQotICAgICAgICBtRnVzZVBpZCA9IDA7CisgICAgVEVNUF9GQUlMVVJFX1JFVFJZKHdhaXRw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IGlmICghbVNvdXJjZUtleS5lbXB0eSgpKSB7Ci0gICAgICAgIHVuc2lnbmVkIGxvbmcgbnJfc2VjID0gMDsKLSAgICAgICAgewotICAgICAgICAgICAgdW5pcXVlX2ZkIGxvb3BfZmQob3BlbihtTG9vcFBhdGguY19zdHIoKSwgT19SRFdSIHwgT19DTE9FWEVDKSk7Ci0gICAgICAgICAgICBpZiAobG9vcF9mZC5nZXQoKSA9PSAtMSkgewotICAgICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8IGdldElkKCkgPDwgIiBmYWlsZWQgdG8gb3BlbiBsb29wIjsKLSAgICAgICAgICAgICAgICByZXR1cm4gLTE7Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIGdldF9ibGtkZXZfc2l6ZShsb29wX2ZkLmdldCgpLCAmbnJfc2VjKTsKLSAgICAgICAgICAgIGlmIChucl9zZWMgPT0gMCkgewotICAgICAgICAgICAgICAgIFBMT0coRVJST1IpIDw8IGdldElkKCkgPDwgIiBmYWlsZWQgdG8gZ2V0IGxvb3Agc2l6ZSI7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIC0xOwotICAgICAgICAgICAgfQorICAgICAgICB1aW50NjRfdCBucl9zZWMgPSAwOworICAgICAgICBpZiAoR2V0QmxvY2tEZXY1MTJTZWN0b3JzKG1Mb29wUGF0aCwgJm5yX3NlYykgIT0gT0spIHsKKyAgICAgICAgICAgIFBMT0coRVJST1IpIDw8IGdldElkKCkgPDwgIiBmYWlsZWQgdG8gZ2V0IGxvb3Agc2l6ZSI7CisgICAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgIH0KIAogICAgICAgICBjaGFyIHRtcFtQQVRIX01BWF07Ci0gICAgICAgIGlmIChEZXZtYXBwZXI6OmNyZWF0ZShnZXRJZCgpLmNfc3RyKCksIG1Mb29wUGF0aC5jX3N0cigpLCBtU291cmNlS2V5LmNfc3RyKCksIG5yX3NlYywKLSAgICAgICAgICAgICAgICB0bXAsIFBBVEhfTUF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w3IEBACiAKICAgICBpZiAoIShtRnVzZVBpZCA9IGZvcmsoKSkpIHsKICAgICAgICAgaWYgKGdldE1vdW50RmxhZ3MoKSAmIE1vdW50RmxhZ3M6OmtQcmltYXJ5KSB7CisgICAgICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb2ZmCiAgICAgICAgICAgICBpZiAoZXhlY2woa0Z1c2VQYXRoLCBrRnVzZVBhdGgsCiAgICAgICAgICAgICAgICAgICAgICItdSIsICIxMDIzIiwgLy8gQUlEX01FRElBX1JXCiAgICAgICAgICAgICAgICAgICAgICItZyIsICIxMDIzIiwgLy8gQUlEX01FRElBX1JXCkBAIC0xNzYsOSArMTc0LDExIEBACiAgICAgICAgICAgICAgICAgICAgIG1SYXdQYXRoLmNfc3RyKCksCiAgICAgICAgICAgICAgICAgICAgIHN0YWJsZU5hbWUuY19zdHIoKSwKICAgICAgICAgICAgICAgICAgICAgTlVMTCkpIHsKKyAgICAgICAgICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb24KICAgICAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiRmFpbGVkIHRvIGV4ZWMiOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgLy8gY2xhbmctZm9ybWF0IG9mZgogICAgICAgICAgICAgaWYgKGV4ZWNsKGtGdXNlUGF0aCwga0Z1c2VQYXRoLAogICAgICAgICAgICAgICAgICAgICAiLXUiLCAiMTAyMyIsIC8vIEFJRF9NRURJQV9SVwogICAgICAgICAgICAgICAgICAgICAiLWciLCAiMTAyMyIsIC8vIEFJRF9NRURJQV9SVwpAQCAtMTg2LDYgKzE4Niw3IEBACiAgICAgICAgICAgICAgICAgICAgIG1SYXdQYXRoLmNfc3RyKCksCiAgICAgICAgICAgICAgICAgICAgIHN0YWJsZU5hbWUuY19zdHIoKSwKICAgICAgICAgICAgICAgICAgICAgTlVMTCkpIHsKKyAgICAgICAgICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb24KICA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OnVuaXF1ZV9mZCBmZChURU1QX0ZBSUxVUkVfUkVUUlkob3Blbih0YXJnZXQuY19zdHIoKSwgT19XUk9OTFksIDApKSk7CisgICAgICAgIGlmIChmZCA9PSAtMSkgeworICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiU2VjdXJlIGRpc2NhcmQgb3BlbiBmYWlsZWQgZm9yOiAiIDw8IHRhcmdldDsKKyAgICAgICAgICAgIHJldHVybiAwOworICAgICAgICB9CisgICAgICAgIF9fdTMyIHNldCA9IDE7CisgICAgICAgIGlvY3RsKGZkLCBGMkZTX0lPQ19TRVRfUElOX0ZJTEUsICZzZXQpOworCiAgICAgICAgIExPRyhERUJVRykgPDwgIlNlY3VyZWx5IGRpc2NhcmRpbmcgJyIgPDwgdGFyZ2V0IDw8ICInIHVubGluaz0iIDw8IG9wdGlvbnMudW5saW5rOwogICAgICAgICBpZiAoIXNlY2Rpc2NhcmRfcGF0aCh0YXJnZXQpKSB7CiAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJTZWN1cmUgZGlzY2FyZCBmYWlsZWQgZm9yOiAiIDw8IHRhcmdldDsKQEAgLTY3LDYgKzkyLDggQEAKICAgICAgICAgICAgICAgICBQTE9HKEVSUk9SKSA8PCAiVW5hYmxlIHRvIHVubGluazogIiA8PCB0YXJnZXQ7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KKyAgICAgICAgc2V0ID0gMDsKKyAgICAgICAgaW9jdGwoZmQsIEYyRlNfSU9DX1NFVF9QSU5fRklMRSwgJnNldCk7CiAgICAgICAgIExPRyhERUJVRykgPDwgIkRpc2NhcmRlZDogIiA8PCB0YXJnZXQ7CiAgICAgfQogICAgIHJldHVybiAwOwpAQCAtNzQsMjkgKzEwMSwyOSBAQAogCiBuYW1lc3BhY2UgewogCi1ib29sIHJlYWRfY29tbWFuZF9saW5lKGludCBhcmdjLCBjb25zdCBjaGFyICogY29uc3QgYXJndltdLCBPcHRpb25zICZvcHRpb25zKSB7Citib29sIHJlYWRfY29tbWFuZF9saW5lKGludCBhcmdjLCBjb25zdCBjaGFyKiBjb25zdCBhcmd2W10sIE9wdGlvbnMmIG9wdGlvbnMpIHsKICAgICBmb3IgKGludCBpID0gMTsgaSA8IGFyZ2M7IGkrKykgewogICAgICAgICBpZiAoIXN0cmNtcCgiLS1uby11bmxpbmsiLCBhcmd2W2ldKSkgewogICAgICAgICAgICAgb3B0aW9ucy51bmxpbmsgPSBmYWxzZTsKICAgICAgICAgfSBlbHNlIGlmICghc3RyY21wKCItLSIsIGFyZ3ZbaV0pKSB7Ci0gICAgICAgICAgICBmb3IgKGludCBqID0gaSsxOyBqIDwgYXJnYzsgaisrKSB7Ci0gICAgICAgICAgICAgICAgaWYgKGFyZ3Zbal1bMF0gIT0gJy8nKSByZXR1cm4gZmFsc2U7IC8vIE11c3QgYmUgYWJzb2x1dGUgcGF0aAorICAgICAgICAgICAgZm9yIChpbnQgaiA9IGkgKyAxOyBqIDwgYXJnYzsgaisrKSB7CisgICAgICAgICAgICAgICAgaWYgKGFyZ3Zbal1bMF0gIT0gJy8nKSByZXR1cm4gZmFsc2U7ICAvLyBNdXN0IGJlIGFic29sdXRlIHBhdGgKICAgICAgICAgICAgICAgICBvcHRpb25zLnRhcmdldHMuZW1wbGFjZV9iYWNrKGFyZ3Zbal0pOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgcmV0dXJuIG9wdGlvbnMudGFyZ2V0cy5zaXplKCkgPiAwOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgcmV0dXJuIGZhbHNlOyAvLyBVbmtub3duIG9wdGlvbgorICAgICAgICAgICAgcmV0dXJuIGZhbHNlOyAgLy8gVW5rbm93biBvcHRpb24KICAgICAgICAgfQogICAgIH0KLSAgICByZXR1cm4gZmFsc2U7IC8vICItLSIgbm90IGZvdW5kCisgICAgcmV0dXJuIGZhbHNlOyAgLy8gIi0tIiBub3QgZm91bmQKIH0KIAotdm9pZCB1c2FnZShjb25zdCBjaGFyICpwcm9nbm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AgICAgICAgIGlmIChlcnJvciAhPSBLTV9FUlJPUl9PSykgewogICAgICAgICAgICAgU0xPR0UoIkZhaWxlZCB0byBnZW5lcmF0ZSBrZXltYXN0ZXIxIGtleSwgZXJyb3IgJWQiLCBlcnJvcik7CiAgICAgICAgICAgICByYyA9IC0xOwpAQCAtMTkwLDE1ICsxODUsMTMgQEAKIAogICAgICAgICBrZXkgPSAodWludDhfdCopa2V5X2Jsb2Iua2V5X21hdGVyaWFsOwogICAgICAgICBrZXlfc2l6ZSA9IGtleV9ibG9iLmtleV9tYXRlcmlhbF9zaXplOwotICAgIH0KLSAgICBlbHNlIGlmIChrZXltYXN0ZXIwX2RldikgeworICAgIH0gZWxzZSBpZiAoa2V5bWFzdGVyMF9kZXYpIHsKICAgICAgICAga2V5bWFzdGVyX3JzYV9rZXlnZW5fcGFyYW1zX3QgcGFyYW1zOwogICAgICAgICBtZW1zZXQoJnBhcmFtcywgJ1wwJywgc2l6ZW9mKHBhcmFtcykpOwogICAgICAgICBwYXJhbXMucHVibGljX2V4cG9uZW50ID0gUlNBX0VYUE9ORU5UOwogICAgICAgICBwYXJhbXMubW9kdWx1c19zaXplID0gUlNBX0tFWV9TSVpFOwogCi0gICAgICAgIGlmIChrZXltYXN0ZXIwX2Rldi0+Z2VuZXJhdGVfa2V5cGFpcihrZXltYXN0ZXIwX2RldiwgVFlQRV9SU0EsICZwYXJhbXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAma2V5LCAma2V5X3NpemUpKSB7CisgICAgICAgIGlmIChrZXltYXN0ZXIwX2Rldi0+Z2VuZXJhdGVfa2V5cGFpcihrZXltYXN0ZXIwX2RldiwgVFlQRV9SU0EsICZwYXJhbXMsICZrZXksICZrZXlfc2l6ZSkpIHsKICAgICAgICAgICAgIFNMT0dFKCJGYWlsZWQgdG8gZ2VuZXJhdGUga2V5cGFpciIpOwogICAgICAgICAgICAgcmMgPSAtMTsKICAgICAgICAgICAgIGdvdG8gb3V0OwpAQCAtMjE5LDI0ICsyMTIsMTkgQEAKICAgICBmdHItPmtleW1hc3Rlcl9ibG9iX3NpemUgPSBrZXlfc2l6ZTsKIAogb3V0OgotICAgIGlmIChrZXltYXN0ZXIwX2RldikKLSAgICAgICAga2V5bWFzdGVyMF9jbG9zZShrZXltYXN0ZXIwX2Rldik7Ci0gICAgaWYgKGtleW1hc3RlcjFfZGV2KQotICAgICAgICBrZXltYXN0ZXIxX2Nsb3NlKGtleW1hc3RlcjFfZGV2KTsKKyAgICBpZiAoa2V5bWFzdGVyMF9kZXYpIGtleW1hc3RlcjBfY2xvc2Uoa2V5bWFzdGVyMF9kZXYpOworICAgIGlmIChrZXltYXN0ZXIxX2Rldikga2V5bWFzdGVyMV9jbG9zZShrZXltYXN0ZXIxX2Rldik7CiAgICAgZnJlZShrZXkpOwogICAgIHJldHVybiByYzsKIH0KIAogLyogVGhpcyBzaWducyB0aGUgZ2l2ZW4gb2JqZWN0IHVzaW5nIHRoZSBrZXltYXN0ZXIga2V5LiAqLwotc3RhdGljIGludCBrZXltYXN0ZXJfc2lnbl9vYmplY3Rfb2xkKHN0cnVjdCBjcnlwdF9tbnRfZnRyICpmdHIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bnNpZ25lZCBjaGFyICpvYmplY3QsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplX3Qgb2JqZWN0X3NpemUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICoqc2lnbmF0dXJlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90ICpzaWduYXR1cmVfc2l6ZSkKLXsKK3N0YXRpYyBpbnQga2V5bWFzdGVyX3NpZ25fb2JqZWN0X29sZChzdHJ1Y3QgY3J5cHRfbW50X2Z0ciogZnRyLCBjb25zdCB1bnNpZ25lZCBjaGFyKiBvYmplY3QsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2l6ZV90IG9iamVjdF9zaXplLCB1bnNpZ25lZCBjaGFyKiogc2lnbmF0dXJlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCogc2lnbmF0dXJlX3NpemUpIHsKICAgICBpbnQgcmMgPSAwOwotICAgIGtleW1hc3RlcjBfZGV2aWNlX3QgKmtleW1hc3RlcjBfZGV2ID0gMDsKLSAgICBrZXltYXN0ZXIxX2RldmljZV90ICprZXltYXN0ZXIxX2RldiA9IDA7CisgICAga2V5bWFzdGVyMF9kZXZpY2VfdCoga2V5bWFzdGVyMF9kZXYgPSAwOworICAgIGtleW1hc3RlcjFfZGV2aWNlX3QqIGtleW1hc3RlcjFfZGV2ID0gMDsKIAogICAgIHVuc2lnbmVkIGNoYXIgdG9fc2lnbltSU0FfS0VZX1NJWkVfQllURVNdOwogICAgIHNpemVfdCB0b19zaWduX3NpemUgPSBzaXplb2YodG9fc2lnbik7CkBAIC0yODQsMzIgKzI3MiwyNSBAQAogICAgICAgICBwYXJhbXMuZGlnZXN0X3R5cGUgPSBESUdFU1RfTk9ORTsKICAgICAgICAgcGFyYW1zLnBhZGRpbmdfdHlwZSA9IFBBRERJTkdfTk9ORTsKIAotICAgICAgICByYyA9IGtleW1hc3RlcjBfZGV2LT5zaWduX2RhdGEoa2V5bWFzdGVyMF9kZXYsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZwYXJhbXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ0ci0+a2V5bWFzdGVyX2Jsb2IsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ0ci0+a2V5bWFzdGVyX2Jsb2Jfc2l6ZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9fc2lnbiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9fc2lnbl9zaXplLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaWduYXR1cmUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hdHVyZV9zaXplKTsKKyAgICAgICAgcmMgPSBrZXltYXN0ZXIwX2Rldi0+c2lnbl9kYXRhKGtleW1hc3RlcjBfZGV2LCAmcGFyYW1zLCBmdHItPmtleW1hc3Rlcl9ibG9iLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnRyLT5rZXltYXN0ZXJfYmxvYl9zaXplLCB0b19zaWduLCB0b19zaWduX3NpemUsIHNpZ25hdHVyZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hdHVyZV9zaXplKTsKICAgICAgICAgZ290byBvdXQ7CiAgICAgfSBlbHNlIGlmIChrZXltYXN0ZXIxX2RldikgewotICAgICAgICBrZXltYXN0ZXJfa2V5X2Jsb2JfdCBrZXkgPSB7IGZ0ci0+a2V5bWFzdGVyX2Jsb2IsIGZ0ci0+a2V5bWFzdGVyX2Jsb2Jfc2l6ZSB9OworICAgICAgICBrZXltYXN0ZXJfa2V5X2Jsb2JfdCBrZXkgPSB7ZnRyLT5rZXltYXN0ZXJfYmxvYiwgZnRyLT5rZXltYXN0ZXJfYmxvYl9zaXplfTsKICAgICAgICAga2V5bWFzdGVyX2tleV9wYXJhbV90IHBhcmFtc1tdID0gewogICAgICAgICAgICAga2V5bWFzdGVyX3BhcmFtX2VudW0oS01fVEFHX1BBRERJTkcsIEtNX1BBRF9OT05FKSwKICAgICAgICAgICAgIGtleW1hc3Rlcl9wYXJhbV9lbnVtKEtNX1RBR19ESUdFU1QsIEtNX0RJR0VTVF9OT05FKSwKICAgICAgICAgfTsKLSAgICAgICAga2V5bWFzdGVyX2tleV9wYXJhbV9zZXRfdCBwYXJhbV9zZXQgPSB7IHBhcmFtcywgc2l6ZW9mKHBhcmFtcykvc2l6ZW9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ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmcGFyYW1fc2V0LCBOVUxMIC8qIG91dF9wYXJhbXMgKi8sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmb3BfaGFuZGxlKTsKKyAgICAgICAgICAgIGVycm9yID0ga2V5bWFzdGVyMV9kZXYtPmJlZ2luKGtleW1hc3RlcjFfZGV2LCBLTV9QVVJQT1NFX1NJR04sICZrZXksICZwYXJhbV9zZXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBOVUxMIC8qIG91dF9wYXJhbXMgKi8sICZvcF9oYW5kbGUpOwogICAgICAgICB9CiAgICAgICAgIGlmIChlcnJvciAhPSBLTV9FUlJPUl9PSykgewogICAgICAgICAgICAgU0xPR0UoIkVycm9yIHN0YXJ0aW5nIGtleW1hc3RlciBzaWduYXR1cmUgdHJhbnNhY3Rpb246ICVkIiwgZXJyb3IpOwpAQCAtMzE3LDExICsyOTgsMTAgQEAKICAgICAgICAgICAgIGdvdG8gb3V0OwogICAgICAgICB9CiAKLSAgICAgICAga2V5bWFzdGVyX2Jsb2JfdCBpbnB1dCA9IHsgdG9fc2lnbiwgdG9fc2lnbl9zaXplIH07CisgICAgICAgIGtleW1hc3Rlcl9ibG9iX3QgaW5wdXQgPSB7dG9fc2lnbiwgdG9fc2lnbl9zaXplfTsKICAgICAgICAgc2l6ZV90IGlucHV0X2NvbnN1bWVkOwotICAgICAgICBlcnJvciA9IGtleW1hc3RlcjFfZGV2LT51cGRhdGUoa2V5bWFzdGVyMV9kZXYsIG9wX2hhbmRsZSwgTlVMTCAvKiBpbl9wYXJhbXMgKi8sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmaW5wdXQsICZpbnB1dF9jb25zdW1lZCwgTlVMTCAvKiBvdXRfcGFyYW1zICovLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTlVMTCAvKiBvdXRwdXQgKi8pOworICAgICAgICBlcnJvciA9IGtleW1hc3RlcjFfZGV2LT51cGRhdGUoa2V5bWFzdGVyMV9kZXYsIG9wX2hhbmRsZSwgTlVMTCAvKiBpbl9wYXJhbXMgKi8sICZpbnB1dCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZpbnB1dF9jb25zdW1lZCwgTlVMTCAvKiBvdXRfcGFyYW1zICovLCBOVUxMIC8qIG91dHB1dCAqLyk7CiAgICAgICAgIGlmIChlcnJvciAhPSBLTV9FUlJPUl9PSykgewogICAgICAgICAgICAgU0xPR0UoIkVycm9yIHNlbmRpbmcgZGF0YSB0byBrZXltYXN0ZXIgc2lnbmF0dXJlIHRyYW5zYWN0aW9uOiAlZCIsIGVycm9yKTsKICAgICAgICAgICAgIHJjID0gLTE7CkBAIC0zMzcsOCArMzE3LDcgQEAKIAogICAgICAgICBrZXltYXN0ZXJfYmxvYl90IHRtcF9zaWc7CiAgICAgICAgIGVycm9yID0ga2V5bWFzdGVyMV9kZXYtPmZpbmlzaChrZXltYXN0ZXIxX2Rldiwgb3BfaGFuZGxlLCBOVUxMIC8qIGluX3BhcmFtcyAqLywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5VTEwgLyogdmVyaWZ5IHNpZ25hdHVyZSAqLywgTlVMTCAvKiBvdXRfcGFyYW1zICovLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnRtcF9zaWcpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTlVMTCAvKiB2ZXJpZnkgc2lnbmF0dXJlICovLCBOVUxMIC8qIG91dF9wYXJhbXMgKi8sICZ0bXBfc2lnKTsKICAgICAgICAgaWYgKGVycm9yICE9IEtNX0VSUk9SX09LKSB7CiAgICAgICAgICAgICBTTE9HRSgiRXJyb3IgZmluaXNoaW5nIGtleW1hc3RlciBzaWduYXR1cmUgdHJhbnNhY3Rpb246ICVkIiwgZXJy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gICAgICAgICAgIGNvbnN0IHNpemVfdCBvYmplY3Rfc2l6ZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKipzaWduYXR1cmUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QgKnNpZ25hdHVyZV9zaXplKQoteworc3RhdGljIGludCBrZXltYXN0ZXJfc2lnbl9vYmplY3RfbmV3KHN0cnVjdCBjcnlwdF9tbnRfZnRyKiBmdHIsIGNvbnN0IHVuc2lnbmVkIGNoYXIqIG9iamVjdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplX3Qgb2JqZWN0X3NpemUsIHVuc2lnbmVkIGNoYXIqKiBzaWduYXR1cmUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90KiBzaWduYXR1cmVfc2l6ZSkgewogICAgIHVuc2lnbmVkIGNoYXIgdG9fc2lnbltSU0FfS0VZX1NJWkVfQllURVNdOwogICAgIHNpemVfdCB0b19zaWduX3NpemUgPSBzaXplb2YodG9fc2lnbik7CiAgICAgbWVtc2V0KHRvX3NpZ24sIDAsIFJTQV9LRVlfU0laRV9CWVRFUyk7CkBAIC00NDMsMTIgKzQxNSwxMCBAQAogbmFtZXNwYWNlIGFuZHJvaWQgewogCiBjbGFzcyBDcnlwdEZzVGVzdCA6IHB1YmxpYyB0ZXN0aW5nOjpUZXN0IHsKLXByb3RlY3RlZDoKLSAgICB2aXJ0dWFsIHZvaWQgU2V0VXAoKSB7Ci0gICAgfQorICBwcm90ZWN0ZWQ6CisgICAgdmlydHVhbCB2b2lkIFNldFVwKCkge30KIAotICAgIHZpcnR1YWwgdm9pZCBUZWFyRG93bigpIHsKLSAgICB9CisgICAgdmlydHVhbCB2b2lkIFRlYXJEb3duKCkge30KIH07CiAKIFRFU1RfRihDcnlwdEZzVGVzdCwgU2NyeXB0SGlkbGl6YXRpb25FcXVpdmFs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