Skip to content

Commit

Permalink
Merge branch 'master' into development/ipcchannel_dangling_handlers_t…
Browse files Browse the repository at this point in the history
…estcase
  • Loading branch information
msieben authored Sep 23, 2024
2 parents 5c900fc + da77127 commit 8f15665
Show file tree
Hide file tree
Showing 28 changed files with 459 additions and 374 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/Linux build template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
sudo apt-spy2 fix --commit --launchpad --country=US
echo "deb http://archive.ubuntu.com/ubuntu/ jammy main universe restricted multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb http://archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted multiverse" | sudo tee -a /etc/apt/sources.list
sudo dpkg --add-architecture i386
${{matrix.architecture == '32' && 'sudo dpkg --add-architecture i386' || ':'}}
sudo apt-get update
sudo apt install python3-pip build-essential cmake ninja-build libusb-1.0-0-dev zlib1g-dev zlib1g-dev:i386 libssl-dev gcc-11-multilib g++-11-multilib
sudo apt install python3-pip build-essential cmake ninja-build libusb-1.0-0-dev ${{matrix.architecture == '32' && 'zlib1g-dev:i386 libssl-dev:i386 libsbc-dev:i386 gcc-11-multilib g++-11-multilib' || 'zlib1g-dev libssl-dev libsbc-dev'}}
sudo pip install jsonref
# ----- Checkout & DependsOn regex -----
Expand Down Expand Up @@ -85,6 +85,7 @@ jobs:
# ----- Installing generators & Options regex -----
- name: Install generators
run: |
${{matrix.architecture == '32' && 'export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH' || 'PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH'}}
cmake -G Ninja -S ThunderTools -B ${{matrix.build_type}}/build/ThunderTools \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror -m${{matrix.architecture}}" \
-DCMAKE_C_FLAGS="-Wall -Wextra -Wpedantic -Werror -m${{matrix.architecture}}" \
Expand All @@ -103,6 +104,7 @@ jobs:
# ----- Building & uploading artifacts -----
- name: Build Thunder
run: |
${{matrix.architecture == '32' && 'export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH' || 'PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH'}}
cmake -G Ninja -S Thunder -B ${{matrix.build_type}}/build/Thunder \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror -m${{matrix.architecture}}" \
-DCMAKE_C_FLAGS="-Wall -Wextra -Wpedantic -Werror -m${{matrix.architecture}}" \
Expand All @@ -117,6 +119,11 @@ jobs:
-DPROXYSTUB_PATH="${PWD}/${{matrix.build_type}}/install/usr/lib/wpeframework/proxystubs" \
-DSYSTEM_PATH="${PWD}/${{matrix.build_type}}/install/usr/lib/wpeframework/plugins" \
-DVOLATILE_PATH="tmp" \
-DBLUETOOTH_SUPPORT=ON \
-DBLUETOOTH=ON \
-DDOWNLOAD_BLUEZ_UTIL_HEADERS=ON \
-DBLUETOOTH_AUDIO_SUPPORT=ON \
-DBLUETOOTH_GATT_SUPPORT=ON \
-DLOCALTRACER=ON \
-DWARNING_REPORTING=ON \
-DPROCESSCONTAINERS=ON \
Expand Down
13 changes: 6 additions & 7 deletions Source/Thunder/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ namespace Plugin {
Core::hresult Controller::Delete(const string& path)
{
Core::hresult result = Core::ERROR_UNKNOWN_KEY;
bool valid;
string normalized_path = Core::File::Normalize(path, valid);

ASSERT(_service != nullptr);

if (valid == false) {
const string normalized_path = Core::File::Normalize(path, true /* safe paths only */);

if (normalized_path.empty() == true) {
result = Core::ERROR_PRIVILIGED_REQUEST;
}
else {
Expand Down Expand Up @@ -681,10 +681,9 @@ namespace Plugin {
remainder = index.Remainder().Text();
}

bool valid;
string normalized(Core::File::Normalize(remainder, valid));
const string normalized(Core::File::Normalize(remainder, true /* safe paths only */));

if (valid == false) {
if (normalized.empty() == true) {
result->Message = "incorrect path";
result->ErrorCode = Web::STATUS_BAD_REQUEST;
}
Expand Down Expand Up @@ -1236,7 +1235,7 @@ namespace Plugin {
data.Interface = proxy->InterfaceId();
data.Count = proxy->ReferenceCount();
data.Name = proxy->Name();

elements.emplace_back(std::move(data));
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Thunder/PluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ POP_WARNING()

for (const ProxyStub::UnknownProxy* proxy : proxies) {
Core::instance_id instanceId = proxy->Implementation();
printf("[%s] InstanceId: 0x%" PRIx64 ", RefCount: %d, InterfaceId %d [0x%X]\n", proxy->Name(), static_cast<uint64_t>(instanceId), proxy->ReferenceCount(), proxy->InterfaceId(), proxy->InterfaceId());
printf("[%s] InstanceId: 0x%" PRIx64 ", RefCount: %d, InterfaceId %d [0x%X]\n", proxy->Name().c_str(), static_cast<uint64_t>(instanceId), proxy->ReferenceCount(), proxy->InterfaceId(), proxy->InterfaceId());
}
printf("\n");
}
Expand Down
3 changes: 3 additions & 0 deletions Source/Thunder/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3726,6 +3726,9 @@ namespace PluginHost {
response->Message = _T("JSONRPC executed succesfully");
}
else {
#ifdef LEGACY_JSONRPCOVERHTTP_ERRORCODE
response->ErrorCode = Web::STATUS_ACCEPTED;
#endif
response->Message = _T("Failure on JSONRPC: ") + Core::NumberType<int32_t>(body->Error.Code).Text();
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/com/IUnknown.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ namespace ProxyStub {
, _parent(parent)
, _channel(channel)
, _remoteReferences(1)
, _name(&(name[7])) /* It always starts with "struct ", remove it...*/
, _name(name)
{
}
virtual ~UnknownProxy() = default;
Expand Down Expand Up @@ -402,8 +402,8 @@ namespace ProxyStub {

return (result);
}
inline const char* Name() const {
return (_name);
inline string Name() const {
return Core::ClassName(_name).Text();
}

private:
Expand Down
23 changes: 19 additions & 4 deletions Source/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,27 @@ endif()
if(BLUETOOTH_SUPPORT)
target_compile_definitions(${TARGET} PUBLIC __CORE_BLUETOOTH_SUPPORT__)

find_package(Bluez5UtilHeaders REQUIRED)
include(GetBluez5Headers)

target_link_libraries(${TARGET}
GetBluez5UtilHeadersFiles(Bluez5UtilHeadersFiles)

install(FILES ${Bluez5UtilHeadersFiles}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/core/bluez5 COMPONENT ${NAMESPACE}_Development)

GetBluez5IncludeDirs(Bluez5IncludeDirs)

foreach(path ${Bluez5IncludeDirs})
target_include_directories(${TARGET}
PUBLIC
Bluez5UtilHeaders::Bluez5UtilHeaders
)
$<BUILD_INTERFACE:${path}>)
endforeach()

CheckBluez5InclusiveLanguage(INCLUSIVE_LANGUAGE)

if(NOT ${INCLUSIVE_LANGUAGE})
#TODO: Remove NO_INCLUSIVE_LANGUAGE define when the plugins are synced to BLUEZ_HAS_NO_INCLUSIVE_LANGUAGE
target_compile_definitions(${TARGET} PUBLIC INTERFACE NO_INCLUSIVE_LANGUAGE BLUEZ_HAS_NO_INCLUSIVE_LANGUAGE)
endif()

message(STATUS "Enable bluetooth support.")
endif()
Expand Down
144 changes: 91 additions & 53 deletions Source/core/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,95 +72,133 @@ namespace Core {
Close();
}

/* static */ string File::Normalize(const string& location, bool& valid)
/* static */ string File::Normalize(const string& location, const bool inScopeOnly, const bool allowDirs)
{
string result(location);

valid = true;

// First see if we are not empy.
if (result.empty() == false) {
uint32_t index = 0;

while (index < result.length()) {
while (index < result.length()) {

#ifdef __WINDOWS__
if (result[index] == '\\') {
result[index] = '/';
}
#endif

if ((result[index] == '/') && (index >= 1) ) {
if ((result[index] == '/') && (index >= 1)) {
if (result[index - 1] == '/') {
if (index >= 2) {
// We have a double slash, clear all till the beginning
result = result.substr(index - 1);
index = 1;
}
// We have a double slash, trim it
result.erase(index, 1);
index--;
}
else if (result[index - 1] == '.') {
if ((index == 1) || (result[index - 2] == '/')) {
// It is a dot, remove it...
uint32_t offset = (index == 1 ? 0 : index - 2);
result.erase(offset, 2);
index = offset;
if (result.length() != 2) {
// It is a dot, remove it... but not if it's just ./
result.erase(index - (index == 1 ? 1 : 2), 2);
index -= 2;
}
}
else if ((result[index - 2] == '.') && ((index == 2) || (result[index - 3] == '/'))) {
if (index <= 3) {
valid = false;
if (index == 2) {
// We're going out of scope!
if (inScopeOnly == true) {
result.clear();
}
}
else if (index == 3) {
// Going up past / thus invalid
result.clear();
}
#ifdef __WINDOWS__
else if ((index == 5) && (result[1] == ':')) {
// Going up past X:/ thus invalid
result.clear();
}
#endif
else {
// Seems like we are moving up a directory... execute that on the result... if we can...
// there is data we can drop, drop it, drop it till the '/' is found
uint32_t offset = index - 4;
while ((offset > 0) && (result[offset] != '/')) {
offset--;
}
result.erase(offset, index - offset);
index = offset;

// ...but don't swallow another ..
if ((result[offset] != '.') && (result[offset + 1] != '.')) {
result.erase(offset + (result[offset] == '/' ? 1 : 0), index - offset + (result[offset] == '/' ? 0 : -1));
index = offset;
}
}
}
}
}
index++;
}

// It could be that the last slash is not part of the full line, check the last part, assuming there is such a slash,
// normalization rules applyt than as well....
if ((result.length() >= 1) && (result[result.length() - 1] == '.')) {

if (result.length() == 1) {
// We have only a dot...
result.clear();
}
else if ( (result.length() == 2) && (result[0] == '.') ) {
// We have a ".." and nothing more
valid = false;
result.clear();
}
else if ((result.length() >= 2) && (result[result.length() - 2] == '/')) {
result = result.substr(0, result.length() - 2);
}
else if ((result.length() >= 3) && (result[result.length() - 2] == '.') && (result[result.length() - 3] == '/')) {
// How about ThisFile/.., it is valid, but /.. would not be, both end up at an empty string... but the difference
// is the fact that the first, had a length > 3 and the second was exactly 3, so a length of 3 is invalid and empty..
if (result.length() == 3) {
valid = false;
result.clear();
}
else {
// there is data we can drop, drop it, drop it till the '/' is found
uint32_t offset = static_cast<uint32_t>(result.length() - 4);

while ((offset > 0) && (result[offset] != '/')) {
offset--;
}

// It could be that the last slash is not part of the full line, check the last part, assuming there is such a slash,
// normalization rules apply than as well....
if (result.length() >= 1) {
if (result[result.length() - 1] == '/') {
if (allowDirs == false) {
result.clear();
}
else if ((result.length() == 1) && (result[0] == '/') && (location[0] == '.')) {
// Correct corner case where .//// ends up as /
result = "./";
}
}
else if (result[result.length() - 1] == '.') {
if (allowDirs == false) {
result.clear();
}
else if ((result.length() >= 2) && (result[result.length() - 2] == '/')) {
// Ends with /.
result.erase(result.length() - 1, 1);
}
else if ((result.length() >= 3) && (result[result.length() - 2] == '.') && (result[result.length() - 3] == '/')) {
// How about ThisFile/.., it is valid, but /.. would not be, both end up at an empty string... but the difference
// is the fact that the first, had a length > 3 and the second was exactly 3, so a length of 3 is invalid and empty..
if (result.length() == 3) {
// Invalid /..
result.clear();
}
#ifdef __WINDOWS__
else if ((result.length() == 5) && (result[1] == ':')) {
// Invalid X:/..
result.clear();
}
#endif
else {
// there is data we can drop, drop it, drop it till the '/' is found
uint32_t offset = static_cast<uint32_t>(result.length() - 4);

while ((offset > 0) && (result[offset] != '/')) {
offset--;
}

// again do not swallow another ..
if ((result[offset] != '.') && (result[offset + 1] != '.')) {
result.erase(offset + (result[offset] == '/' ? 1 : 0));

if ((result.empty() == true) && (allowDirs == true)) {
// Collapsed everything, so insert current dir
result = "./";
}
}
}
result = result.substr(0, offset);
}
}
}
}
else {
// We have . or ..
result += '/';
}
}
}
}

return (result);
}

Expand Down
9 changes: 4 additions & 5 deletions Source/core/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ namespace Core {
return (*this);
}

static string Normalize(const string& input, bool& valid);
static string Normalize(const string& input, const bool inScopeOnly = false, const bool allowDirs = false);

public:
inline static string FileName(const string& name)
Expand Down Expand Up @@ -666,17 +666,16 @@ POP_WARNING()
~Directory();

public:
static string Normalize(const string& location)
static string Normalize(const string& location, const bool inScopeOnly = false)
{
string result;

// First see if we are not empy.
if (location.empty() == false) {

bool valid;
result = File::Normalize(location, valid);
result = File::Normalize(location, inScopeOnly, true /* accept directories */);

if ((valid == true) && ((result.empty() == true) || (result[result.length() - 1] != '/'))) {
if ((result.empty() == false) && (result[result.length() - 1] != '/')) {
result += '/';
}
}
Expand Down
8 changes: 5 additions & 3 deletions Source/core/NodeId.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
#endif

#ifdef __CORE_BLUETOOTH_SUPPORT__
#include <../include/bluetooth/bluetooth.h>
#include <../include/bluetooth/hci.h>
#include <../include/bluetooth/l2cap.h>
PUSH_WARNING(DISABLE_WARNING_PEDANTIC)
#include "bluez5/bluetooth.h"
#include "bluez5/hci.h"
#include "bluez5/l2cap.h"
POP_WARNING()
#else
#ifndef AF_BLUETOOTH
#define AF_BLUETOOTH 60000
Expand Down
Loading

0 comments on commit 8f15665

Please sign in to comment.