2018-07-27 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in ripcd(8) that threw a segfault when executing
	'DC!'.
This commit is contained in:
Fred Gleason
2018-07-27 09:30:52 -04:00
parent 3e0929ba77
commit 046ddb0264
3 changed files with 17 additions and 11 deletions

View File

@@ -17235,3 +17235,6 @@
passed a filter string consisting of pure whitespace.
* Fixed bugs in 'rdcastmanager.cgi' that caused corruption when
displaying UTF-8 strings.
2018-07-27 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in ripcd(8) that threw a segfault when executing
'DC!'.

View File

@@ -436,7 +436,9 @@ void MainObject::ParseCommand(int ch)
}
if(buf[i]=='!') {
conn->args[conn->argnum++][conn->argptr]=0;
DispatchCommand(ch);
if(!DispatchCommand(ch)) { // Connection closed?
return;
}
conn->argnum=0;
conn->argptr=0;
if(conn->socket==NULL) {
@@ -460,7 +462,7 @@ void MainObject::ParseCommand(int ch)
}
void MainObject::DispatchCommand(int ch)
bool MainObject::DispatchCommand(int ch)
{
QString default_name;
char str[RD_RML_MAX_LENGTH];
@@ -479,18 +481,18 @@ void MainObject::DispatchCommand(int ch)
if(!strcmp(conn->args[0],"DC")) { // Drop Connection
conn->socket->close();
KillSocket(ch);
return;
return false;
}
if(!strcmp(conn->args[0],"PW")) { // Password Authenticate
if(!strcmp(conn->args[1],rda->config()->password())) {
conn->auth=true;
EchoCommand(ch,"PW +!");
return;
return true;
}
else {
conn->auth=false;
EchoCommand(ch,"PW -!");
return;
return true;
}
}
@@ -500,13 +502,13 @@ void MainObject::DispatchCommand(int ch)
//
if(!conn->auth) {
EchoArgs(ch,'-');
return;
return true;
}
if(!strcmp(conn->args[0],"RU")) { // Request User
EchoCommand(ch,(const char *)QString().
sprintf("RU %s!",(const char *)rda->station()->userName()));
return;
return true;
}
if(!strcmp(conn->args[0],"SU")) { // Set User
@@ -515,7 +517,7 @@ void MainObject::DispatchCommand(int ch)
if(!strcmp(conn->args[0],"MS")) { // Send RML Command
if(conn->argnum<4) {
return;
return true;
}
strcpy(str,conn->args[3]);
for(int i=4;i<conn->argnum;i++) {
@@ -558,7 +560,7 @@ void MainObject::DispatchCommand(int ch)
if(!strcmp(conn->args[0],"ME")) { // Send RML Reply
if(conn->argnum<4) {
return;
return true;
}
strcpy(str,conn->args[3]);
for(int i=4;i<conn->argnum;i++) {
@@ -633,7 +635,7 @@ void MainObject::DispatchCommand(int ch)
if(!notify->read(msg)) {
LogLine(RDConfig::LogWarning,"invalid notification processed");
delete notify;
return;
return true;
}
BroadcastCommand("ON "+msg+"!",ch);
ripcd_notification_mcaster->
@@ -644,6 +646,7 @@ void MainObject::DispatchCommand(int ch)
if(!strcmp(conn->args[0],"TA")) { // Send Onair Flag State
EchoCommand(ch,QString().sprintf("TA %d!",ripc_onair_flag));
}
return true;
}

View File

@@ -86,7 +86,7 @@ class MainObject : public QObject
void ExecCart(int cartnum);
void LogGpioEvent(int matrix,int line,RDMatrix::GpioType type,bool state);
void ParseCommand(int);
void DispatchCommand(int);
bool DispatchCommand(int);
void KillSocket(int);
void EchoCommand(int,const char *);
void BroadcastCommand(const char *,int except_ch=-1);