rxdebug: NUL-terminate version before printing 08/12908/4
authorAndrew Deason <adeason@dson.org>
Thu, 15 Feb 2018 22:41:33 +0000 (16:41 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 16 Feb 2018 00:38:33 +0000 (19:38 -0500)
commita66629eac4dda4eea37b4f06e0850641cb2a7387
treed0d9b51ef5ec5cf67583c58c17b9d0b439588374
parent4f7550dcaf9375046514cdd97cea0f667e955e9f
rxdebug: NUL-terminate version before printing

Currently, 'rxdebug -version' never initializes the buffer we read the
version string into. Usually this is not noticeable, since all OpenAFS
binaries tend to pad the Rx version response packet with NULs, so we
get back several NULs to terminate the string. However, this is not
guaranteed, and if we do not get back a NUL-terminated string, we can
easily read beyond the end of the buffer.

To avoid this, initialize the 'version' buffer with NULs before we do
anything, and set the last byte to NUL, in case we exactly filled the
buffer.

Change-Id: I1b1ae546c01f018a9b4e198f918c2d9eb86015d6
Reviewed-on: https://gerrit.openafs.org/12908
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Andrew Deason <adeason@sinenomine.net>
src/rxdebug/rxdebug.c