summaryrefslogtreecommitdiffstats
path: root/src/client/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/net')
-rw-r--r--src/client/net/serverconnection.cpp9
-rw-r--r--src/client/net/serverconnection.h2
-rw-r--r--src/client/net/serverdiscovery.cpp6
3 files changed, 9 insertions, 8 deletions
diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp
index 826cf06..e9cc72c 100644
--- a/src/client/net/serverconnection.cpp
+++ b/src/client/net/serverconnection.cpp
@@ -110,8 +110,9 @@ void ServerConnection::handleMsg()
// Initial challenge request by server
emit stateChange(ConnectWindow::AwaitingChallengeResponse);
_myChallenge.resize(CHALLENGE_LEN);
- for (int i = 0; i < CHALLENGE_LEN; ++i)
- _myChallenge[i] = qrand() & 0xff;
+ for (int i = 0; i < CHALLENGE_LEN; ++i) {
+ _myChallenge[i] = (char)(qrand() & 0xff);
+ }
QByteArray serverChallenge(_fromServer.getFieldBytes(_CHALLENGE));
_toServer.reset();
_toServer.setField(_ID, _CHALLENGE);
@@ -141,13 +142,13 @@ void ServerConnection::handleMsg()
return;
}
emit stateChange(ConnectWindow::LoggingIn);
- char *user = getpwuid(getuid())->pw_name;
+ const char *user = getpwuid(getuid())->pw_name;
if (user == NULL || *user == '\0')
user = getenv("USER");
if (user == NULL || *user == '\0')
user = getenv("USERNAME");
if (user == NULL || *user == '\0')
- user = (char*)"Hans Affe";
+ user = "Hans Affe";
_toServer.reset();
_toServer.setField(_ID, _LOGIN);
_toServer.setField("HOST", QHostInfo::localHostName());
diff --git a/src/client/net/serverconnection.h b/src/client/net/serverconnection.h
index 17fa20a..9db9b02 100644
--- a/src/client/net/serverconnection.h
+++ b/src/client/net/serverconnection.h
@@ -36,7 +36,7 @@ public:
ServerConnection(const QString& host, const quint16 port, const QByteArray& sessionName, const QByteArray& certHash, bool autoConnect);
void disconnectFromServer();
~ServerConnection();
- const inline bool isConnected() const
+ inline bool isConnected() const
{
return _socket != NULL && _socket->state() == QAbstractSocket::ConnectedState;
}
diff --git a/src/client/net/serverdiscovery.cpp b/src/client/net/serverdiscovery.cpp
index 99a0dcd..5ca0eba 100644
--- a/src/client/net/serverdiscovery.cpp
+++ b/src/client/net/serverdiscovery.cpp
@@ -21,7 +21,7 @@ ServerDiscovery::ServerDiscovery(QObject *parent)
/* Try to get a UDP port for server discovery */
int tries = 10;
while (tries-- != 0) {
- const quint16 port = (quint16)(qrand() % 10000) + 10000;
+ const quint16 port = (quint16)(qrand() % 10000 + 10000);
if (_discoverySocket.bind(QHostAddress::Any, port))
break;
if (tries == 0)
@@ -98,8 +98,8 @@ void ServerDiscovery::doDiscovery()
if (_salt2.size() < SALT_LEN)
_salt2.resize(SALT_LEN);
for (int i = 0; i < SALT_LEN; ++i) {
- salt1[i] = qrand() & 0xff;
- _salt2[i] = qrand() & 0xff;
+ salt1[i] = (char)(qrand() & 0xff);
+ _salt2[i] = (char)(qrand() & 0xff);
}
_packet.reset();
_packet.setField(_HASH, genSha1(&_nameBytes, &salt1, &iplist));