mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-22 17:45:48 -05:00
b79b774969
Found with: ASAN_OPTIONS="detect_odr_violation=1,strip_path_prefix=$(pwd)/" build/sdrangel Fixes: Direct leak of 16 byte(s) in 1 object(s) allocated from: #0 0x7f3c3e0f46b8 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:95 #1 0x7f3bfdef913c in WebServer::WebServer(unsigned short&, QObject*) sdrangel/plugins/feature/skymap/webserver.cpp:34 #2 0x7f3bfdf10b56 in SkyMapGUI::SkyMapGUI(PluginAPI*, FeatureUISet*, Feature*, QWidget*) sdrangel/plugins/feature/skymap/skymapgui.cpp:220 #3 0x7f3bfdf0eb20 in SkyMapGUI::create(PluginAPI*, FeatureUISet*, Feature*) sdrangel/plugins/feature/skymap/skymapgui.cpp:44 #4 0x7f3bfdef75e9 in SkyMapPlugin::createFeatureGUI(FeatureUISet*, Feature*) const sdrangel/plugins/feature/skymap/skymapplugin.cpp:72 #5 0x7f3c3d60938b in MainWindow::featureAddClicked(Workspace*, int) sdrangel/sdrgui/mainwindow.cpp:2888 #6 0x7f3c3d624621 in QtPrivate::FunctorCall<QtPrivate::IndexesList<0, 1>, QtPrivate::List<Workspace*, int>, void, void (MainWindow::*)(Workspace*, int)>::call(void (MainWindow::*)(Workspace*, int), MainWindow*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:152 #7 0x7f3c3d61feed in void QtPrivate::FunctionPointer<void (MainWindow::*)(Workspace*, int)>::call<QtPrivate::List<Workspace*, int>, void>(void (MainWindow::*)(Workspace*, int), MainWindow*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:185 #8 0x7f3c3d61d376 in QtPrivate::QSlotObject<void (MainWindow::*)(Workspace*, int), QtPrivate::List<Workspace*, int>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:418 #9 0x7f3c387062b1 (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x3062b1) (BuildId: ed2abb344a128279a866aa6c4a79f3fa5c87c59e) #10 0x7f3c3d5d5ca4 in Workspace::addFeature(Workspace*, int) build-sdrangel-Desktop_qt5-Debug/sdrgui/sdrgui_autogen/DMHXEJ42XS/moc_workspace.cpp:393 #11 0x7f3c3d90c6a2 in Workspace::addFeatureEmitted(int) sdrangel/sdrgui/gui/workspace.cpp:413 #12 0x7f3c3d9245bb in QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<int>, void, void (Workspace::*)(int)>::call(void (Workspace::*)(int), Workspace*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:152 #13 0x7f3c3d91fb83 in void QtPrivate::FunctionPointer<void (Workspace::*)(int)>::call<QtPrivate::List<int>, void>(void (Workspace::*)(int), Workspace*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:185 #14 0x7f3c3d91cc86 in QtPrivate::QSlotObject<void (Workspace::*)(int), QtPrivate::List<int>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:418 #15 0x7f3c387062b1 (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x3062b1) (BuildId: ed2abb344a128279a866aa6c4a79f3fa5c87c59e) #16 0x7f3c3d5c3c77 in FeatureAddDialog::addFeature(int) build-sdrangel-Desktop_qt5-Debug/sdrgui/sdrgui_autogen/DMHXEJ42XS/moc_featureadddialog.cpp:141 #17 0x7f3c3d6d0d79 in FeatureAddDialog::apply(QAbstractButton*) sdrangel/sdrgui/gui/featureadddialog.cpp:53 #18 0x7f3c3d5c380e in FeatureAddDialog::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) build-sdrangel-Desktop_qt5-Debug/sdrgui/sdrgui_autogen/DMHXEJ42XS/moc_featureadddialog.cpp:82 #19 0x7f3c38705fcc (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x305fcc) (BuildId: ed2abb344a128279a866aa6c4a79f3fa5c87c59e) #20 0x7f3c395029b2 in QDialogButtonBox::clicked(QAbstractButton*) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x3029b2) (BuildId: dfefd27f084c0dd066215fc79825fceae604f481) and more
82 lines
3.0 KiB
C++
82 lines
3.0 KiB
C++
///////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright (C) 2022-2024 Jon Beniston, M7RCE <jon@beniston.com> //
|
|
// //
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
// it under the terms of the GNU General Public License as published by //
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
// (at your option) any later version. //
|
|
// //
|
|
// This program is distributed in the hope that it will be useful, //
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
// GNU General Public License V3 for more details. //
|
|
// //
|
|
// You should have received a copy of the GNU General Public License //
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef INCLUDE_WEB_SERVER_H_
|
|
#define INCLUDE_WEB_SERVER_H_
|
|
|
|
#include <QTcpServer>
|
|
#include <QTcpSocket>
|
|
|
|
// WebServer for making simple dynamic html pages and serving binaries from
|
|
// resources or local disk
|
|
class WebServer : public QTcpServer
|
|
{
|
|
Q_OBJECT
|
|
|
|
struct Substitution {
|
|
QString m_from;
|
|
QString m_to;
|
|
Substitution(const QString& from, const QString& to) :
|
|
m_from(from),
|
|
m_to(to)
|
|
{
|
|
}
|
|
};
|
|
|
|
struct MimeType {
|
|
QString m_type;
|
|
bool m_binary;
|
|
MimeType(const QString& type, bool binary=true) :
|
|
m_type(type),
|
|
m_binary(binary)
|
|
{
|
|
}
|
|
};
|
|
|
|
private:
|
|
|
|
// Hash of a list of paths to substitute
|
|
QHash<QString, QString> m_pathSubstitutions;
|
|
|
|
// Hash of path to a list of substitutions to make in the file
|
|
QHash<QString, QList<Substitution *>*> m_substitutions;
|
|
|
|
// Hash of files held in memory
|
|
QHash<QString, QByteArray> m_files;
|
|
|
|
// Hash of filename extension to MIME type information
|
|
QHash<QString, MimeType *> m_mimeTypes;
|
|
MimeType m_defaultMimeType;
|
|
|
|
public:
|
|
WebServer(quint16 &port, QObject* parent = 0);
|
|
~WebServer();
|
|
void incomingConnection(qintptr socket) override;
|
|
void addPathSubstitution(const QString &from, const QString &to);
|
|
void addSubstitution(QString path, QString from, QString to);
|
|
void addFile(const QString &path, const QByteArray &data);
|
|
QString substitute(QString path, QString html);
|
|
void sendFile(QTcpSocket* socket, const QByteArray &data, MimeType *mimeType, const QString &path);
|
|
|
|
private slots:
|
|
void readClient();
|
|
void discardClient();
|
|
|
|
};
|
|
|
|
#endif
|