diff --git a/docs/libssh2_knownhost_writeline.3 b/docs/libssh2_knownhost_writeline.3 index 9303849c..eee6f2fa 100644 --- a/docs/libssh2_knownhost_writeline.3 +++ b/docs/libssh2_knownhost_writeline.3 @@ -23,7 +23,8 @@ the 'type' output format. \fIbuflen\fP is the size of the \fIbuffer\fP. See RETURN VALUE about the size. \fIoutlen\fP must be a pointer to a size_t variable that will get the output -length stored +length of the stored data chunk. The number does not included the trailing +zero! \fItype\fP specifies what file type it is, and \fILIBSSH2_KNOWNHOST_FILE_OPENSSH\fP is the only currently supported diff --git a/src/knownhost.c b/src/knownhost.c index 525f60f3..77d98cb0 100644 --- a/src/knownhost.c +++ b/src/knownhost.c @@ -728,7 +728,8 @@ knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts, rc = LIBSSH2_ERROR_BUFFER_TOO_SMALL; } - *outlen = nlen; + /* we report the full length of the data with the trailing zero excluded */ + *outlen = nlen-1; return rc; }