ZGlmZiAtLWdpdCBhL2FwL2FwcC9mc19jaGVjay9tdGQuYyBiL2FwL2FwcC9mc19jaGVjay9tdGQuYwpuZXcgZmlsZSBtb2RlIDEwMDc1NQppbmRleCAwMDAwMDAwLi45YTYwNzE0Ci0tLSAvZGV2L251bGwKKysrIGIvYXAvYXBwL2ZzX2NoZWNrL210ZC5jCkBAIC0wLDAgKzEsODQwIEBACisjZGVmaW5lIF9HTlVfU09VUkNFDQorI2luY2x1ZGUgPHN0ZGlvLmg+DQorI2luY2x1ZGUgPHN0ZGxpYi5oPg0KKyNpbmNsdWRlIDx1bmlzdGQuaD4NCisjaW5jbHVkZSA8c3RyaW5nLmg+DQorI2luY2x1ZGUgPHN5cy90eXBlcy5oPg0KKyNpbmNsdWRlIDxzeXMvc3RhdC5oPg0KKyNpbmNsdWRlIDxmY250bC5oPg0KKyNpbmNsdWRlIDxzeXMvdmZzLmg+DQorDQorDQorI2luY2x1ZGUgPG10ZC9tdGQtYWJpLmg+DQorI2luY2x1ZGUgPGVycm5vLmg+DQorDQorI2luY2x1ZGUgPHN5cy9pb2N0bC5oPg0KKyNpbmNsdWRlICJmc19jaGVjay5oIg0KKyNpbmNsdWRlICJjZmdfYXBpLmgiDQorI2luY2x1ZGUgInB1Yl9kZWJ1Z19pbmZvLmgiDQorDQorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTWFjcm8gZGVmaW5pdGlvbnMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKg0KKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovDQorI2RlZmluZSBNT1VOVFNfSU5GT19GSUxFCQkJCSIvcHJvYy9tb3VudHMiDQorDQorI2RlZmluZSBOVl9GU19GQUNfTUFJTl9QQV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91YmkpOw0KKwkJfQ0KKwl9DQorDQorCXJldHVybiB2b2xfbnVtOw0KK30NCisNCisNCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCisqILqvyv3D+7PGo7ogcmVhZF9maWxlDQorKiC5psTcw+jK9qO6ILbByKHOxLz+DQorKiCyzsr9y7XD96O6IChJTikNCisqICAgICAgICAgICAgcF9maWxlOiAgzsS8/g0KKyogICAgICAgICAgICBsZW46ICAgILOktsgNCisqICAgICAgICAgICAgKE9VVCkNCisqILe1ILvYINa1o7qzybmmt7W72LbByKG1xM7EvP4sILfx1PK3tbvYMA0KKyogxuTL/Mu1w/ejure1u9jWtbX308PV38rNt8UNCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCitzdGF0aWMgdW5zaWduZWQgY2hhciAqcmVhZF9maWxlKGNvbnN0IGNoYXIgKnBfZmlsZSwgdW5zaWduZWQgaW50ICpsZW4pDQorew0KKwlGSUxFICogZmQgIAkJPSAwOw0KKyAgICBzdHJ1Y3Qgc3RhdCBidWYgPSB7MH07DQorCXVuc2lnbmVkIGNoYXIgKiBwX2J1ZiAgPSBOVUxMOw0KKw0KKwlpZihwX2ZpbGUgPT0gTlVMTCkNCisJCXJldHVybiBOVUxMOw0KKwkNCisgICAgaWYoc3RhdChwX2ZpbGUsICZidWYpIDwgMCkNCisgICAgew0KKwkJcHJpbnRmKCJyZWFkX2ZpbGUgc3RhdCAlcyBmYWlsZWRcbiIsIHBfZmlsZSk7DQorCQlzY19kZWJ1Z19pbmZvX3JlY29yZChNT0RVTEVfSURfQVBfRlNfQ0hFQ0ssICJyZWFkX2ZpbGUgc3RhdCAlcyBmYWlsZWRcbiIsIHBfZmlsZSk7DQorICAgICAgICByZXR1cm4gTlVMTDsNCisgICAgfQ0KKwkNCisJZmQgPSBmb3BlbihwX2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maWxlDQorKiC5psTcw+jK9qO6ILHIvc/Ev7HqzsS8/rrN1LTOxLz+yse38dK70fkNCisqILLOyv3LtcP3o7ogKElOKQ0KKyogICAgICAgICAgICBwX2RzdF9maWxlOiAgxL+x6s7EvP4NCisqICAgICAgICAgICAgcF9zcmNfZmlsZTogINS0zsS8/g0KKyogICAgICAgICAgICAoT1VUKQ0KKyogt7Ugu9gg1rWjus7EvP7Su9H5t7W72DAsILfx1PK3tbvYLTENCisqIMbky/zLtcP3o7oNCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCitzdGF0aWMgaW50IGNvbXBhcmVfZmlsZShjb25zdCBjaGFyICpwX2RzdF9maWxlLCBjb25zdCBjaGFyICpwX3NyY19maWxlKQ0KK3sNCisJdW5zaWduZWQgY2hhciAqcF9kc3Q7DQorCXVuc2lnbmVkIGNoYXIgKnBfc3JjOw0KKwl1bnNpZ25lZCBpbnQgZHN0X2xlbjsNCisJdW5zaWduZWQgaW50IHNyY19sZW47DQorDQorCWlmKHBfZHN0X2ZpbGUgPT0gTlVMTCB8fCBwX3NyY19maWxlID09IE5VTEwpDQorCQlyZXR1cm4gLTE7DQorDQorCXBfZHN0ID0gcmVhZF9maWxlKHBfZHN0X2ZpbGUsICZkc3RfbGVuKTsNCisJaWYoIXBfZHN0KQ0KKwkJcmV0dXJuIC0xOw0KKwkNCisJcF9zcmMgPSByZWFkX2ZpbGUocF9zcmNfZmlsZSwgJnNyY19sZW4pOw0KKwlpZighcF9zcmMpDQorCXsNCisJCWZyZWUocF9kc3QpOw0KKwkJcmV0dXJuIC0xOw0KKwl9DQorCQ0KKwlpZihkc3RfbGVuICE9IHNyY19sZW4pDQorCXsNCisJCWZyZWUocF9zcmMpOw0KKwkJZnJlZShwX2RzdCk7DQorCQkNCisJCXByaW50ZigiY29tcGFyZV9maWxlIHNpemUgZHN0YnVmID0gJWQsIHNyY2J1ZiA9ICVkXG4iLCBkc3RfbGVuLCBzcmNfbGVuKTsNCisJCXNjX2RlYnVnX2luZm9fcmVjb3JkKE1PRFVMRV9JRF9BUF9GU19DSEVDSywgImNvbXBhcmVfZmlsZSBzaXplIGRzdGJ1ZiA9ICVkLCBzcmNidWYgPSAlZFxuIiwgZHN0X2xlbiwgc3JjX2xlbik7DQorCQlyZXR1cm4gLTE7DQorCX0NCisNCisJaWYobWVtY21wKHBfc3JjLCBwX2RzdCwgc3JjX2xlbikgIT0gMCkNCisJew0KKwkJZnJlZShwX3NyYyk7DQorCQlmcmVlKHBfZHN0KTsNCisJCXByaW50ZigiY29tcGFyZV9maWxlIG1lbWNtcCBub3Qgc2FtZVxuIik7DQorCQlzY19kZWJ1Z19pbmZvX3JlY29yZChNT0RVTEVfSURfQVBfRlNfQ0hFQ0ssICJjb21wYXJlX2ZpbGUgbWVtY21wIG5vdCBzYW1lXG4iKTsNCisJCXJldHVybiAtMTsNCisJfQ0KKw0KKwlmcmVlKHBfc3JjKTsNCisJZnJlZShwX2RzdCk7DQorCQ0KKyAgICByZXR1cm4gMDsNCit9DQorDQorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQorKiC6r8r9w/uzxqO6IGNoZWNrX2ZpbGVzX2FjY2Vzcw0KKyoguabE3MPoyvajuiC87LLpdXNlcmRhdGHOxLz+z7XNs8/CtcTOxLz+yse38bTm1NrH0tPQtsHQtMioz94NCisqILLOyv3LtcP3o7ogzt4NCisqILe1ILvYINa1o7q87LLp1f2zo7e1u9gwLCC38dTyt7W72C0xo6y9+NDQdXNlcmRhdGG31sf4tcSywbP9DQorKiDG5Mv8y7XD96O6DQorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovDQorc3RhdGljIGludCBjaGVja19maWxlc19hY2Nlc3MoKQ0KK3sNCisJaWYoYW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5mby5mX2JhdmFpbCAgPCBDT05GSUdfQkxPQ0tfU0laRSAqIFVTRVJEQVRBX1JFU0VUX0ZSRUVfQkxPQ0tfTEVWRUwpKQ0KKyAgICAgICAgcmV0dXJuIC0xOw0KKyNlbmRpZg0KKw0KKyAgICBmZCA9IG9wZW4oZnNja25hbWUsIE9fV1JPTkxZIHwgT19DUkVBVCB8IE9fVFJVTkMsIDA2NDQpOw0KKyAgICBpZiAoZmQgPCAwKQ0KKyAgICB7DQorICAgICAgICBwcmludGYoIm9wZW4gJXMgZmFpbGVkIGVycm5vICVkXG4iLCBmc2NrbmFtZSwgZXJybm8pOw0KKwkJc2NfZGVidWdfaW5mb19yZWNvcmQoTU9EVUxFX0lEX0FQX0ZTX0NIRUNLLCAib3BlbiAlcyBmYWlsZWQgZXJybm8gJWRcbiIsIGZzY2tuYW1lLCBlcnJubyk7DQorICAgICAgICByZXR1cm4gLTE7DQorICAgIH0NCisgICAgd2hpbGUgKGxlbiA+IDApDQorICAgIHsNCisgICAgICAgIHJlcyA9IHdyaXRlKGZkLCBwdHIsIGxlbik7DQorICAgICAgICBpZiAocmVzIDwgMCkNCisgICAgICAgIHsNCisgICAgICAgICAgICBpZiAoZXJybm8gPT0gRUlOVFIpDQorICAgICAgICAgICAgew0KKyAgICAgICAgICAgICAgICByZXMgPSAwOw0KKyAgICAgICAgICAgIH0NCisgICAgICAgICAgICBlbHNlDQorICAgICAgICAgICAgew0KKyAgICAgICAgICAgICAgICBwcmludGYoIndyaXRlICVzIGZhaWxlZCBlcnJubyAlZFxuIiwgZnNja25hbWUsIGVycm5vKTsNCisJCQkJc2NfZGVidWdfaW5mb19yZWNvcmQoTU9EVUxFX0lEX0FQX0ZTX0NIRUNLLCAid3JpdGUgJXMgZmFpbGVkIGVycm5vICVkXG4iLCBmc2NrbmFtZSwgZXJybm8pOw0KKyAgICAgICAgICAgICAgICByZXQgPSAtMTsNCisgICAgICAgICAgICAgICAgYnJlYWs7DQorICAgICAgICAgICAgfQ0KKyAgICAgICAgfQ0KKyAgICAgICAgcHRyICs9IHJlczsNCisgICAgICAgIGxlbiAtPSByZXM7DQorICAgIH0NCisNCisgICAgDQorICAgIGlmIChjbG9zZShmZCkgPCAwKQ0KKyAgICB7DQorICAgICAgICBwcmludGYoImNsb3NlICVzIGZhaWxlZCBlcnJubyAlZFxuIiwgZnNja25hbWUsIGVycm5vKTsNCisJCXNjX2RlYnVnX2luZm9fcmVjb3JkKE1PRFVMRV9JRF9BUF9GU19DSEVDSywgImNsb3NlICVzIGZhaWxlZCBlcnJubyAlZFxuIiwgZnNja25hbWUsIGVycm5vKTsNCisgICAgICAgIHJldHVybiAtMTsNCisgICAgfQ0KKyAgICByZXR1cm4gcmV0Ow0KK30NCisNCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCisqILqvyv3D+7PGo7ogY2hlY2tfdXNlcmRhdGFfaXNfbm9ybWFsDQorKiC5psTcw+jK9qO6ILzssul1c2VyZGF0YbfWx/jPwsPmtcTOxLz+yse38dX9s6OjrMjnufu05tTa0uyzo6Os1PLQ6NKq1tjQwrvWuLR1c2VyZGF0YbfWx/gNCisqILLOyv3LtcP3o7ogKElOKQ0KKyogICAgICAgICAgICBkc3RfZmlsZTogIMS/serOxLz+DQorKiAgICAgICAgICAgIHNyY19maWxlOiAg1LTOxLz+DQorKiAgICAgICAgICAgIChPVVQpDQorKiC3tSC72CDWtaO6vOyy6dX9s6O3tbvYMCwg0OjSqtbY0MK71ri0t9bH+Le1u9gtMQ0KKyogxuTL/Mu1w/ejug0KKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLw0KK2ludCBjaGVja191c2VyZGF0YV9pc19ub3JtYWwoKQ0KK3sNCisJc3RydWN0IHN0YXQgZmFjX252X2J1ZiA9IHswfTsNCisgICAgc3RydWN0IHN0YXQgd29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