Skip to content

Commit

Permalink
Fix buffer overflow bugs when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksiy-Yakovenko committed Sep 7, 2024
1 parent 0e75342 commit 3d0460b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions Tests/AlbumNavigationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class AlbumNavigationTests : public ::testing::Test {
messagepump_free ();
conf_free ();
ddb_logger_free ();
plug_remove_plugin((DB_plugin_t *)_fakeout);
}
playlist_t *plt;
int srs[128];
Expand Down
2 changes: 1 addition & 1 deletion Tests/PlaylistTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ TEST(PlaylistTests, test_SearchFor2ndValueInMultiValueItems_FindsTheItem) {
plt_unref (plt);
}

using ::testing::StartsWith;
TEST (PlaylistTests, test_LoadDBPLWithRelativepaths) {
using ::testing::StartsWith;
ddb_playlist_t *plt = deadbeef->plt_alloc ("test");

char dname[PATH_MAX];
Expand Down
1 change: 1 addition & 0 deletions Tests/StreamerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class StreamerTests: public ::testing::Test {
streamer_free ();
conf_free();
ddb_logger_free();
plug_remove_plugin((DB_plugin_t *)_fakeout);
}

protected:
Expand Down
1 change: 1 addition & 0 deletions Tests/TrackSwitchingTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class TrackSwitchingTests: public ::testing::Test {
messagepump_free();
conf_free();
ddb_logger_free();
plug_remove_plugin((DB_plugin_t *)_fakeout);
}
DB_output_t *_fakeout;
uintptr_t _mainloop_tid;
Expand Down
2 changes: 2 additions & 0 deletions osx/deadbeef.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22930,6 +22930,7 @@
"$(inherited)",
"$(SRCROOT)/deps/jansson-2.13.1/src",
"$(SRCROOT)/../external/googletest/googletest/include",
"$(SRCROOT)/../external/googletest/googlemock/include",
"\"$(SRCROOT)/../include\"",
"\"$(SRCROOT)/..\"",
"\"$(SRCROOT)/../shared\"",
Expand Down Expand Up @@ -22977,6 +22978,7 @@
"$(inherited)",
"$(SRCROOT)/deps/jansson-2.13.1/src",
"$(SRCROOT)/../external/googletest/googletest/include",
"$(SRCROOT)/../external/googletest/googlemock/include",
"\"$(SRCROOT)/../include\"",
"\"$(SRCROOT)/..\"",
"\"$(SRCROOT)/../shared\"",
Expand Down
4 changes: 4 additions & 0 deletions src/plugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1883,10 +1883,12 @@ void
plug_register_in (DB_plugin_t *inplug) {
int i;
for (i = 0; g_plugins[i]; i++);
assert(i < MAX_PLUGINS);
g_plugins[i++] = inplug;
g_plugins[i] = NULL;

for (i = 0; g_decoder_plugins[i]; i++);
assert(i < MAX_DECODER_PLUGINS);
g_decoder_plugins[i++] = (DB_decoder_t *)inplug;
g_decoder_plugins[i] = NULL;
}
Expand All @@ -1896,10 +1898,12 @@ void
plug_register_out (DB_plugin_t *outplug) {
int i;
for (i = 0; g_plugins[i]; i++);
assert(i < MAX_PLUGINS);
g_plugins[i++] = outplug;
g_plugins[i] = NULL;

for (i = 0; g_output_plugins[i]; i++);
assert(i < MAX_OUTPUT_PLUGINS);
g_output_plugins[i++] = (DB_output_t *)outplug;
g_output_plugins[i] = NULL;
}
Expand Down
3 changes: 3 additions & 0 deletions src/plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ plug_init_plugin (DB_plugin_t* (*loadfunc)(DB_functions_t *), void *handle);
const char *
plug_get_path_for_plugin_ptr (DB_plugin_t *plugin_ptr);

void
plug_remove_plugin (void *p);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 3d0460b

Please sign in to comment.