Fix potential buffer overrun.


Fixed buffer overrun by recomputing available remaining space at each
point. Note, we could use strlcat for exactly this situation, using the
full buffer length, but since buffer length - 1 was used in other places,
got the code closest to the original.

Change-Id: Id38ba34949b7e25ae8acadce1c24e080aebf06ae
1 file changed