When encoding a value for a large varlen column (e.g. varchar(max), nvarchar(max), varbinary(max)), tiberius writes the value in a single chunk, then writes a zero length chunk to signal the end of the column data. However, if the value being encoded has length zero, the first chunk already ends the column data, and the server will incorrectly interpret the extra zero as part of the next column's data (or whatever follows this column in the buffer). This PR skips the terminating zero if the value has length zero.
When encoding a value for a large varlen column (e.g.
varchar(max)
,nvarchar(max)
,varbinary(max)
), tiberius writes the value in a single chunk, then writes a zero length chunk to signal the end of the column data. However, if the value being encoded has length zero, the first chunk already ends the column data, and the server will incorrectly interpret the extra zero as part of the next column's data (or whatever follows this column in the buffer). This PR skips the terminating zero if the value has length zero.