2017-02-21 Fred Gleason <fredg@paravelsystems.com>

* Modified 'lib/rdformpost.cpp' to use read-only accessors for
	std::map values.
	* Added a check for valid event IDs for the 'SaveLog' method in
	'web/rdxport/logs.cpp'.
This commit is contained in:
Fred Gleason 2017-02-21 16:51:25 -05:00
parent bc55c06eee
commit db0e842496
3 changed files with 22 additions and 11 deletions

View File

@ -15600,3 +15600,8 @@
* Changed the behavior of the TagStation RLM as to not send an update * Changed the behavior of the TagStation RLM as to not send an update
if its group is not explicitly listed in one of the TagStation if its group is not explicitly listed in one of the TagStation
categories. categories.
2017-02-21 Fred Gleason <fredg@paravelsystems.com>
* Modified 'lib/rdformpost.cpp' to use read-only accessors for
std::map values.
* Added a check for valid event IDs for the 'SaveLog' method in
'web/rdxport/logs.cpp'.

View File

@ -112,7 +112,7 @@ RDFormPost::~RDFormPost()
for(std::map<QString,bool>::const_iterator ci=post_filenames.begin(); for(std::map<QString,bool>::const_iterator ci=post_filenames.begin();
ci!=post_filenames.end();ci++) { ci!=post_filenames.end();ci++) {
if(ci->second) { if(ci->second) {
unlink(post_values[ci->first].toString()); unlink(post_values.at(ci->first).toString());
} }
} }
if(!post_tempdir.isNull()) { if(!post_tempdir.isNull()) {
@ -143,7 +143,7 @@ QVariant RDFormPost::value(const QString &name,bool *ok)
{ {
QVariant v; QVariant v;
if(post_values.count(name)>0) { if(post_values.count(name)>0) {
v=post_values[name]; v=post_values.at(name);
} }
if(ok!=NULL) { if(ok!=NULL) {
*ok=(post_values.count(name)>0); *ok=(post_values.count(name)>0);
@ -170,7 +170,7 @@ bool RDFormPost::getValue(const QString &name,QHostAddress *addr,bool *ok)
bool RDFormPost::getValue(const QString &name,QString *str,bool *ok) bool RDFormPost::getValue(const QString &name,QString *str,bool *ok)
{ {
if(post_values.count(name)>0) { if(post_values.count(name)>0) {
*str=post_values[name].toString(); *str=post_values.at(name).toString();
return true; return true;
} }
return false; return false;
@ -180,7 +180,7 @@ bool RDFormPost::getValue(const QString &name,QString *str,bool *ok)
bool RDFormPost::getValue(const QString &name,int *n,bool *ok) bool RDFormPost::getValue(const QString &name,int *n,bool *ok)
{ {
if(post_values.count(name)>0) { if(post_values.count(name)>0) {
*n=post_values[name].toInt(ok); *n=post_values.at(name).toInt(ok);
return true; return true;
} }
return false; return false;
@ -190,7 +190,7 @@ bool RDFormPost::getValue(const QString &name,int *n,bool *ok)
bool RDFormPost::getValue(const QString &name,long *n,bool *ok) bool RDFormPost::getValue(const QString &name,long *n,bool *ok)
{ {
if(post_values.count(name)>0) { if(post_values.count(name)>0) {
*n=post_values[name].toLongLong(ok); *n=post_values.at(name).toLongLong(ok);
return true; return true;
} }
*n=0; *n=0;
@ -264,7 +264,7 @@ bool RDFormPost::getValue(const QString &name,QTime *time,bool *ok)
bool RDFormPost::getValue(const QString &name,bool *state,bool *ok) bool RDFormPost::getValue(const QString &name,bool *state,bool *ok)
{ {
if(post_values.count(name)>0) { if(post_values.count(name)>0) {
*state=post_values[name].toInt(ok); *state=post_values.at(name).toInt(ok);
return true; return true;
} }
return false; return false;
@ -445,6 +445,7 @@ void RDFormPost::LoadUrlEncoding(char first)
printf("POST DUMPED TO \"/tmp/output.dat\"!\n"); printf("POST DUMPED TO \"/tmp/output.dat\"!\n");
exit(0); exit(0);
*/ */
lines=lines.split("&",data); lines=lines.split("&",data);
for(unsigned i=0;i<lines.size();i++) { for(unsigned i=0;i<lines.size();i++) {
line=line.split("=",lines[i]); line=line.split("=",lines[i]);
@ -558,14 +559,14 @@ void RDFormPost::LoadMultipartEncoding(char first)
} }
else { // Read data else { // Read data
if(filename.isEmpty()) { if(filename.isEmpty()) {
QString str=post_values[name].toString(); QString str=post_values.at(name).toString();
str+=QString(data); str+=QString(data);
post_filenames[name]=false; post_filenames[name]=false;
post_values[name]=str.simplifyWhiteSpace(); post_values.at(name)=str.simplifyWhiteSpace();
} }
else { else {
post_filenames[name]=true; post_filenames[name]=true;
post_values[name]=filename; post_values.at(name)=filename;
write(fd,data,n); write(fd,data,n);
} }
} }

View File

@ -266,9 +266,14 @@ void Xport::SaveLog()
QDateTime datetime; QDateTime datetime;
QTime time; QTime time;
bool state; bool state;
if(!xport_post->getValue(line+"_ID",&integer1)) { bool ok=false;
if(!xport_post->getValue(line+"_ID",&integer1,&ok)) {
XmlExit("Missing "+line+"_ID",400); XmlExit("Missing "+line+"_ID",400);
} }
if(!ok) {
XmlExit("Invalid "+line+"_ID",400);
}
ll->setId(integer1); ll->setId(integer1);
if(!xport_post->getValue(line+"_TYPE",&integer1)) { if(!xport_post->getValue(line+"_TYPE",&integer1)) {
@ -452,5 +457,5 @@ void Xport::SaveLog()
logevt->save(); logevt->save();
XmlExit("OK",200); XmlExit(QString().sprintf("OK Saved %d events",logevt->size()),200);
} }