Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

598 sanitizr address #599

Merged
merged 10 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,29 @@ jobs:
# # ${PWD}/artifacts on the host.
# run: |
# ls -al "${PWD}/artifacts"

build-santize-address:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: apt install
run: >-
sudo apt update &&
sudo apt install libunwind-dev &&
sudo apt install -y ${{ env.DEB_PKGS }} ${{ env.DEB_TEST_PKGS }}
- name: meson
run: |
meson --version
meson setup build -Dsanitize-address=true
env:
CXX: g++
- name: build
run: ninja -v -C build
- name: install
run: sudo meson install -C build
- name: test
run: |
if ! xvfb-run -a meson test -C build --verbose --no-stdsplit; then
echo "::warning title=test-failed::test failed"
fi
continue-on-error: true
5 changes: 5 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ project('iptux', 'cpp',
version: '0.9.1',
default_options: ['warning_level=3', 'cpp_std=c++14'])
add_global_arguments('-Werror=format', language : 'cpp')
if get_option('sanitize-address')
add_project_arguments('-fsanitize=address', language: 'cpp')
add_project_link_arguments('-fsanitize=address', language: 'cpp')
endif

so_version = '0.9.1'
subdir('src')
subdir('share')
Expand Down
7 changes: 7 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ option(
value: 'auto',
description: 'enable app indicator support',
)

option(
'sanitize-address',
type: 'boolean',
value: 'false',
description: 'enable -fsanitize=address compile/link flag',
)
10 changes: 6 additions & 4 deletions src/iptux-core/internal/UdpDataServiceTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "gtest/gtest.h"

#include <memory>

#include "iptux-core/TestHelper.h"
#include "iptux-core/internal/UdpDataService.h"
#include "iptux-utils/utils.h"
Expand All @@ -9,13 +11,13 @@ using namespace iptux;

TEST(UdpDataService, process) {
auto core = newCoreThread();
auto service = new UdpDataService(*core.get());
auto service = make_unique<UdpDataService>(*core.get());
service->process(inAddrFromString("127.0.0.1"), 1234, "", 0, true);
}

TEST(UdpDataService, SomeoneEntry) {
auto core = newCoreThread();
auto service = new UdpDataService(*core.get());
auto service = make_unique<UdpDataService>(*core.get());
const char* data = "iptux 0.8.0:1:lidaobing:lidaobing.lan:257:lidaobing";
service->process(inAddrFromString("127.0.0.1"), 1234, data, strlen(data),
true);
Expand All @@ -28,7 +30,7 @@ TEST(UdpDataService, CreatePalInfo) {
"1_iptux "
"0.8.0-b1:6:lidaobing:LIs-MacBook-Pro.local:259:中\xe4\xb8\x00\x00icon-"
"tux.png\x00utf-8\x00";
auto service = new UdpDataService(*core.get());
auto service = make_unique<UdpDataService>(*core.get());
auto udp = service->process(inAddrFromString("127.0.0.1"), 1234, data,
strlen(data), false);
auto pal = udp->CreatePalInfo();
Expand All @@ -43,7 +45,7 @@ TEST(UdpDataService, CreatePalInfo) {
"1_iptux "
"0.8.0-b1:6:中\xe4\xb8:LIs-MacBook-Pro.local:259:"
"中\xe4\xb8\x00\x00icon-tux.png\x00utf-8\x00";
auto service = new UdpDataService(*core.get());
auto service = make_unique<UdpDataService>(*core.get());
auto udp = service->process(inAddrFromString("127.0.0.1"), 1234, data,
strlen(data), false);
auto pal = udp->CreatePalInfo();
Expand Down
31 changes: 16 additions & 15 deletions src/iptux/DataSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,23 +794,24 @@
snprintf(path, MAX_PATHLEN, "%d", active);
gtk_tree_model_get_iter_from_string(model, &iter, path);
gtk_tree_model_get(model, &iter, 1, &file, -1);
if (strcmp(g_progdt->myicon.c_str(), file) != 0) {
snprintf(path, MAX_PATHLEN, __PIXMAPS_PATH "/icon/%s", file);
if (access(path, F_OK) != 0) {
g_free(file);
g_progdt->myicon = "my-icon";
snprintf(path, MAX_PATHLEN, "%s" ICON_PATH "/my-icon",
g_get_user_config_dir());
gtk_tree_model_get(model, &iter, 0, &pixbuf, -1);
gdk_pixbuf_save(pixbuf, path, "png", NULL, NULL);
gtk_icon_theme_add_builtin_icon(g_progdt->myicon.c_str(), MAX_ICONSIZE,
pixbuf);
g_object_unref(pixbuf);
} else {
g_progdt->myicon = file;
if (file) {
if (strcmp(g_progdt->myicon.c_str(), file) != 0) {
snprintf(path, MAX_PATHLEN, __PIXMAPS_PATH "/icon/%s", file);
if (access(path, F_OK) != 0) {
g_progdt->myicon = "my-icon";
snprintf(path, MAX_PATHLEN, "%s" ICON_PATH "/my-icon",

Check warning on line 802 in src/iptux/DataSettings.cpp

View check run for this annotation

Codecov / codecov/patch

src/iptux/DataSettings.cpp#L799-L802

Added lines #L799 - L802 were not covered by tests
g_get_user_config_dir());
gtk_tree_model_get(model, &iter, 0, &pixbuf, -1);
gdk_pixbuf_save(pixbuf, path, "png", NULL, NULL);
gtk_icon_theme_add_builtin_icon(g_progdt->myicon.c_str(),

Check warning on line 806 in src/iptux/DataSettings.cpp

View check run for this annotation

Codecov / codecov/patch

src/iptux/DataSettings.cpp#L804-L806

Added lines #L804 - L806 were not covered by tests
MAX_ICONSIZE, pixbuf);
g_object_unref(pixbuf);

Check warning on line 808 in src/iptux/DataSettings.cpp

View check run for this annotation

Codecov / codecov/patch

src/iptux/DataSettings.cpp#L808

Added line #L808 was not covered by tests
} else {
g_progdt->myicon = file;

Check warning on line 810 in src/iptux/DataSettings.cpp

View check run for this annotation

Codecov / codecov/patch

src/iptux/DataSettings.cpp#L810

Added line #L810 was not covered by tests
}
}
} else
g_free(file);
}
}

widget = GTK_WIDGET(g_datalist_get_data(&widset, "archive-chooser-widget"));
Expand Down
Loading