Fixed crash with uninitialized pointer RsSshd::mSession.

Fixed some compile errors on Windows.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5693 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-10-19 13:22:51 +00:00
parent d4bf742268
commit 02f8d27b6e
3 changed files with 15 additions and 8 deletions

View file

@ -27,6 +27,7 @@
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
#include <iostream> #include <iostream>
#include <time.h>
#include "util/rsstring.h" #include "util/rsstring.h"

View file

@ -32,7 +32,7 @@ clients must be made or how a client should react.
RsSshd *rsSshd = NULL; // External Reference Variable. RsSshd *rsSshd = NULL; // External Reference Variable.
// NB: This must be called EARLY before all the threads are launched. // NB: This must be called EARLY before all the threads are launched.
RsSshd *RsSshd::InitRsSshd(std::string portStr, std::string rsakeyfile) RsSshd *RsSshd::InitRsSshd(const std::string &portStr, const std::string &rsakeyfile)
{ {
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0) #if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0)
ssh_threads_set_callbacks(ssh_threads_get_pthread()); ssh_threads_set_callbacks(ssh_threads_get_pthread());
@ -58,13 +58,15 @@ RsSshd::RsSshd(std::string portStr)
mBindState = 0; mBindState = 0;
mRpcSystem = NULL; mRpcSystem = NULL;
mSession = NULL;
setSleepPeriods(0.01, 0.1); setSleepPeriods(0.01, 0.1);
return; return;
} }
int RsSshd::init(std::string pathrsakey) int RsSshd::init(const std::string &pathrsakey)
{ {
mBind=ssh_bind_new(); mBind=ssh_bind_new();
@ -117,7 +119,11 @@ void RsSshd::run()
} }
} }
cleanupSession(); cleanupSession();
#ifndef WINDOWS_SYS
sleep(5); // have a break; sleep(5); // have a break;
#else
Sleep(5000); // have a break;
#endif
} }
} }
@ -628,7 +634,7 @@ int RsSshd::setSleepPeriods(float busy, float idle)
/* PASSWORDS */ /* PASSWORDS */
/***********************************************************************************/ /***********************************************************************************/
int RsSshd::auth_password(char *name, char *pwd) int RsSshd::auth_password(const char *name, const char *pwd)
{ {
#ifdef ALLOW_CLEARPWDS #ifdef ALLOW_CLEARPWDS
if (auth_password_basic(name, pwd)) if (auth_password_basic(name, pwd))
@ -726,7 +732,7 @@ int RsSshd::adduserpwdhash(std::string username, std::string hash)
} }
int RsSshd::auth_password_hashed(char *name, char *pwd) int RsSshd::auth_password_hashed(const char *name, const char *pwd)
{ {
std::string username(name); std::string username(name);
std::string password(pwd); std::string password(pwd);

View file

@ -71,7 +71,7 @@ class RsSshd: public RsThread, public RpcComms
public: public:
// NB: This must be called EARLY before all the threads are launched. // NB: This must be called EARLY before all the threads are launched.
static RsSshd *InitRsSshd(std::string portstr, std::string rsakeyfile); static RsSshd *InitRsSshd(const std::string &portstr, const std::string &rsakeyfile);
// Interface. // Interface.
@ -101,7 +101,7 @@ int adduserpwdhash(std::string username, std::string hash);
private: private:
RsSshd(std::string portStr); /* private constructor => so can only create with */ RsSshd(std::string portStr); /* private constructor => so can only create with */
int init(std::string pathrsakey); int init(const std::string &pathrsakey);
// High level operations. // High level operations.
int listenConnect(); int listenConnect();
@ -122,8 +122,8 @@ int cleanupSession();
int cleanupAll(); int cleanupAll();
/* Password Checking */ /* Password Checking */
int auth_password(char *name, char *pwd); int auth_password(const char *name, const char *pwd);
int auth_password_hashed(char *name, char *pwd); int auth_password_hashed(const char *name, const char *pwd);
#ifdef ALLOW_CLEARPWDS #ifdef ALLOW_CLEARPWDS
int auth_password_basic(char *name, char *pwd); int auth_password_basic(char *name, char *pwd);
#endif // ALLOW_CLEARPWDS #endif // ALLOW_CLEARPWDS