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

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

From: libssh2 Trac <trac_at_libssh2.stuge.se>
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: <http://trac.libssh2.org/ticket/181#comment:4>
libssh2 <http://trac.libssh2.org/>
C library for writing portable SSH2 clients
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-06-23