Fix unidiomatic use of vsnprintf(). * Don't terminate an already-terminated buffer. * Consistently use 1024-byte buffers. * While here, consistently use ap for a va_list.