From 320450201a65bc69233e5bd595f2a0deb964cd78 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 14 Jun 2009 14:27:15 +0200 Subject: [PATCH] After a mention from Ben Kibbey we now let knownhost_writeline() return the length of the actual data it returns, excluding the trailing zero. I also updated the man page for libssh2_knownhost_writeline() accordingly. --- docs/libssh2_knownhost_writeline.3 | 3 ++- src/knownhost.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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; }