ZGlmZiAtLWdpdCBhL21idGsvbWJ0a19saWIvc3JjL21idGtfaHR0cC5jIGIvbWJ0ay9tYnRrX2xpYi9zcmMvbWJ0a19odHRwLmMKaW5kZXggZTYzMDY0ZS4uYjRlNThlZSAxMDA3NTUKLS0tIGEvbWJ0ay9tYnRrX2xpYi9zcmMvbWJ0a19odHRwLmMKKysrIGIvbWJ0ay9tYnRrX2xpYi9zcmMvbWJ0a19odHRwLmMKQEAgLTEwLDYgKzEwLDkgQEAKICNpbmNsdWRlIDxzdGRsaWIuaD4KICNpbmNsdWRlIDxjdHlwZS5oPgogI2luY2x1ZGUgPHN0cmluZy5oPgorI2luY2x1ZGUgPGZjbnRsLmg+CisjaW5jbHVkZSA8dW5pc3RkLmg+CisjaW5jbHVkZSA8c3lzL3N0YXQuaD4KIAogI2luY2x1ZGUgIm1idGtfaHR0cF9iYXNlLmgiCiAjaW5jbHVkZSAibWJ0a19odHRwLmgiCkBAIC0xOCw2ICsyMSw5IEBACiAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgogICAgIENvbnN0YW50cyBhbmQgTWFjcm9zCiAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworI2RlZmluZSBCVUZGRVJfU0laRSAxMDI0CisKKwogCiAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgogICAgIFZhcmlhYmxlczpsb2NhbApAQCAtNDkzLDYgKzQ5OSw3IEBACiAgICAgY2hhciBsaW5lW0JVRkZFUl9TSVpFXTsKICAgICBjaGFyICpwdHIgPSBOVUxMOwogICAgIGludCBsZW4gPSAwOworCWludCB3cml0ZV9sZW4gPSAwOwogICAgIHdoaWxlKChsZW4gPSBtYnRrX2h0dHBfcmVhZF9saW5lKHNlc3Npb24tPnNvY2tfZmQsbGluZSxCVUZGRVJfU0laRSkpID4gMCkKICAgICB7CiAgICAgICAgIGlmKCFtZW1jbXAobGluZSwiXHJcbiIsMikpCkBAIC01MDAsNyArNTA3LDcgQEAKICAgICAgICAgICAgIExPR0QoIlJlYWQgZW1wdHkgbGluZS4iKTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9Ci0KKwkJCiAgICAgICAgIC8vIERlbGV0ZSAiXHJcbiIKICAgICAgICAgcHRyID0gbGluZSArIGxlbiAtIDE7IC8vIFBvaW50IHRvIGxhc3QgY2hhci4KICAgICAgICAgd2hpbGUoaHR0cF9pc19zcGFjZV9jaGFyKCpwdHIpKQpAQCAtNTExLDEzICs1MTgsMjkgQEAKICAgICAgICAgfQogCiAgICAgICAgIExPR1YoIkxJTkU6JXMiLGxpbmUpOwotCi0gICAgICAgIGlmKGh0dHBfaGFuZGxlc1tzZXNzaW9uLT5oYW5kbGVfaWRdLnNob3dfcnNwX2hlYWRlciAmJgotICAgICAgICAgICBodHRwX2hhbmRsZXNbc2Vzc2lvbi0+aGFuZGxlX2lkXS5kYXRhX2NiKQorICAgICAgICBpZihzZXNzaW9uLT50eXBlKQogICAgICAgICB7Ci0gICAgICAgICAgICBodHRwX2hhbmRsZXNbc2Vzc2lvbi0+aGFuZGxlX2lkXS5kYXRhX2NiKHNlc3Npb24tPmlkLAotICAgICAgICAgICAgICAgICAgICBNQlRLX0hUVFBfREFUQV9IRUFERVIsbGluZSxsZW4pOworICAgICAgICAgICAgLyoKKyAgICAJCWlmKHNlc3Npb24tPmZpbGVfZmQgPj0gMCkKKyAgICAJCXsKKyAgICAJCQl3cml0ZV9sZW4gPSB3cml0ZShzZXNzaW9uLT5maWxlX2ZkLCBsaW5lLCBsZW4pOworICAgIAkgICAgICAgIGlmKHdyaXRlX2xlbiA8IGxlbikgeworICAgIAkgICAgICAgICAgICBMT0dFKCJ3cml0ZSgpIGZhaWwuIik7CisgICAgCSAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAJICAgICAgICB9CisgICAgCQl9CisgICAgCQkqLwogICAgICAgICB9CisgICAgICAgIGVsc2UKKyAgICAgICAgeworICAgICAgICAgICAgaWYoaHR0cF9oYW5kbGVzW3Nlc3Npb24tPmhhbmRsZV9pZF0uc2hvd19yc3BfaGVhZGVyICYmCisgICAgICAgICAgICAgICBodHRwX2hhbmRsZXNbc2Vzc2lvbi0+aGFuZGxlX2lkXS5kYXRhX2NiKQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIGh0dHBfaGFuZGxlc1tzZXNzaW9uLT5oYW5kbGVfaWRdLmRhdGFfY2Ioc2Vzc2lvbi0+aWQsCisgICAgICAgICAgICAgICAgICAgICAgICBNQlRLX0hUVFBfREFUQV9IRUFERVIsbGluZSxsZW4pOworICAgICAgICAgICAgfQorCisgICAgICAgIH0gICAgICAKIAogICAgICAgICBpZighbWVtY21wKGxpbmUsIkhUVFAvIiw1KSkgICAvLyAiSFRUUC8xLjEgMjAwIE9LIgogICAgICAgICB7CkBAIC02NTIsNyArNjc1LDcgQEAKICAgICBjaGFyIHJlYWRfYnVmW0JVRkZFUl9TSVpFICsgMV07CiAgICAgaW50IHJlYWRfbGVuID0gMDsKICAgICBjaGFyIGNodW5rX2J1ZltCVUZGRVJfU0laRSArIDFdOwotICAgIGludCBjaHVua19sZW47CisgICAgaW50IGNodW5rX2xlbiA9IDAsIHdyaXRlX2xlbj0wOwogICAgIGh0dHBfY2h1bmtfaW5pdCgmY2h1bmtlcik7CiAgICAgd2hpbGUoVFJVRSkKICAgICB7CkBAIC02NzQsOSArNjk3LDI0IEBACiAgICAgICAgIExPR0QoIlJlYWQgY2h1bmtfbGVuOiVkIixjaHVua19sZW4pOwogICAgICAgICBjaHVua19idWZbY2h1bmtfbGVuXSA9ICdcMCc7CiAKLSAgICAgICAgaWYoaHR0cF9oYW5kbGVzW3Nlc3Npb24tPmhhbmRsZV9pZF0uZGF0YV9jYikKLSAgICAgICAgICAgIGh0dHBfaGFuZGxlc1tzZXNzaW9uLT5oYW5kbGVfaWRdLmRhdGFfY2Ioc2Vzc2lvbi0+aWQsCi0gICAgICAgICAgICAgICAgICAgIE1CVEtfSFRUUF9EQVRBX0NPTlRFTlQsY2h1bmtfYnVmLGNodW5rX2xlbik7CisgICAgICAgIGlmKHNlc3Npb24tPnR5cGUpCisgICAgICAgIHsKKyAgICAJCWlmKHNlc3Npb24tPmZpbGVfZmQgPj0gMCkKKyAgICAJCXsKKyAgICAJCQl3cml0ZV9sZW4gPSB3cml0ZShzZXNzaW9uLT5maWxlX2ZkLCBjaHVua19idWYsIGNodW5rX2xlbik7CisgICAgCSAgICAgICAgaWYod3JpdGVfbGVuIDwgY2h1bmtfbGVuKSB7CisgICAgCSAgICAgICAgICAgIExPR0UoIndyaXRlKCkgZmFpbC4iKTsKKyAgICAJICAgICAgICAgICAgcmV0dXJuIC0xOworICAgIAkgICAgICAgIH0KKyAgICAJCX0KKyAgICAgICAgfQorICAgICAgICBlbHNlCisgICAgICAgIHsKKyAgICAgICAgICAgIGlmKGh0dHBfaGFuZGxlc1tzZXNzaW9uLT5oYW5kbGVfaWRdLmRhdGFfY2IpCisgICAgICAgICAgICAgICAgaHR0cF9oYW5kbGVzW3Nlc3Npb24tPmhhbmRsZV9pZF0uZGF0YV9jYihzZXNzaW9uLT5pZCwKKyAgICAgICAgICAgICAgICAgICAgICAgIE1CVEtfSFRUUF9EQVRBX0NPTlRFTlQsY2h1bmtfYnVmLGNodW5rX2xlbik7CisgICAgICAgICAgICB1c2xlZXAoMTAwMDAwKTsKKyAgICAgICAgfQogCiAgICAgICAgIGlmKENIVU5LRV9TVE9QID09IGNodW5rX2NvZGUpCiAgICAgICAgIHsKQEAgLTY5OSw2ICs3MzcsNyBAQAogI2RlZmluZSBCVUZGRVJfU0laRSAyMDQ4CiAgICAgY2hhciByZWFkX2J1ZltCVUZGRVJfU0laRSArIDFdOwogICAgIGludCByZWFkX2xlbiA9IDA7CisJaW50IHdyaXRlX2xlbiA9IDA7CiAgICAgaW50NjQgcmVhZF9jb3VudCA9IDA7CiAgICAgd2hpbGUoVFJVRSkKICAgICB7CkBAIC03MTAsMjQgKzc0OSw1MiBAQAogICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICB9CiAKKyAgICAgICAgCiAgICAgICAgIGlmKHJlYWRfY291bnQgKyByZWFkX2xlbiA+PSBzZXNzaW9uLT5yc3AuY29udGVudF9sZW5ndGgpICAgLy8gUmVhZCBkYXRhIGNvbXBsZXRlLgogICAgICAgICB7CisgICAgICAgICAgICBpZihzZXNzaW9uLT5maWxlX2ZkID49IDApCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgd3JpdGVfbGVuID0gd3JpdGUoc2Vzc2lvbi0+ZmlsZV9mZCwgcmVhZF9idWYsIHJlYWRfbGVuKTsKKyAgICAgICAgICAgICAgICBpZih3cml0ZV9sZW4gPCByZWFkX2xlbikgeworICAgICAgICAgICAgICAgICAgICBMT0dFKCJ3cml0ZSgpIGZhaWwuIik7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisKICAgICAgICAgICAgIGlmKGh0dHBfaGFuZGxlc1tzZXNzaW9uLT5oYW5kbGVfaWRdLmRhdGFfY2IpCiAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgaHR0cF9oYW5kbGVzW3Nlc3Npb24tPmhhbmRsZV9pZF0uZGF0YV9jYihzZXNzaW9uLT5pZCwKICAgICAgICAgICAgICAgICAgICAgICAgIE1CVEtfSFRUUF9EQVRBX0NPTlRFTlQscmVhZF9idWYsc2Vzc2lvbi0+cnNwLmNvbnRlbnRfbGVuZ3RoIC0gcmVhZF9jb3VudCk7Ci0KKyAgICAgICAgCiAgICAgICAgICAgICAgICAgaHR0cF9oYW5kbGVzW3Nlc3Npb24tPmhhbmRsZV9pZF0uZGF0YV9jYihzZXNzaW9uLT5pZCwKICAgICAgICAgICAgICAgICAgICAgICAgIE1CVEtfSFRUUF9EQVRBX0NPTVBMRVRFLE5VTEwsMCk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogCi0gICAgICAgIGlmKGh0dHBfaGFuZGxlc1tzZXNzaW9uLT5oYW5kbGVfaWRdLmRhdGFfY2IpCi0gICAgICAgICAgICBodHRwX2hhbmRsZXNbc2Vzc2lvbi0+aGFuZGxlX2lkXS5kYXRhX2NiKHNlc3Npb24tPmlkLAotICAgICAgICAgICAgICAgICAgICBNQlRLX0hUVFBfREFUQV9DT05URU5ULHJlYWRfYnVmLHJlYWRfbGVuKTsKKyAgICAgICAgTE9HRSgicmVhZF9sZW4gOiVkLCBzZXNzaW9uLT50eXBlOiVkXG4iLCByZWFkX2xlbiwgc2Vzc2lvbi0+dHlwZSk7CisgICAgICAgIGlmKHNlc3Npb24tPnR5cGUpCisgICAgICAgIHsKKyAgICAgICAgICAgIGlmKHNlc3Npb24tPmZpbGVfZmQgPj0gMCkKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICB3cml0ZV9sZW4gPSB3cml0ZShzZXNzaW9uLT5maWxlX2ZkLCByZWFkX2J1ZiwgcmVhZF9sZW4pOworICAgICAgICAgICAgICAgIGlmKHdyaXRlX2xlbiA8IHJlYWRfbGVuKSB7CisgICAgICAgICAgICAgICAgICAgIExPR0UoIndyaXRlKCkgZmFpbC4iKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBlbHNlCisgICAgICAgIHsKKyAgICAgICAgICAgIGlmKGh0dHBfaGFuZGxlc1tzZXNzaW9uLT5oYW5kbGVfaWRdLmRhdGFfY2IpCisgICAgICAgICAgICAgICAgaHR0cF9oYW5kbGVzW3Nlc3Npb24tPmhhbmRsZV9pZF0uZGF0YV9jYihzZXNzaW9uLT5pZCwKKyAgICAgICAgICAgICAgICAgICAgICAgIE1CVEtfSFRUUF9EQVRBX0NPTlRFTlQscmVhZF9idWYscmVhZF9sZW4pOworICAgICAgICAgICAgdXNsZWVwKDEwMDAwMCk7CisgICAgICAgIH0KIAogICAgICAgICByZWFkX2NvdW50ICs9IHJlYWRfbGVuOworICAgICAgICBMT0dFKCJtYnRrMTExMTExMTExMTExMTExMTExMTExMTExM2J5IHJlYWRfY291bnQ6JWQsIHJlYWRfbGVuOiVkXG4uIiwgcmVhZF9jb3VudCwgcmVhZF9sZW4pOworCiAgICAgfQogCiAgICAgcmV0dXJuIDA7CkBAIC03MzksNiArODA2LDcgQEAKICNkZWZpbmUgQlVGRkVSX1NJWkUgMjA0OAogICAgIGNoYXIgcmVhZF9idWZbQlVGRkVSX1NJWkUgKyAxXTsKICAgICBpbnQgcmVhZF9sZW4gPSAwOworCWludCB3cml0ZV9sZW4gPSAwOwogICAgIHdoaWxlKFRSVUUpCiAgICAgewogICAgICAgICByZWFkX2xlbiA9IG1idGtfaHR0cF9yZWFkKHNlc3Npb24tPnNvY2tfZmQscmVhZF9idWYsQlVGRkVSX1NJWkUsMTAwMCk7CkBAIC03NTEsMTggKzgxOSwzNyBAQAogICAgICAgICAgICAgLy9yZXR1cm4gLTE7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQotCisJCQogICAgICAgICByZWFkX2J1ZltyZWFkX2xlbl0gPSAnXDAnOwogCi0gICAgICAgIGlmKGh0dHBfaGFuZGxlc1tzZXNzaW9uLT5oYW5kbGVfaWRdLmRhdGFfY2IpCi0gICAgICAgICAgICBodHRwX2hhbmRsZXNbc2Vzc2lvbi0+aGFuZGxlX2lkXS5kYXRhX2NiKHNlc3Npb24tPmlkLAotICAgICAgICAgICAgICAgICAgICBNQlRLX0hUVFBfREFUQV9DT05URU5ULHJlYWRfYnVmLHJlYWRfbGVuKTsKKyAgICAgICAgaWYoc2Vzc2lvbi0+dHlwZSkKKyAgICAgICAgeworICAgIAkJaWYoc2Vzc2lvbi0+ZmlsZV9mZCA+PSAwKQorICAgIAkJeworICAgIAkJCXdyaXRlX2xlbiA9IHdyaXRlKHNlc3Npb24tPmZpbGVfZmQsIHJlYWRfYnVmLCByZWFkX2xlbik7CisgICAgCSAgICAgICAgaWYod3JpdGVfbGVuIDwgcmVhZF9sZW4pIHsKKyAgICAJICAgICAgICAgICAgTE9HRSgid3JpdGUoKSBmYWlsLiIpOworICAgIAkgICAgICAgICAgICByZXR1cm4gLTE7CisgICAgCSAgICAgICAgfQorICAgIAkJfQorICAgICAgICB9CisgICAgICAgIGVsc2UKKyAgICAgICAgeworICAgICAgICAgICAgaWYoaHR0cF9oYW5kbGVzW3Nlc3Npb24tPmhhbmRsZV9pZF0uZGF0YV9jYikKKyAgICAgICAgICAgICAgICBodHRwX2hhbmRsZXNbc2Vzc2lvbi0+aGFuZGxlX2lkXS5kYXRhX2NiKHNlc3Npb24tPmlkLAorICAgICAgICAgICAgICAgICAgICAgICAgTUJUS19IVFRQX0RBVEFfQ09OVEVOVCxyZWFkX2J1ZixyZWFkX2xlbik7CisKKyAgICAgICAgICAgIHVzbGVlcCgxMDAwMDApOworICAgICAgICB9CisgICAgICAgIExPR0UoIm1idGsxMTExMTExMTExMTExMTExMTExMTExMTExYnkgZ2VuZXJhbFxuLiIpOworCiAgICAgfQogCiAgICAgaWYoaHR0cF9oYW5kbGVzW3Nlc3Npb24tPmhhbmRsZV9pZF0uZGF0YV9jYikKICAgICAgICAgaHR0cF9oYW5kbGVzW3Nlc3Npb24tPmhhbmRsZV9pZF0uZGF0YV9jYihzZXNzaW9uLT5pZCwKICAgICAgICAgICAgICAgICBNQlRLX0hUVFBfREFUQV9DT01QTEVURSxOVUxMLDApOwogCisKICAgICByZXR1cm4gMDsKIH0KIApAQCAtNzcwLDcgKzg1NywxOCBAQAogewogICAgIExPR0koIlN0YXJ0IEhUVFAgcmVhZC4iKTsKICAgICBpbnQgcmVzdWx0ID0gMDsKKwkKIC8vICAgIHVzbGVlcCg1MDAwMDApOworCWlmKHNlc3Npb24tPnR5cGUpCisJeworCQlzZXNzaW9uLT5maWxlX2ZkID0gb3BlbigiL2h0dHBfdGVzdC50eHQiLCBPX1dST05MWXxPX1RSVU5DfE9fQ1JFQVR8T19BUFBFTkQsIDA2NjYpOworCQorCQlpZihzZXNzaW9uLT5maWxlX2ZkIDwgMCkgeworCQkJTE9HRSgib3BlbigpIGZhaWwuIik7CisJCQlyZXR1cm4gLTE7CisJCX0KKwl9CisKICAgICBzZXNzaW9uLT5zdGF0ZSA9IEhUVFBfU0VTU0lPTl9TVEFURV9SRUFEX0hFQURFUjsKICAgICBpZihodHRwX2hlYWRlcl9yZWFkKHNlc3Npb24pKQogICAgIHsKQEAgLTc4NSw2ICs4ODMsNyBAQAogICAgICAgICB7CiAgICAgICAgICAgICBpZihodHRwX3Nlc3Npb25fcmVhZF9ieV9jaHVuayhzZXNzaW9uKSkKICAgICAgICAgICAgIHsKKyAgICAgICAgICAgIAlMT0dFKCJodHRwX3Nlc3Npb25fcmVhZF9ieV9jaHVuayBmYWlsLiIpOwogICAgICAgICAgICAgICAgIHJlc3VsdCA9IC0xOwogICAgICAgICAgICAgICAgIGdvdG8gcmVhZF9lbmQ7CiAgICAgICAgICAgICB9CkBAIC03OTMsNiArODkyLDcgQEAKICAgICAgICAgewogICAgICAgICAgICAgaWYoaHR0cF9zZXNzaW9uX3JlYWRfYnlfbGVuZ3RoKHNlc3Npb24pKQogICAgICAgICAgICAgeworICAgICAgICAgICAgCUxPR0UoImh0dHBfc2Vzc2lvbl9yZWFkX2J5X2xlbmd0aCBmYWlsLiIpOwogICAgICAgICAgICAgICAgIHJlc3VsdCA9IC0xOwogICAgICAgICAgICAgICAgIGdvdG8gcmVhZF9lbmQ7CiAgICAgICAgICAgICB9CkBAIC04MDEsNiArOTAxLDcgQEAKICAgICAgICAgewogICAgICAgICAgICAgaWYoaHR0cF9zZXNzaW9uX3JlYWRfYnlfZ2VuZXJhbChzZXNzaW9uKSkKICAgICAgICAgICAgIHsKKyAgICAgICAgICAgIAlMT0dFKCJodHRwX3Nlc3Npb25fcmVhZF9ieV9nZW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24gIT0gTlVMTCkKKyAgICB7CisJCWh0dHBfaGFuZGxlc1tzZXNzaW9uLT5oYW5kbGVfaWRdLmRhdGFfZmlsZV9jYiA9IGRhdGFfZmlsZV9jYjsKKwkKKwkJaWYodHlwZSkgLy8xIHJlYWQgZmlsZSBzaXplCisJCXsKKwkJCWludCBzaXplID0gbWJ0a19odHRwX2dldF9maWxlX3NpemUoIi9odHRwX3Rlc3QudHh0Iik7CisJCQlodHRwX2hhbmRsZXNbc2Vzc2lvbi0+aGFuZGxlX2lkXS5kYXRhX2ZpbGVfY2IodHlwZSwgIE5VTEwsIHNpemUpOworCQl9ZWxzZQkvL3JlYWQgZmlsZSBkYXRhCisJCXsKKwkJCWNoYXIgYnVmWzEwMjQrMV0gPSB7MH07CisJCQlpbnQgcmV0ID0gMDsKKworICAgICAgICAgICAgaW50IGZkID0gb3BlbigiL2h0dHBfdGVzdC50eHQiLCBPX1JET05MWSk7CisgICAgICAgICAgICBpZiAoZmQgPT0gLTEpIHsKKyAgICAgICAgICAgIAlwcmludGYoIk9wZW4gZmlsZSAlcyBmYWlsZWRcbiIsICIvaHR0cF90ZXN0LnR4dCIpOworICAgICAgICAgICAgCXJldHVybiAtMTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgaWYob2Zmc2V0KQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIGxzZWVrKGZkLCBvZmZzZXQsIFNFRUtfU0VUKTsKKyAgICAgICAgICAgIH0KKy8vICAgICAgICAgICAgdXNsZWVwKDUwMDAwMCk7CisgICAgICAgICAgICBpbnQgaW5kZXggPSAwOworICAgICAgICAgICAgd2hpbGUoMSkKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICBtZW1zZXQoYnVmLDAsIHNpemVvZihidWYpKTsKKyAgICAgICAgICAgICAgICByZXQgPSByZWFkKGZkLCBidWYsIDEwMjQpOworICAgICAgICAgICAgICAgIHByaW50ZigicmV0ID0gJWQgLCAiLCByZXQpOworICAgICAgICAgICAgICAgIHVzbGVlcCgxMDAwMDApOworICAgICAgICAgICAgICAgIExPR0UoIm1idGssIHJlYWQgZmlsZTolc1xuIiwgYnVmKTsKKyAgICAgICAgICAgICAgICBpZihyZXQgPD0gMCkKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgICAgICAgICBodHRwX2hhbmRsZXNbc2Vzc2lvbi0+aGFuZGxlX2lkXS5kYXRhX2ZpbGVfY2IodHlwZSwgYnVmLCByZXQpOworICAgICAgICAgICAgICAgIGluZGV4Kys7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBjbG9zZShmZCk7CisgICAgICAgICAgICBwcmludGYoIiVkXG4iLCBpbmRleCk7CisKKyAgICAgICAgICAgIExPR0UoInJlYWQoKWVuZCAgaW5kZXg7OiVkLCByZXQ6JWQiLGluZGV4LHJldCk7CisJCX0KKwl9CisKKworCXJldHVybiAwOworfQorCisKKworCg==