Skip to content

Commit

Permalink
More on Flawfinder false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
ea4k committed Jun 13, 2021
1 parent de96ecd commit 43b5d1e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ TBD - 1.6
- Bugfix: Hamlib was not properly started on KLog start (closes #126) (TNX G4MKT)
- Improvement: Added user selectable ADIF fields in the Other and My Data tabs. (Closes #4)
- Improvement: Enhanced how the UDP server is started on KLog start.
- Improvement: Added some basic SQL Injection protection to the UI. (closes #95)
- Improvement: UI data is saved before entering the Setup and restored after setup is done. (closes #188)
- Improvement: Added some basic SQL Injection protection to the UI. (Closes #95)
- Improvement: UI data is saved before entering the Setup and restored after setup is done. (Closes #188)
- Improvement: Only one instance of KLog is allowed to run simultaneously. (Closes #250) (TNX foldynl)
- Commented some Flawfinder false positives.
- Translations: Catalan (TNX Txema), Czech (TNX OK1MLG) & Spanish (EA4K).

Expand Down
2 changes: 1 addition & 1 deletion src/elogclublog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ void eLogClubLog::sendLogFile(const QString &_file, QList<int> _qso, bool _overw

//QFile *file = new QFile("_file");
QFile *file = new QFile(util->getClubLogFile());
if (file->open(QIODevice::ReadOnly))
if (file->open(QIODevice::ReadOnly)) /* Flawfinder: ignore */
{
blob = file->readAll();

Expand Down
26 changes: 13 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ int main(int argc, char *argv[])
{
myappTranslator.load(QCoreApplication::applicationDirPath() + "/translations/klog_" + (QLocale::system().name()).left(2) + ".qm"); /* Flawfinder: ignore */
}
else if (QFile::exists(QDir::homePath()+"/klog/klog_" + (QLocale::system().name()).left(2)+ ".qm") )
else if (QFile::exists(QDir::homePath()+"/klog/klog_" + (QLocale::system().name()).left(2)+ ".qm") ) /* Flawfinder: ignore */
{
myappTranslator.load(QDir::homePath()+"/klog/klog_" + (QLocale::system().name()));
myappTranslator.load(QDir::homePath()+"/klog/klog_" + (QLocale::system().name())); /* Flawfinder: ignore */
}
else if (((QLocale::system().name()).left(2)) == "en") /* Flawfinder: ignore */
{ // If language is English, it will execute without showing message
Expand All @@ -142,9 +142,9 @@ int main(int argc, char *argv[])
#elif defined(Q_OS_OSX)
//qDebug() << "KLog OSX " << endl;

if (QFile::exists(QCoreApplication::applicationDirPath() + "/translations/klog_" + (QLocale::system().name()).left(2) + ".qm") )
if (QFile::exists(QCoreApplication::applicationDirPath() + "/translations/klog_" + (QLocale::system().name()).left(2) + ".qm") ) /* Flawfinder: ignore */
{
myappTranslator.load(QCoreApplication::applicationDirPath() + "/translations/klog_" + (QLocale::system().name()).left(2) + ".qm");
myappTranslator.load(QCoreApplication::applicationDirPath() + "/translations/klog_" + (QLocale::system().name()).left(2) + ".qm"); /* Flawfinder: ignore */
}
else if (((QLocale::system().name()).left(2)) == "en") /* Flawfinder: ignore */
{ // If language is English, it will execute without showing message
Expand All @@ -156,22 +156,22 @@ int main(int argc, char *argv[])
}
#else
//qDebug() << "KLog OTHER OS: " << (QLocale::system()).name() << endl;
if (QFile::exists("klog_" + (QLocale::system().name()).left(2) + ".qm") )
if (QFile::exists("klog_" + (QLocale::system().name()).left(2) + ".qm") ) /* Flawfinder: ignore */
{
myappTranslator.load("klog_" + (QLocale::system().name()).left(2));
myappTranslator.load("klog_" + (QLocale::system().name()).left(2)); /* Flawfinder: ignore */
}
else if (QFile::exists("/usr/share/klog/translations/klog_" + (QLocale::system().name()).left(2) + ".qm") )
else if (QFile::exists("/usr/share/klog/translations/klog_" + (QLocale::system().name()).left(2) + ".qm") ) /* Flawfinder: ignore */
{
//qDebug() << "KLog OTHER -2: " << "/usr/share/klog/klog_" + (QLocale::system().name()).left(2) << endl;
myappTranslator.load("/usr/share/klog/translations/klog_" + (QLocale::system().name()));
//qDebug() << "KLog OTHER -2: " << "/usr/share/klog/klog_" + (QLocale::system().name()).left(2) << endl; /* Flawfinder: ignore */
myappTranslator.load("/usr/share/klog/translations/klog_" + (QLocale::system().name())); /* Flawfinder: ignore */
}
else if (QFile::exists(QCoreApplication::applicationDirPath() + "/translations/klog_" + (QLocale::system().name()).left(2) + ".qm"))
else if (QFile::exists(QCoreApplication::applicationDirPath() + "/translations/klog_" + (QLocale::system().name()).left(2) + ".qm")) /* Flawfinder: ignore */
{
//qDebug() << "KLog OTHER -3: " << QCoreApplication::applicationDirPath() + "/translations/klog_" + (QLocale::system().name()).left(2) << endl;
myappTranslator.load(QCoreApplication::applicationDirPath() + "/translations/klog_" + (QLocale::system().name()));
myappTranslator.load(QCoreApplication::applicationDirPath() + "/translations/klog_" + (QLocale::system().name())); /* Flawfinder: ignore */
}

else if (((QLocale::system().name()).left(2)) == "en")
else if (((QLocale::system().name()).left(2)) == "en") /* Flawfinder: ignore */
{ // If language is English, it will execute without showing message

}
Expand All @@ -195,7 +195,7 @@ int main(int argc, char *argv[])
msgBox.setWindowTitle("KLog");
msgBox.setIcon(QMessageBox::Warning);
msgBox.setTextFormat(Qt::RichText);
QString language = (QLocale::system().name()).left(2);
QString language = (QLocale::system().name()).left(2); /* Flawfinder: ignore */

msg = QString("No translation files for your language have been found so KLog will be shown in English.") + "<p>" +
QString("If you have the klog_%1.qm file for your language, you can copy it into the %2/translations/ folder and restart KLog.</p><p>If you want to help to translate KLog into your language, please contact the author.").arg(language).arg(QCoreApplication::applicationDirPath()) +
Expand Down
2 changes: 1 addition & 1 deletion src/mainqsoentrywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void MainQSOEntryWidget::createUI()
palBlack.setColor(QPalette::Text, Qt::black);

connect(qrzLineEdit, SIGNAL(returnPressed()), this, SLOT(slotOKButtonClicked() ) );
connect(qrzLineEdit, SIGNAL(res), this, SLOT(slotOKButtonClicked() ) );
//connect(qrzLineEdit, SIGNAL(res), this, SLOT(slotOKButtonClicked() ) );
//connect(qrzLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotQRZTextChanged() ) );
connect(qrzLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotStartDelayInputTimer() ) );
connect(delayInputTimer, SIGNAL(timeout()), this, SLOT(slotDelayInputTimedOut() ) );
Expand Down
3 changes: 2 additions & 1 deletion src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ QString Utilities::getKLogDBFile()
dbPath = getKLogDefaultDatabaseFile();
QFile file(getCfgFile());

if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) /* Flawfinder: ignore */
{

//return dbPath;
//return getKLogDatabaseFile(dbPath);
Expand Down

1 comment on commit 43b5d1e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaws found

./src/hamlibclass.cpp:455:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
./src/hamlibclass.cpp:473:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).

Please sign in to comment.