ZGlmZiAtLWdpdCBhL2FwL2xpYi9saWJ2b2ljZS92b2ljZV9idWZmZXIuYyBiL2FwL2xpYi9saWJ2b2ljZS92b2ljZV9idWZmZXIuYwpuZXcgZmlsZSBtb2RlIDEwMDc1NQppbmRleCAwMDAwMDAwLi5iYTRlMzNlCi0tLSAvZGV2L251bGwKKysrIGIvYXAvbGliL2xpYnZvaWNlL3ZvaWNlX2J1ZmZlci5jCkBAIC0wLDAgKzEsNTYxIEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCisqKiCw5sioy/nT0CAoQykyMDE1LCDW0NDLzajRtrnJt93T0M/euavLvqGjDQorKiogDQorKiogzsS8/sP7s8Y6ICAgICB2b2ljZV9idWZmZXIuYw0KKyoqIM7EvP6x6sq2OiAgICAgDQorKiogxNrI3dWq0qo6ICAgIA0KKyoqIMq508O3vbeoOiAgICAgDQorKiogDQorKiog0N64xMjVxtogICAgICAgILDmsb66xSAgICAgINDeuMSx6rzHICAgICAgICDQ3rjEyMsgICAgICAgICAg0N64xMTayN0NCisqKiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0KKyoqIDIwMjMvMDcvMTggICAgIFYxLjAgICAgICAgIENyZWF0ZSAgICAgICAgICB4eHEgICAgICAgILS0vagNCisqKiANCisqICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCisNCisjaW5jbHVkZSA8c3RkaW8uaD4NCisjaW5jbHVkZSA8c3RkbGliLmg+DQorI2luY2x1ZGUgPGFzc2VydC5oPg0KKyNpbmNsdWRlIDxlcnJuby5oPg0KKyNpbmNsdWRlIDxzeXMvdHlwZXMuaD4NCisjaW5jbHVkZSA8c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JTEwMDApID09IDApew0KKyAgICAgICAgICAgIHByaW50ZigiJXM6IHR4X29wdGNvdW50PSVkIVxuIiwgX19mdW5jX18sIHR4X29wdGNvdW50KTsNCisNCisgICAgICAgICAgICBpZih0eF9vcHRjb3VudCA9PSAxMDAwMDAwKQ0KKyAgICAgICAgICAgICAgICB0eF9vcHRjb3VudCA9IDA7DQorCQl9DQorDQorCQkvL3dyaXRlIHRvIHBzDQorCQl3X3NpemUgPSB2b2ljZV9idWZmZXJfd3JpdGUodmJfcmVjLmZkLCBidWYsIHNpemUpOw0KKyAgICAgICAgDQorICAgICAgICBpZih3X3NpemUgPD0gMCl7DQorICAgICAgICAJZmlyc3Rfd3JlcnJfZmxhZysrOw0KKwkJCVZCX0lOVF9PVkVSRkxPVyhmaXJzdF93cmVycl9mbGFnKTsNCisgICAgICAgICAgICANCisJCQlpZihmaXJzdF93cmVycl9mbGFnID09MSl7DQorICAgICAgICAgICAgCXByaW50ZigiJXM6IGVycm9yIHdyaXRpbmcgZGF0YSFcbiIsIF9fZnVuY19fKTsNCisJCQl9DQorCQkJaWYoKGZpcnN0X3dyZXJyX2ZsYWcgJSA1MDApID09IDApew0KKyAgICAgICAgICAgIAlwcmludGYoIiVzOiBmaXJzdF93cmVycl9mbGFnPSVkIVxuIiwgX19mdW5jX18sIGZpcnN0X3dyZXJyX2ZsYWcpOw0KKwkJCX0NCisgICAgICAgICAgICANCisgICAgICAgICAgICBjb250aW51ZTsNCisgICAgICAgIH0NCisJCWVsc2V7DQorCQkJZmlyc3Rfd3JlcnJfZmxhZyA9IDA7DQorCQl9DQorICAgIH0NCisgICAgDQorICAgIHJldHVybiAwOw0KK30NCisNCitzdGF0aWMgaW50IHZiX3RocmVhZF9jcmVhdGUoIGNvbnN0IGNoYXIgKm5hbWUscHRocmVhZF90CSp0aHJlYWRfdCwgdmJfdGhyZWFkX3Byb2MgKnByb2MsIA0KKwkJCQkJCQkJaW50IHN0YWNrX3NpemUsIHVuc2lnbmVkIHByaW9ya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