32 Commits

Author SHA1 Message Date
Daniel Stenberg
637c90959b agent_connect_unix: make sure there's a trailing zero
... if the path name was too long. Reported by Coverity CID 89801.
2014-12-23 20:05:16 +01:00
Daniel Stenberg
031566f9cc calloc: introduce LIBSSH2_CALLOC()
A simple function using LIBSSH2_ALLOC + memset, since this pattern was
used in multiple places and this simplies code in general.
2014-12-22 15:59:21 +01:00
Marc Hoersken
abcc0d370f agent.c: check return code of MapViewOfFile
Fixes VS2012 code analysis warning C6387: 'p+4' may be '0':
this does not adhere to the specification for the function
'memcpy': libssh2 agent.c 330

Fixes VS2012 code analysis warning C6387: 'p' may be '0':
this does not adhere to the specification for the function
'UnmapViewOfFile': libssh2 agent.c 333
2014-12-15 00:59:00 +01:00
Dan Fandrich
08973a00a1 agent_list_identities: Fixed memory leak on OOM 2014-02-28 22:34:29 +01:00
Dan Fandrich
c00efa5f93 Fixed a few typos 2014-02-24 23:23:13 +01:00
Matthias Kerestesch
1ad20ac7d3 libssh2_agent_init: init ->fd to LIBSSH2_INVALID_SOCKET
... previously it was left at 0 which is a valid file descriptor!

Bug: https://trac.libssh2.org/ticket/265

Fixes #265
2013-05-18 23:03:18 +02:00
Peter Stuge
f28264c6a3 Define and use LIBSSH2_INVALID_SOCKET instead of INVALID_SOCKET
INVALID_SOCKET is a special value in Windows representing a
non-valid socket identifier. We were #defining this to -1 on
non-Windows platforms, causing unneccessary namespace pollution.
Let's have our own identifier instead.

Thanks to Matt Lawson for pointing this out.
2012-03-02 17:36:52 +01:00
Henrik Nordstrom
7aa4bfc671 Custom callbacks for performing low level socket I/O 2011-08-21 15:19:44 +02:00
Daniel Stenberg
2db7d9c655 agent_list_identities: fix out of scope access
An auto variable out of scope was being referenced and used.

fixes #220
2011-06-20 00:08:51 +02:00
Guenter Knauf
aa4f861643 Expanded tabs to spaces. 2010-12-22 14:27:55 +01:00
Peter Stuge
e8c44e789f src/agent.c: Simplify _libssh2_send() error checking ever so slightly 2010-11-13 01:50:24 +01:00
Daniel Stenberg
ca2e81eb1f send/recv: use _libssh2_recv and _libssh2_send now
Starting now, we unconditionally use the internal replacement functions
for send() and recv() - creatively named _libssh2_recv() and
_libssh2_send().

On errors, these functions return the negative 'errno' value instead of
the traditional -1. This design allows systems that have no "natural"
errno support to not have to invent it. It also means that no code
outside of these two transfer functions should use the errno variable.
2010-11-12 21:53:35 +01:00
Daniel Stenberg
822f9e8689 agent: use better error defines 2010-10-07 11:19:35 +02:00
Daniel Stenberg
32bd0df992 agent: make libssh2_agent_userauth() work blocking properly
previously it would always work in a non-blocking manner
2010-06-18 20:13:08 +02:00
Daniel Stenberg
3496e1c2a2 warning: fix a compiler warning 'pointer differs in signedness'
As reported in bug #177
2010-06-15 19:51:26 +02:00
Daniel Stenberg
22a2de7347 agent: use _libssh2_error() when returning errors
As pointed out in bug report #173, this module basically never
used _libssh2_error() which made it work inconstently with other
parts of the libssh2 code base. This is my first take at making
this code more in line with the rest.
2010-06-11 13:32:41 +02:00
Daniel Stenberg
3490b3fe10 agent: make the code better deal with unexpected code flows
agent->ops gets initialized by the libssh2_agent_connect() call
but we need to make sure that we don't segfault even if a bad
sequence of function calls is used.
2010-06-11 11:13:46 +02:00
Daniel Stenberg
76fd96e63e agent: win32: fix bad _libssh2_store_str call
As pointed out by Grubsky Grigory <g.grubsky@securitycode.ru>, I
made a mistake when I added the _libssh2_store_str() call before
and I made a slightly different patch than what he suggested.
Based purely on taste.
2010-05-25 23:19:46 +02:00
Daniel Stenberg
71fb9cc93e cleanup: prefer the internal functions
To get the blocking vs non-blocking to work as smooth as possible
and behave better internally, we avoid using the external
interfaces when calling functions internally.

Renamed a few internal functions to use _libssh2 prefix when not
being private within a file, and removed the libssh2_ for one
that was private within the file.
2010-04-25 19:35:43 +02:00
Daniel Stenberg
fca949ea55 agent_transact_unix: remove unused variable 2010-04-18 15:27:47 +02:00
Daniel Stenberg
c3bcdd88a4 cleanups: better binary packet gen, size_t fixes and PACKET_* removal
I'll introduce a new internal function set named

 _libssh2_store_u32
 _libssh2_store_u64
 _libssh2_store_str

That can be used all through the library to build binary outgoing
packets.  Using these instead of the current approach removes
hundreds of lines from the library while at the same time greatly
enhances readability. I've not yet fully converted everything to
use these functions.

I've converted LOTS of 'unsigned long' to 'size_t' where
data/string lengths are dealt with internally. This is The Right
Thing and it will help us make the transition to our
size_t-polished API later on as well.

I'm removing the PACKET_* error codes. They were originally
introduced as a set of separate error codes from the transport
layer, but having its own set of errors turned out to be very
awkward and they were then converted into a set of #defines that
simply maps them to the global libssh2 error codes instead. Now,
I'l take the next logical step and simply replace the PACKET_*
defines with the actual LIBSSH2_ERROR_* defines. It will increase
readability and decrease confusion.

I also separated packet stuff into its own packet.h header file.
2010-04-17 13:18:15 +02:00
Daniel Stenberg
1adcb5234f rename libssh2_error to the correct _libssh2_error
We reserve ^libssh2_ for public symbols and we use _libssh2 as
prefix for internal ones. I fixed the intendation of all these
edits with emacs afterwards, which then changed it slightly more
than just _libssh2_error() expressions but I didn't see any
obvious problems.
2010-04-16 00:18:51 +02:00
Daniel Stenberg
a03e1b0457 silence picky compiler warnings 2010-03-03 23:32:56 +01:00
Daniel Stenberg
d4a768af4e removed libssh2_error()'s forth argument
libssh2_error() no longer allocates a string and only accepts a const
error string. I also made a lot of functions use the construct of
return libssh2_error(...) instead of having one call to
libssh2_error() and then a separate return call. In several of those
cases I then also changed the former -1 return code to a more
detailed one - something that I think will not change behaviors
anywhere but it's worth keeping an eye open for any such.
2010-03-03 23:04:05 +01:00
Dave McCaldon
ea914c8b72 Resolve compile issues on Solaris x64 and UltraSPARC
Solaris builds of libssh2-1.2.3 failed on both x64 and UltraSPARC
platforms because of two problems:

1) src/agent.c:145 sun is a reserved word when using the SUNWspro compiler
2) example/direct_tcpip.c:84 INADDR_NONE is not defined
2010-02-09 11:19:52 +01:00
Peter Stuge
095ccbf825 Always #define INVALID_SOCKET -1 in libssh2_priv.h when not on win32
Fix broken builds since commit abd9bd0bbe631efeada1f54552c70b54e1c490c1
for all non-win32 platforms.
2010-01-29 23:51:38 +01:00
Daiki Ueno
d00e97a7f1 Define INVALID_SOCKET and use it instead of SOCKET_BAD.
Revert the part of previous commit that defines SOCKET_BAD library wide.
2009-12-25 10:04:34 +09:00
Daiki Ueno
8436e45ea6 Use libssh2_socket_t in the ssh-agent stuff.
Define a portability macro SOCKET_BAD which means "invalid socket".
2009-12-24 19:45:57 +09:00
Daiki Ueno
0b6e37872d Mark/unmark connection to Pageant is open/close. 2009-12-24 17:57:15 +09:00
Daiki Ueno
1b3b7b2214 Add test to check if the socket is connected. 2009-12-24 16:49:28 +09:00
Daiki Ueno
bbb2f29037 Fix doc comments. 2009-12-23 09:12:31 +09:00
Daiki Ueno
7b351eed36 Add ssh-agent API.
Signed-off-by: Simon Josefsson <simon@josefsson.org>
2009-12-21 12:19:20 +01:00