Subject: Re: [libssh2] #181: _libssh2_debug doesnt terminate buffer

Re: [libssh2] #181: _libssh2_debug doesnt terminate buffer

From: libssh2 Trac <>
Date: Wed, 23 Jun 2010 08:53:24 -0000

#181: _libssh2_debug doesnt terminate buffer
  Reporter: john@… | Owner: bagder
      Type: enhancement | Status: assigned
  Priority: normal | Milestone: 1.2.7
 Component: API | Version: 1.2.6
Resolution: | Keywords:
    Blocks: | Blocked By:

Comment (by stuge):

 Replying to [comment:2 john@…]:
>> Are you saying that your snprintf() doesn't zero terminate the output?
> No in the function '''_libssh2_debug''' the debug string is stored in a
 variable called '''buffer'''. This is not a terminated string.

 snprintf() and vsnprintf() do zero-terminate the written string but
 libssh2_debug() overwrites it with a line feed.

 Agree no session pointer.

 This is now fixed in commit 0f0652a3093111fc7dac0205fdcf8d02bf16e89f

 And actually the old code would always write outside allocated memory if
 the buffer was too small for the message, since then snprintf() and
 friends return the number of bytes that is needed for the full message.
 Bad libssh2!

Ticket URL: <>
libssh2 <>
C library for writing portable SSH2 clients
Received on 2010-06-23