mirror of
https://github.com/libssh2/libssh2.git
synced 2025-07-29 13:01:14 +03:00
Fix a couple of warnings of errors in MSVC builds
Two warnings (in tests & examples) in particular would cause problems: bad format causing invalid data output or a bad chdir due to out of scope buffer use.
This commit is contained in:
@ -231,7 +231,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
while(got < fileinfo.st_size) {
|
while(got < fileinfo.st_size) {
|
||||||
char mem[1024*24];
|
char mem[1024*24];
|
||||||
int rc;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int amount = sizeof(mem);
|
int amount = sizeof(mem);
|
||||||
|
@ -48,10 +48,10 @@ int main(int argc, char *argv[])
|
|||||||
size_t nread;
|
size_t nread;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
struct stat fileinfo;
|
struct stat fileinfo;
|
||||||
|
int err;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
WSADATA wsadata;
|
WSADATA wsadata;
|
||||||
int err;
|
|
||||||
|
|
||||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||||
if(err != 0) {
|
if(err != 0) {
|
||||||
@ -165,7 +165,7 @@ int main(int argc, char *argv[])
|
|||||||
if(!channel) {
|
if(!channel) {
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
int errlen;
|
int errlen;
|
||||||
int err = libssh2_session_last_error(session, &errmsg, &errlen, 0);
|
err = libssh2_session_last_error(session, &errmsg, &errlen, 0);
|
||||||
fprintf(stderr, "Unable to open a session: (%d) %s\n", err, errmsg);
|
fprintf(stderr, "Unable to open a session: (%d) %s\n", err, errmsg);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define __FILESIZE "I64"
|
#define __FILESIZE "I64u"
|
||||||
#else
|
#else
|
||||||
#define __FILESIZE "llu"
|
#define __FILESIZE "llu"
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define __FILESIZE "I64"
|
#define __FILESIZE "I64u"
|
||||||
#else
|
#else
|
||||||
#define __FILESIZE "llu"
|
#define __FILESIZE "llu"
|
||||||
#endif
|
#endif
|
||||||
|
@ -225,7 +225,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
for(;;) {
|
for(;;) {
|
||||||
/* loop until we block */
|
/* loop until we block */
|
||||||
int rc;
|
|
||||||
do {
|
do {
|
||||||
char buffer[0x4000];
|
char buffer[0x4000];
|
||||||
rc = libssh2_channel_read(channel, buffer, sizeof(buffer) );
|
rc = libssh2_channel_read(channel, buffer, sizeof(buffer) );
|
||||||
|
@ -250,8 +250,8 @@ int main(int argc, char *argv[])
|
|||||||
fds[0].events = LIBSSH2_POLLFD_POLLIN | LIBSSH2_POLLFD_POLLOUT;
|
fds[0].events = LIBSSH2_POLLFD_POLLIN | LIBSSH2_POLLFD_POLLOUT;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int rc = (libssh2_poll(fds, 1, 10));
|
|
||||||
int act = 0;
|
int act = 0;
|
||||||
|
rc = (libssh2_poll(fds, 1, 10));
|
||||||
|
|
||||||
if(rc < 1)
|
if(rc < 1)
|
||||||
continue;
|
continue;
|
||||||
|
@ -254,7 +254,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
for(;;) {
|
for(;;) {
|
||||||
/* loop until we block */
|
/* loop until we block */
|
||||||
int rc;
|
|
||||||
do {
|
do {
|
||||||
char buffer[0x4000];
|
char buffer[0x4000];
|
||||||
rc = libssh2_channel_read(channel, buffer, sizeof(buffer) );
|
rc = libssh2_channel_read(channel, buffer, sizeof(buffer) );
|
||||||
|
@ -65,7 +65,7 @@ bcrypt_hash(uint8_t *sha2pass, uint8_t *sha2salt, uint8_t *out)
|
|||||||
uint32_t cdata[BCRYPT_BLOCKS];
|
uint32_t cdata[BCRYPT_BLOCKS];
|
||||||
int i;
|
int i;
|
||||||
uint16_t j;
|
uint16_t j;
|
||||||
size_t shalen = SHA512_DIGEST_LENGTH;
|
uint16_t shalen = SHA512_DIGEST_LENGTH;
|
||||||
|
|
||||||
/* key expansion */
|
/* key expansion */
|
||||||
Blowfish_initstate(&state);
|
Blowfish_initstate(&state);
|
||||||
|
@ -1392,9 +1392,9 @@ _libssh2_packet_requirev(LIBSSH2_SESSION *session,
|
|||||||
|
|
||||||
if(strchr((char *) packet_types, ret)) {
|
if(strchr((char *) packet_types, ret)) {
|
||||||
/* Be lazy, let packet_ask pull it out of the brigade */
|
/* Be lazy, let packet_ask pull it out of the brigade */
|
||||||
int ret = _libssh2_packet_askv(session, packet_types, data,
|
ret = _libssh2_packet_askv(session, packet_types, data,
|
||||||
data_len, match_ofs, match_buf,
|
data_len, match_ofs, match_buf,
|
||||||
match_len);
|
match_len);
|
||||||
state->start = 0;
|
state->start = 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,11 @@ static int connect_to_server(void)
|
|||||||
|
|
||||||
static void setup_fixture_workdir(void)
|
static void setup_fixture_workdir(void)
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
char wd_buf[_MAX_PATH];
|
||||||
|
#else
|
||||||
|
char wd_buf[MAXPATHLEN];
|
||||||
|
#endif
|
||||||
char *wd = getenv("FIXTURE_WORKDIR");
|
char *wd = getenv("FIXTURE_WORKDIR");
|
||||||
#ifdef FIXTURE_WORKDIR
|
#ifdef FIXTURE_WORKDIR
|
||||||
if(!wd) {
|
if(!wd) {
|
||||||
@ -88,11 +93,6 @@ static void setup_fixture_workdir(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(!wd) {
|
if(!wd) {
|
||||||
#ifdef WIN32
|
|
||||||
char wd_buf[_MAX_PATH];
|
|
||||||
#else
|
|
||||||
char wd_buf[MAXPATHLEN];
|
|
||||||
#endif
|
|
||||||
getcwd(wd_buf, sizeof(wd_buf));
|
getcwd(wd_buf, sizeof(wd_buf));
|
||||||
wd = wd_buf;
|
wd = wd_buf;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user