///////////////////////////// // TaggedDataInput methods // ///////////////////////////// public Message ReadMessage(FlexBuffer buf1) { buf = buf1; // lengthBudget is how many array elements total are reasonable to // allocate while parsing this message. the largest value comes as each // byte of the incoming message turned into an array element. the total // will always be lower than this as often it takes multiple bytes to // make a single array element. so, each time we make an array, we // deduct the specified length from lengthBudget. if the result is // negative, then either the incoming message is misformed or someone is // trying to spoof us. lengthBudget = buf.Avail(); try { Message msg = StartMessage(); ReadKeysAndValues(msg); EndMessage(msg); return(msg); } finally { buf = null; lengthBudget = 0; } }