From db0e8424964be341988075c79b71e34ddb80ff75 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Tue, 21 Feb 2017 16:51:25 -0500 Subject: [PATCH] 2017-02-21 Fred Gleason * 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'. --- ChangeLog | 5 +++++ lib/rdformpost.cpp | 19 ++++++++++--------- web/rdxport/logs.cpp | 9 +++++++-- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 473abf2a..f976f34c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15600,3 +15600,8 @@ * 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 categories. +2017-02-21 Fred Gleason + * 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'. diff --git a/lib/rdformpost.cpp b/lib/rdformpost.cpp index 6df46cde..0f5ec061 100644 --- a/lib/rdformpost.cpp +++ b/lib/rdformpost.cpp @@ -112,7 +112,7 @@ RDFormPost::~RDFormPost() for(std::map::const_iterator ci=post_filenames.begin(); ci!=post_filenames.end();ci++) { if(ci->second) { - unlink(post_values[ci->first].toString()); + unlink(post_values.at(ci->first).toString()); } } if(!post_tempdir.isNull()) { @@ -143,7 +143,7 @@ QVariant RDFormPost::value(const QString &name,bool *ok) { QVariant v; if(post_values.count(name)>0) { - v=post_values[name]; + v=post_values.at(name); } if(ok!=NULL) { *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) { if(post_values.count(name)>0) { - *str=post_values[name].toString(); + *str=post_values.at(name).toString(); return true; } 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) { if(post_values.count(name)>0) { - *n=post_values[name].toInt(ok); + *n=post_values.at(name).toInt(ok); return true; } 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) { if(post_values.count(name)>0) { - *n=post_values[name].toLongLong(ok); + *n=post_values.at(name).toLongLong(ok); return true; } *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) { if(post_values.count(name)>0) { - *state=post_values[name].toInt(ok); + *state=post_values.at(name).toInt(ok); return true; } return false; @@ -445,6 +445,7 @@ void RDFormPost::LoadUrlEncoding(char first) printf("POST DUMPED TO \"/tmp/output.dat\"!\n"); exit(0); */ + lines=lines.split("&",data); for(unsigned i=0;igetValue(line+"_ID",&integer1)) { + bool ok=false; + + if(!xport_post->getValue(line+"_ID",&integer1,&ok)) { XmlExit("Missing "+line+"_ID",400); } + if(!ok) { + XmlExit("Invalid "+line+"_ID",400); + } ll->setId(integer1); if(!xport_post->getValue(line+"_TYPE",&integer1)) { @@ -452,5 +457,5 @@ void Xport::SaveLog() logevt->save(); - XmlExit("OK",200); + XmlExit(QString().sprintf("OK Saved %d events",logevt->size()),200); }