fixed: ebusctl crashed, if size of input buffer is reached.
This commit is contained in:
@@ -153,11 +153,10 @@ void BaseLoop::start()
|
||||
}
|
||||
|
||||
void BaseLoop::logRaw(const unsigned char byte, bool received) {
|
||||
if (received == true) {
|
||||
if (received == true)
|
||||
L.log(bus, event, "<%02x", byte);
|
||||
} else {
|
||||
else
|
||||
L.log(bus, event, ">%02x", byte);
|
||||
}
|
||||
}
|
||||
|
||||
string BaseLoop::decodeMessage(const string& data)
|
||||
@@ -553,7 +552,7 @@ string BaseLoop::decodeMessage(const string& data)
|
||||
result << "commands:" << endl
|
||||
<< " read - read ebus values 'read [-v] [-f] [-m seconds] [class] name' or 'read [-v] [-f] [-m seconds] class name field'" << endl
|
||||
<< " write - write ebus values 'write class name value[;value]*' or 'write -h ZZPBSBNNDx'" << endl
|
||||
<< " find - find ebus values 'find [name]' or 'find class name'" << endl << endl
|
||||
<< " find - find ebus values usage: 'find [-v] [-r] [-w] [-p] [name]' or 'find [-v] [-r] [-w] [-p] class name'" << endl << endl
|
||||
<< " scan - scan ebus known addresses 'scan'" << endl
|
||||
<< " - scan ebus all addresses 'scan full'" << endl
|
||||
<< " - show scan results 'scan result'" << endl << endl
|
||||
|
||||
@@ -73,13 +73,19 @@ bool connect(const char* host, int port, bool once)
|
||||
socket->send(message.c_str(), message.size());
|
||||
|
||||
if (strncasecmp(message.c_str(), "QUIT", 4) != 0 && strncasecmp(message.c_str(), "STOP", 4) != 0) {
|
||||
|
||||
char data[1024];
|
||||
size_t datalen;
|
||||
|
||||
datalen = socket->recv(data, sizeof(data)-1);
|
||||
data[datalen] = '\0';
|
||||
do {
|
||||
memset(data, 0, sizeof(data));
|
||||
datalen = socket->recv(data, sizeof(data)-1);
|
||||
|
||||
if (data[datalen-1] != '\n')
|
||||
cout << data;
|
||||
|
||||
} while (data[datalen-1] != '\n');
|
||||
|
||||
data[datalen] = '\0';
|
||||
cout << data;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user