Compare commits

...

23 Commits

Author SHA1 Message Date
Daniel Stenberg
e885300b18 RELEASE-NOTES: synced with 92a9f95279 2012-05-18 23:30:04 +02:00
Alexander Lamaison
92a9f95279 win32/libssh2_config.h: Remove hardcoded #define LIBSSH2_HAVE_ZLIB.
Rationale: Everything else in this file states a fact about the win32
platform that is unconditional for that platform.  There is nothing
unconditional about the presence of zlib.  It is neither included with
Windows nor with the platform SDK.  Therefore, this is not an appropriate
place to assert its presence.  Especially as, once asserted, it cannot be
overridden using a compiler flag.

In contrast, if it is omitted, then it can easily be reasserted by adding
a compiler flag defining LIBSSH2_HAVE_ZLIB.
2012-05-15 17:32:06 +01:00
Daniel Stenberg
e91d4c9790 RELEASE-NOTES: synced with 69a3354467 2012-05-14 22:49:53 +02:00
Daniel Stenberg
69a3354467 _libssh2_packet_add: SSH_MSG_CHANNEL_REQUEST default to want_reply
RFC4254 says the default 'want_reply' is TRUE but the code defaulted to
FALSE. Now changed.

Fixes #233
2012-05-14 22:42:42 +02:00
Daniel Stenberg
3ede6e280e gettimeofday: no need for a replacement under cygwin
Fixes #224
2012-05-14 22:32:36 +02:00
Alexander Lamaison
b583311a93 Prevent sftp_packet_read accessing freed memory.
sftp_packet_add takes ownership of the packet passed to it and (now that we
handle zombies) might free the packet.  sftp_packet_read uses the packet type
byte as its return code but by this point sftp_packet_add might have freed
it.  This change fixes the problem by caching the packet type before calling
sftp_packet_add.

I don't understand why sftp_packet_read uses the packet type as its return
code.  A future change might get rid of this entirely.
2012-05-13 15:56:54 +01:00
Daniel Stenberg
27ac5aa40d sftp_packet_flush: flush zombies too
As this function is called when the SFTP session is closed, it needs to
also kill all zombies left in the SFTP session to avoid leaking memory
just in case some zombie would still be in there.
2012-05-12 22:42:40 +02:00
Daniel Stenberg
a123051200 sftp_packetlist_flush: zombies must not have responses already
When flushing the packetlist, we must only add the request as a zombie
if no response has already been received. Otherwise we could wrongly
make it a zombie even though the response was already received and then
we'd get a zombie stuck there "forever"...
2012-05-12 22:37:20 +02:00
Daniel Stenberg
62901253a4 sftp_read: on EOF remove packet before flush
Since the sftp_packetlist_flush() function will move all the existing
FXP_READ requests in this handle to the zombie list we must first remove
this just received packet as it is clearly not a zombie.
2012-05-10 23:11:07 +02:00
Daniel Stenberg
7c5ee0fa66 sftp_packet_require: sftp_packet_read() returning 0 is not an error
Exactly as the comment in the code said, checking the return code from
sftp_packet_read() with <= was wrong and it should be < 0. With the new
filtering on incoming packets that are "zombies" we can now see this
getting zero returned.
2012-05-10 23:09:37 +02:00
Daniel Stenberg
1e15075a8e sftp_packetlist_flush: only make it zombie if it was sent
The list of outgoing packets may also contain packets that never were
sent off and we better not make them zombies too.
2012-05-10 23:08:23 +02:00
Alexander Lamaison
ad63fc2df6 Mark outstanding read requests after EOF as zombies.
In order to be fast, sftp_read sends many read requests at once.  With a small
file, this can mean that when EOF is received back, many of these requests are
still outstanding.  Responses arriving after we close the file and abandon the
file handle are queued in the SFTP packet queue and never collected.  This
causes transfer speed to drop as a progressively longer queue must be searched
for every packet.

This change introduces a zombie request-ID list in the SFTP session that is
used to recognise these outstanding requests and prevent them being added to
the queue.
2012-05-10 19:35:25 +02:00
Rafael Kitover
d46185eaa5 Update win32/GNUmakefile to use OpenSSL 1.0.1a
libcrypto on win32 now depends on gdi32.dll, so move the OpenSSL LDLIBS
block to before the compiler definitions, so that libcrypto gets added
first, and then add -lgdi32 into the following common LDLIBS for gcc.
2012-04-23 20:04:41 +02:00
Guenter Knauf
9c4b380dd6 Changed 'Requires' to 'Requires.private'.
Only static builds need to link against the crypto libs.
2012-04-23 12:33:08 +02:00
Guenter Knauf
e887a8bd0f Fixed 'Requires:' names.
The 'Requires:' line lists the names of the .pc files.
2012-04-23 01:11:22 +02:00
Guenter Knauf
04692445d4 Added 'Requires:' line to libssh2.pc.
This is necessary so that other libs which lookup libssh2 info
via pkg-config can add the right crypto lib dependencies.
2012-04-23 00:35:03 +02:00
Guenter Knauf
a955f8428b Updated dependency lib versions. 2012-04-20 13:50:06 +02:00
Peter Stuge
ededdfa9c2 configure.ac: Add option to disable build of the example applications
Examples are built by default. Any of the following options on the
configure command line will skip building them:

  --disable-examples-build
  --enable-examples-build=no
  --enable-examples-build=false
2012-04-18 16:35:05 +02:00
Peter Stuge
11f9dce3d7 userauth.c: fread() from public key file to correctly detect any errors
If the filename parameter for file_read_publickey() was the name of a
directory instead of a file then libssh2 would spin trying to fgetc()
from the FILE * for the opened directory when trying to determine the
length of the encoded public key, since fgetc() can't report errors.

Use fread() instead to correctly detect this error condition along
with many others.

This fixes the problem reported in
http://www.libssh2.org/mail/libssh2-devel-archive-2012-04/0021.shtml

Reported-by: Oleksiy Zagorskyi <zalex_ua@i.ua>
2012-04-18 12:23:04 +02:00
Peter Stuge
6bbebcf36c Return LIBSSH2_ERROR_SOCKET_DISCONNECT on EOF when reading banner 2012-04-18 12:23:04 +02:00
Guenter Knauf
7a87bba02a Fixed copyright year. 2012-04-17 17:29:49 +02:00
Guenter Knauf
c8374cdc10 Updated dependency lib versions in static makefiles. 2012-04-12 22:01:45 +02:00
Daniel Stenberg
9b2bed22fc version: bump to 1.4.2
We're on the 1.4.2 track now (at least)
2012-04-06 15:28:18 +02:00
18 changed files with 195 additions and 64 deletions

View File

@@ -1,6 +1,9 @@
AUTOMAKE_OPTIONS = foreign nostdinc
SUBDIRS = src example tests docs
SUBDIRS = src tests docs
if BUILD_EXAMPLES
SUBDIRS += example
endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libssh2.pc

View File

@@ -1,28 +1,21 @@
libssh2 1.4.1
libssh2 1.4.2
This release includes the following bugfixes:
o build error with gcrypt backend
o always do "forced" window updates to avoid corner case stalls
o aes: the init function fails when OpenSSL has AES support
o transport_send: Finish in-progress key exchange before sending data
o channel_write: acknowledge transport errors
o examples/x11.c: Make sure sizeof passed to read operation is correct
o examples/x11.c:,Fix suspicious sizeof usage
o sftp_packet_add: verify the packet before accepting it
o SFTP: preserve the original error code more
o sftp_packet_read: adjust window size as necessary
o Use safer snprintf rather then sprintf in several places
o Define and use LIBSSH2_INVALID_SOCKET instead of INVALID_SOCKET
o sftp_write: cannot return acked data *and* EAGAIN
o sftp_read: avoid data *and* EAGAIN
o libssh2.h: Add missing prototype for libssh2_session_banner_set()
o Return LIBSSH2_ERROR_SOCKET_DISCONNECT on EOF when reading banner
o userauth.c: fread() from public key file to correctly detect any errors
o configure.ac: Add option to disable build of the example applications
o Added 'Requires.private:' line to libssh2.pc
o SFTP: filter off incoming "zombie" responses
o gettimeofday: no need for a replacement under cygwin
o SSH_MSG_CHANNEL_REQUEST: default to want_reply
o win32/libssh2_config.h: Remove hardcoded #define LIBSSH2_HAVE_ZLIB
This release would not have looked like this without help, code, reports and
advice from friends like these:
Armen Babakhanian, Paul Howarth, Matthew Booth, Steven Dake, Peter Stuge,
Matt Lawson, Tom Weber, Alexander Lamaison
Alexander Lamaison, Rafael Kitover, Guenter Knauf, Peter Stuge,
Oleksiy Zagorskyi
Thanks! (and sorry if I forgot to mention someone)

View File

@@ -96,13 +96,17 @@ AC_ARG_WITH(libz,
# Look for OpenSSL (default)
if test "$use_openssl" != "no" && test "$use_libgcrypt" != "yes"; then
AC_LIB_HAVE_LINKFLAGS([ssl], [crypto], [#include <openssl/ssl.h>])
LIBSREQUIRED=libssl,libcrypto
fi
# Look for libgcrypt
if test "$ac_cv_libssl" != "yes" && test "$use_libgcrypt" != "no"; then
AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
LIBSREQUIRED=libgcrypt
fi
AC_SUBST(LIBSREQUIRED)
if test "$ac_cv_libssl" != "yes" && test "$ac_cv_libgcrypt" != "yes"; then
AC_MSG_ERROR([cannot find OpenSSL or Libgcrypt,
try --with-libssl-prefix=PATH or --with-libgcrypt-prefix=PATH])
@@ -215,6 +219,22 @@ AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibi
AC_MSG_RESULT(no)
)
# Build example applications?
AC_MSG_CHECKING([whether to build example applications])
AC_ARG_ENABLE([examples-build],
AC_HELP_STRING([--enable-examples-build], [Build example applications (this is the default)])
AC_HELP_STRING([--disable-examples-build], [Do not build example applications]),
[case "$enableval" in
no | false)
build_examples='no'
;;
*)
build_examples='yes'
;;
esac], [build_examples='yes'])
AC_MSG_RESULT($build_examples)
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
# Checks for header files.
# AC_HEADER_STDC
AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/uio.h])
@@ -300,6 +320,7 @@ AC_MSG_NOTICE([summary of build options:
Library types: Shared=${enable_shared}, Static=${enable_static}
Crypto library: openssl: ${ac_cv_libssl:-no} (AES-CTR: ${ac_cv_func_EVP_aes_128_ctr:-N/A}) libgcrypt: ${ac_cv_libgcrypt:-no}
Debug build: $enable_debug
Build examples: $build_examples
Path to sshd: $ac_cv_path_SSHD (only for self-tests)
libz compression: $ac_cv_libz
])

View File

@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2009, Sara Golemon <sarag@libssh2.org>
* Copyright (c) 2009-2010 Daniel Stenberg
* Copyright (c) 2009-2012 Daniel Stenberg
* Copyright (c) 2010 Simon Josefsson <simon@josefsson.org>
* All rights reserved.
*
@@ -40,19 +40,19 @@
#ifndef LIBSSH2_H
#define LIBSSH2_H 1
#define LIBSSH2_COPYRIGHT "2004-2011 The libssh2 project and its contributors."
#define LIBSSH2_COPYRIGHT "2004-2012 The libssh2 project and its contributors."
/* We use underscore instead of dash when appending DEV in dev versions just
to make the BANNER define (used by src/session.c) be a valid SSH
banner. Release versions have no appended strings and may of course not
have dashes either. */
#define LIBSSH2_VERSION "1.4.0_DEV"
#define LIBSSH2_VERSION "1.4.2_DEV"
/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBSSH2_VERSION_MAJOR 1
#define LIBSSH2_VERSION_MINOR 4
#define LIBSSH2_VERSION_PATCH 0
#define LIBSSH2_VERSION_PATCH 2
/* This is the numeric version of the libssh2 version number, meant for easier
parsing and comparions by programs. The LIBSSH2_VERSION_NUM define will
@@ -69,7 +69,7 @@
and it is always a greater number in a more recent release. It makes
comparisons with greater than and less than work.
*/
#define LIBSSH2_VERSION_NUM 0x010400
#define LIBSSH2_VERSION_NUM 0x010402
/*
* This is the date and time when the full source package was created. The

View File

@@ -11,6 +11,7 @@ Name: libssh2
URL: http://www.libssh2.org/
Description: Library for SSH-based communication
Version: @LIBSSH2VER@
Requires.private: @LIBSREQUIRED@
Libs: -L${libdir} -lssh2 @LDFLAGS@ @LIBS@
Libs.private: @LIBS@
Cflags: -I${includedir}

View File

@@ -14,12 +14,12 @@ endif
# Edit the path below to point to the base of your Zlib sources.
ifndef ZLIB_PATH
ZLIB_PATH = ../../zlib-1.2.5
ZLIB_PATH = ../../zlib-1.2.6
endif
# Edit the path below to point to the base of your OpenSSL package.
ifndef OPENSSL_PATH
OPENSSL_PATH = ../../openssl-0.9.8r
OPENSSL_PATH = ../../openssl-0.9.8v
endif
# Edit the path below to point to your Distribution folder.
@@ -229,9 +229,11 @@ $(OBJDIR)/version.inc: ../include/libssh2.h $(OBJDIR)
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
@-$(MD) $(DISTDIR)$(DS)bin
@-$(CP) ../AUTHORS $(DISTDIR)
@-$(CP) ../COPYING $(DISTDIR)
@-$(CP) ../INSTALL $(DISTDIR)
@-$(CP) ../README $(DISTDIR)
@-$(CP) ../RELEASE-NOTES $(DEVLDIR)
@$(CP) $(TARGET).nlm $(DISTDIR)/bin
@echo Creating $(DISTARC)
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
@@ -240,9 +242,11 @@ dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
@-$(MD) $(DEVLDIR)$(DS)bin
@-$(MD) $(DEVLDIR)$(DS)include
@-$(MD) $(DEVLDIR)$(DS)nw
@-$(CP) ../AUTHORS $(DISTDIR)
@-$(CP) ../COPYING $(DISTDIR)
@-$(CP) ../INSTALL $(DEVLDIR)
@-$(CP) ../README $(DEVLDIR)
@-$(CP) ../RELEASE-NOTES $(DEVLDIR)
@$(CP) $(TARGET).nlm $(DEVLDIR)/bin
@$(CP) ../include/*.h $(DEVLDIR)/include
@$(CP) libssh2_config.h $(DEVLDIR)/include

View File

@@ -14,12 +14,12 @@ endif
# Edit the path below to point to the base of your Zlib sources.
ifndef ZLIB_PATH
ZLIB_PATH = ../../../zlib-1.2.5
ZLIB_PATH = ../../../zlib-1.2.6
endif
# Edit the path below to point to the base of your OpenSSL package.
ifndef OPENSSL_PATH
OPENSSL_PATH = ../../../openssl-0.9.8r
OPENSSL_PATH = ../../../openssl-0.9.8v
endif
# Edit the var below to enable static linking of libssh2 and libz

View File

@@ -78,7 +78,7 @@ void _libssh2_htonu32(unsigned char *buf, uint32_t val);
void _libssh2_store_u32(unsigned char **buf, uint32_t value);
void _libssh2_store_str(unsigned char **buf, const char *str, size_t len);
#if defined(LIBSSH2_WIN32) && !defined(__MINGW32__)
#if defined(LIBSSH2_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
/* provide a private one */
#undef HAVE_GETTIMEOFDAY
int __cdecl _libssh2_gettimeofday(struct timeval *tp, void *tzp);

View File

@@ -751,7 +751,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
if(datalen >= 9) {
uint32_t channel = _libssh2_ntohu32(data + 1);
uint32_t len = _libssh2_ntohu32(data + 5);
unsigned char want_reply = 0;
unsigned char want_reply = 1;
if(len < (datalen - 10))
want_reply = data[9 + len];

View File

@@ -143,7 +143,7 @@ banner_receive(LIBSSH2_SESSION * session)
if (ret == 0) {
session->socket_state = LIBSSH2_SOCKET_DISCONNECTED;
return LIBSSH2_ERROR_SOCKET_RECV;
return LIBSSH2_ERROR_SOCKET_DISCONNECT;
}
if (c == '\0') {

View File

@@ -132,6 +132,66 @@ static void _libssh2_store_u64(unsigned char **ptr, libssh2_uint64_t value)
*ptr += 8;
}
/*
* Search list of zombied FXP_READ request IDs.
*
* Returns NULL if ID not in list.
*/
static struct sftp_zombie_requests *
find_zombie_request(LIBSSH2_SFTP *sftp, uint32_t request_id)
{
struct sftp_zombie_requests *zombie =
_libssh2_list_first(&sftp->zombie_requests);
while(zombie) {
if(zombie->request_id == request_id)
break;
else
zombie = _libssh2_list_next(&zombie->node);
}
return zombie;
}
static void
remove_zombie_request(LIBSSH2_SFTP *sftp, uint32_t request_id)
{
LIBSSH2_SESSION *session = sftp->channel->session;
struct sftp_zombie_requests *zombie = find_zombie_request(sftp,
request_id);
if(zombie) {
_libssh2_debug(session, LIBSSH2_TRACE_SFTP,
"Removing request ID %ld from the list of zombie requests",
request_id);
_libssh2_list_remove(&zombie->node);
LIBSSH2_FREE(session, zombie);
}
}
static int
add_zombie_request(LIBSSH2_SFTP *sftp, uint32_t request_id)
{
LIBSSH2_SESSION *session = sftp->channel->session;
struct sftp_zombie_requests *zombie;
_libssh2_debug(session, LIBSSH2_TRACE_SFTP,
"Marking request ID %ld as a zombie request", request_id);
zombie = LIBSSH2_ALLOC(sftp->channel->session,
sizeof(struct sftp_zombie_requests));
if (!zombie)
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"malloc fail for zombie request ID");
else {
zombie->request_id = request_id;
_libssh2_list_add(&sftp->zombie_requests, &zombie->node);
return LIBSSH2_ERROR_NONE;
}
}
/*
* sftp_packet_add
*
@@ -143,6 +203,7 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data,
{
LIBSSH2_SESSION *session = sftp->channel->session;
LIBSSH2_SFTP_PACKET *packet;
uint32_t request_id;
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Received packet %d (len %d)",
(int) data[0], data_len);
@@ -188,6 +249,21 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data,
"Out of sync with the world");
}
request_id = _libssh2_ntohu32(&data[1]);
/* Don't add the packet if it answers a request we've given up on. */
if((data[0] == SSH_FXP_STATUS || data[0] == SSH_FXP_DATA)
&& find_zombie_request(sftp, request_id)) {
/* If we get here, the file ended before the response arrived. We
are no longer interested in the request so we discard it */
LIBSSH2_FREE(session, data);
remove_zombie_request(sftp, request_id);
return LIBSSH2_ERROR_NONE;
}
packet = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_SFTP_PACKET));
if (!packet) {
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
@@ -196,7 +272,7 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data,
packet->data = data;
packet->data_len = data_len;
packet->request_id = _libssh2_ntohu32(&data[1]);
packet->request_id = request_id;
_libssh2_list_add(&sftp->packets, &packet->node);
@@ -216,6 +292,7 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
unsigned char *packet = NULL;
ssize_t rc;
unsigned long recv_window;
int packet_type;
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "recv packet");
@@ -324,13 +401,17 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
sftp->partial_packet = NULL;
/* sftp_packet_add takes ownership of the packet and might free it
so we take a copy of the packet type before we call it. */
packet_type = packet[0];
rc = sftp_packet_add(sftp, packet, sftp->partial_len);
if (rc) {
LIBSSH2_FREE(session, packet);
return rc;
}
return packet[0];
else {
return packet_type;
}
}
/* WON'T REACH */
}
@@ -363,6 +444,10 @@ static void sftp_packetlist_flush(LIBSSH2_SFTP_HANDLE *handle)
if(!rc)
/* we found a packet, free it */
LIBSSH2_FREE(session, data);
else if(chunk->sent)
/* there was no incoming packet for this request, mark this
request as a zombie if it ever sent the request */
add_zombie_request(sftp, chunk->request_id);
_libssh2_list_remove(&chunk->node);
LIBSSH2_FREE(session, chunk);
@@ -433,10 +518,7 @@ sftp_packet_require(LIBSSH2_SFTP *sftp, unsigned char packet_type,
while (session->socket_state == LIBSSH2_SOCKET_CONNECTED) {
rc = sftp_packet_read(sftp);
if (rc == LIBSSH2_ERROR_EAGAIN)
return rc;
else if (rc <= 0)
/* TODO: isn't this supposed to be < 0 only? */
if (rc < 0)
return rc;
/* data was read, check the queue again */
@@ -1377,6 +1459,12 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
switch (data[0]) {
case SSH_FXP_STATUS:
/* remove the chunk we just processed keeping track of the
* next one in case we need it */
next = _libssh2_list_next(&chunk->node);
_libssh2_list_remove(&chunk->node);
LIBSSH2_FREE(session, chunk);
/* we must remove all outstanding READ requests, as either we
got an error or we're at end of file */
sftp_packetlist_flush(handle);
@@ -2091,13 +2179,15 @@ libssh2_sftp_tell64(LIBSSH2_SFTP_HANDLE *handle)
}
/*
* Flush all remaining incoming SFTP packets.
* Flush all remaining incoming SFTP packets and zombies.
*/
static void sftp_packet_flush(LIBSSH2_SFTP *sftp)
{
LIBSSH2_CHANNEL *channel = sftp->channel;
LIBSSH2_SESSION *session = channel->session;
LIBSSH2_SFTP_PACKET *packet = _libssh2_list_first(&sftp->packets);
struct sftp_zombie_requests *zombie =
_libssh2_list_first(&sftp->zombie_requests);
while(packet) {
LIBSSH2_SFTP_PACKET *next;
@@ -2111,6 +2201,16 @@ static void sftp_packet_flush(LIBSSH2_SFTP *sftp)
packet = next;
}
while(zombie) {
/* figure out the next node */
struct sftp_zombie_requests *next = _libssh2_list_next(&zombie->node);
/* unlink the current one */
_libssh2_list_remove(&zombie->node);
/* free the memory */
LIBSSH2_FREE(session, zombie);
zombie = next;
}
}
/* sftp_close_handle

View File

@@ -60,6 +60,11 @@ struct sftp_pipeline_chunk {
unsigned char packet[1]; /* data */
};
struct sftp_zombie_requests {
struct list_node node;
uint32_t request_id;
};
#ifndef MIN
#define MIN(x,y) ((x)<(y)?(x):(y))
#endif
@@ -136,6 +141,9 @@ struct _LIBSSH2_SFTP
struct list_head packets;
/* List of FXP_READ responses to ignore because EOF already received. */
struct list_head zombie_requests;
/* a list of _LIBSSH2_SFTP_HANDLE structs */
struct list_head sftp_handles;

View File

@@ -472,7 +472,7 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
"Unable to open public key file");
}
while (!feof(fd) && (c = fgetc(fd)) != '\r' && c != '\n')
while (!feof(fd) && 1 == fread(&c, 1, 1, fd) && c != '\r' && c != '\n')
pubkey_len++;
if (feof(fd)) {
/* the last character was EOF */

View File

@@ -9,14 +9,14 @@
# Edit the path below to point to the base of your Zlib sources.
ifndef ZLIB_PATH
ZLIB_PATH = ../../zlib-1.2.5
ZLIB_PATH = ../../zlib-1.2.6
endif
# since currently always enabled in libssh2_config.h set here too!
WITH_ZLIB = 1
# Edit the path below to point to the base of your OpenSSL package.
ifndef OPENSSL_PATH
OPENSSL_PATH = ../../openssl-0.9.8r
OPENSSL_PATH = ../../openssl-1.0.1a
endif
# Edit the var below to set to your architecture or set environment var.
@@ -72,7 +72,7 @@ DS = /
else
CP = copy
RM = del /q /f 2>NUL
MD = md
MD = md 2>NUL
RD = rd /q /s 2>NUL
XX =
DS = $(XX)\$(XX)
@@ -95,6 +95,12 @@ ifeq ($(ARCH),w64)
CFLAGS += -D_AMD64_
endif
ifdef LINK_STATIC
LDLIBS += $(OPENSSL_PATH)/out/libcrypto.$(LIBEXT) $(OPENSSL_PATH)/out/libssl.$(LIBEXT)
else
LDLIBS += $(OPENSSL_PATH)/out/libeay32.$(LIBEXT) $(OPENSSL_PATH)/out/libssl32.$(LIBEXT)
endif
ifeq ($(CC),mwcc)
LD = mwld
RC = mwwinrc
@@ -119,7 +125,7 @@ ARFLAGS = -cq
LIBEXT = a
RANLIB = $(CROSSPREFIX)ranlib
#LDLIBS += -lwsock32
LDLIBS += -lws2_32
LDLIBS += -lws2_32 -lgdi32
RCFLAGS = -I. -I ../include -O coff -i
CFLAGS += -fno-strict-aliasing
CFLAGS += -Wall # -pedantic
@@ -128,12 +134,6 @@ endif
INCLUDES = -I. -I../include
INCLUDES += -I$(OPENSSL_PATH)/outinc -I$(OPENSSL_PATH)/outinc/openssl
ifdef LINK_STATIC
LDLIBS += $(OPENSSL_PATH)/out/libcrypto.$(LIBEXT) $(OPENSSL_PATH)/out/libssl.$(LIBEXT)
else
LDLIBS += $(OPENSSL_PATH)/out/libeay32.$(LIBEXT) $(OPENSSL_PATH)/out/libssl32.$(LIBEXT)
endif
ifdef WITH_ZLIB
INCLUDES += -I$(ZLIB_PATH)
LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT)
@@ -172,9 +172,11 @@ $(OBJDIR)/version.inc: ../include/libssh2.h $(OBJDIR)
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
@-$(MD) $(DISTDIR)$(DS)bin
@-$(CP) ..$(DS)AUTHORS $(DISTDIR)
@-$(CP) ..$(DS)COPYING $(DISTDIR)
@-$(CP) ..$(DS)INSTALL $(DISTDIR)
@-$(CP) ..$(DS)LICENSE $(DISTDIR)
@-$(CP) ..$(DS)README $(DISTDIR)
@-$(CP) ..$(DS)RELEASE-NOTES $(DEVLDIR)
@$(CP) $(TARGET).dll $(DISTDIR)$(DS)bin
@echo Creating $(DISTARC)
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
@@ -183,9 +185,11 @@ dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
@-$(MD) $(DEVLDIR)$(DS)bin
@-$(MD)$(DEVLDIR)$(DS)include
@-$(MD) $(DEVLDIR)$(DS)win32
@-$(CP) ..$(DS)AUTHORS $(DISTDIR)
@-$(CP) ..$(DS)COPYING $(DISTDIR)
@-$(CP) ..$(DS)INSTALL $(DEVLDIR)
@-$(CP) ..$(DS)LICENSE $(DEVLDIR)
@-$(CP) ..$(DS)README $(DEVLDIR)
@-$(CP) ..$(DS)RELEASE-NOTES $(DEVLDIR)
@$(CP) $(TARGET).dll $(DEVLDIR)$(DS)bin
@$(CP) ..$(DS)include$(DS)*.h $(DEVLDIR)$(DS)include
@$(CP) libssh2_config.h $(DEVLDIR)/include

View File

@@ -64,13 +64,13 @@ CFLAGS += -d_WIN32_WINNT=0x0501 -dENABLE_IPV6
!ifdef %zlib_root
ZLIB_ROOT = $(%zlib_root)
!else
ZLIB_ROOT = ..\..\zlib-1.2.5
ZLIB_ROOT = ..\..\zlib-1.2.6
!endif
!ifdef %openssl_root
OPENSSL_ROOT = $(%openssl_root)
!else
OPENSSL_ROOT = ..\..\openssl-0.9.8r
OPENSSL_ROOT = ..\..\openssl-0.9.8v
!endif
#!ifdef %use_zlib

View File

@@ -1,10 +1,10 @@
# Tweak these for your system
OPENSSLINC=..\openssl-0.9.8q\inc32
OPENSSLLIB=..\openssl-0.9.8q\out32dll
OPENSSLINC=..\openssl-0.9.8v\inc32
OPENSSLLIB=..\openssl-0.9.8v\out32dll
ZLIBINC=-DLIBSSH2_HAVE_ZLIB=1 /I..\zlib-1.2.5
ZLIBLIB=..\zlib-1.2.5
ZLIBINC=-DLIBSSH2_HAVE_ZLIB=1 /I..\zlib-1.2.6
ZLIBLIB=..\zlib-1.2.6
!if "$(TARGET)" == ""
TARGET=Release

View File

@@ -34,9 +34,6 @@
#define strcasecmp stricmp
#endif /* _MSC_VER */
/* Compile in zlib support */
#define LIBSSH2_HAVE_ZLIB 1
/* Enable newer diffie-hellman-group-exchange-sha1 syntax */
#define LIBSSH2_DH_GEX_NEW 1

View File

@@ -9,12 +9,12 @@
# Edit the path below to point to the base of your Zlib sources.
ifndef ZLIB_PATH
ZLIB_PATH = ../../../zlib-1.2.5
ZLIB_PATH = ../../../zlib-1.2.6
endif
# Edit the path below to point to the base of your OpenSSL package.
ifndef OPENSSL_PATH
OPENSSL_PATH = ../../../openssl-0.9.8r
OPENSSL_PATH = ../../../openssl-0.9.8v
endif
# Edit the var below to set to your architecture or set environment var.
@@ -61,7 +61,7 @@ DS = /
else
CP = copy
RM = del /q /f 2>NUL
MD = md
MD = md 2>NUL
RD = rd /q /s 2>NUL
XX =
DS = $(XX)\$(XX)