Ensure 'BufSize' >= 1.

Also fix typo which treats the log message length as buffer size,
thereby causing memory corruption if the latter is less than the former.