Commit 6d358ae4 authored by Josef Kindberg's avatar Josef Kindberg Committed by Patrik Ryd
Browse files

libsysutils: Increase command buffersize and command args


Needed to support tethering of multiple remote Bluetooth devices.

Change-Id: I9f736affd83226e8b2fa4f0faacd3654175dd8c9
Signed-off-by: default avatarPatrik Ryd <patrik.ryd@stericsson.com>
parent a6fb0e05
...@@ -23,10 +23,11 @@ class SocketClient; ...@@ -23,10 +23,11 @@ class SocketClient;
class FrameworkListener : public SocketListener { class FrameworkListener : public SocketListener {
public: public:
static const int CMD_ARGS_MAX = 16; static const int CMD_ARGS_MAX = 26;
/* 1 out of errorRate will be dropped */ /* 1 out of errorRate will be dropped */
int errorRate; int errorRate;
private: private:
int mCommandCount; int mCommandCount;
bool mWithSeq; bool mWithSeq;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <sysutils/FrameworkCommand.h> #include <sysutils/FrameworkCommand.h>
#include <sysutils/SocketClient.h> #include <sysutils/SocketClient.h>
static const int CMD_BUF_SIZE = 1024;
FrameworkListener::FrameworkListener(const char *socketName, bool withSeq) : FrameworkListener::FrameworkListener(const char *socketName, bool withSeq) :
SocketListener(socketName, true, withSeq) { SocketListener(socketName, true, withSeq) {
init(socketName, withSeq); init(socketName, withSeq);
...@@ -43,7 +45,7 @@ void FrameworkListener::init(const char *socketName, bool withSeq) { ...@@ -43,7 +45,7 @@ void FrameworkListener::init(const char *socketName, bool withSeq) {
} }
bool FrameworkListener::onDataAvailable(SocketClient *c) { bool FrameworkListener::onDataAvailable(SocketClient *c) {
char buffer[255]; char buffer[CMD_BUF_SIZE];
int len; int len;
len = TEMP_FAILURE_RETRY(read(c->getSocket(), buffer, sizeof(buffer))); len = TEMP_FAILURE_RETRY(read(c->getSocket(), buffer, sizeof(buffer)));
...@@ -52,6 +54,8 @@ bool FrameworkListener::onDataAvailable(SocketClient *c) { ...@@ -52,6 +54,8 @@ bool FrameworkListener::onDataAvailable(SocketClient *c) {
return false; return false;
} else if (!len) } else if (!len)
return false; return false;
if(buffer[len-1] != '\0')
SLOGW("String is not zero-terminated");
int offset = 0; int offset = 0;
int i; int i;
...@@ -63,6 +67,7 @@ bool FrameworkListener::onDataAvailable(SocketClient *c) { ...@@ -63,6 +67,7 @@ bool FrameworkListener::onDataAvailable(SocketClient *c) {
offset = i + 1; offset = i + 1;
} }
} }
return true; return true;
} }
...@@ -74,7 +79,7 @@ void FrameworkListener::dispatchCommand(SocketClient *cli, char *data) { ...@@ -74,7 +79,7 @@ void FrameworkListener::dispatchCommand(SocketClient *cli, char *data) {
FrameworkCommandCollection::iterator i; FrameworkCommandCollection::iterator i;
int argc = 0; int argc = 0;
char *argv[FrameworkListener::CMD_ARGS_MAX]; char *argv[FrameworkListener::CMD_ARGS_MAX];
char tmp[255]; char tmp[CMD_BUF_SIZE];
char *p = data; char *p = data;
char *q = tmp; char *q = tmp;
char *qlimit = tmp + sizeof(tmp) - 1; char *qlimit = tmp + sizeof(tmp) - 1;
...@@ -180,7 +185,6 @@ void FrameworkListener::dispatchCommand(SocketClient *cli, char *data) { ...@@ -180,7 +185,6 @@ void FrameworkListener::dispatchCommand(SocketClient *cli, char *data) {
goto out; goto out;
} }
} }
cli->sendMsg(500, "Command not recognized", false); cli->sendMsg(500, "Command not recognized", false);
out: out:
int j; int j;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment