ccf8de0874
1/ Replace sprintf() with snprintf() (and check for truncation). 2/ Prevent an integer overflow of ub->siz. The "tot_read--" is needed to avoid an off-by-one overflow in "ub->buf[tot_read] = '\0'". It is safe to decrement tot_read here, because we know that tot_read is equal to ub->siz (and ub->siz is very large). We believe that truncation is a better option than failure (implementing failure instead should be as easy as replacing the "tot_read--" with "tot_read = 0").