mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Try to capture some more potential buffer overflows caused by localization
A couple of these could clearly cause a crash just like the one fixed by commit 00865f5a1e1a ("equipment.c: Fix potential buffer overflow in size_data_funct()"). One would append user input to fixed length buffer without checking. We were hardcoding the (correct) max path length in macos.c - replaced by the actual OS constant. But the vast majority are just extremely generous guesses how long localized strings could possibly be. Yes, this commit is likely leaning towards overkill. But we have now been bitten by buffer overflow crashes twice that were caused by localization, so I tried to go through all of the code and identify every possible buffer that could be affected by this. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
93eeb03d67
commit
0129192958
13 changed files with 31 additions and 30 deletions
11
macos.c
11
macos.c
|
@ -7,6 +7,7 @@
|
|||
#include <CoreServices/CoreServices.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include "gtkosxapplication.h"
|
||||
#include <sys/syslimits.h>
|
||||
|
||||
static GtkosxApplication *osx_app;
|
||||
|
||||
|
@ -148,9 +149,9 @@ int subsurface_fill_device_list(GtkListStore *store)
|
|||
|
||||
const char *subsurface_icon_name()
|
||||
{
|
||||
static char path[1024];
|
||||
static char path[PATH_MAX];
|
||||
|
||||
snprintf(path, 1024, "%s/%s", gtkosx_application_get_resource_path(), ICON_NAME);
|
||||
snprintf(path, sizeof(path), "%s/%s", gtkosx_application_get_resource_path(), ICON_NAME);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
@ -173,7 +174,7 @@ const char *subsurface_gettext_domainpath(char *argv0)
|
|||
{
|
||||
/* on a Mac we ignore the argv0 argument and instead use the resource_path
|
||||
* to figure out where to find the translation files */
|
||||
static char buffer[256];
|
||||
static char buffer[PATH_MAX];
|
||||
const char *resource_path = gtkosx_application_get_resource_path();
|
||||
if (resource_path) {
|
||||
snprintf(buffer, sizeof(buffer), "%s/share/locale", resource_path);
|
||||
|
@ -192,9 +193,9 @@ void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,
|
|||
GtkWidget *vbox, GtkUIManager *ui_manager)
|
||||
{
|
||||
GtkWidget *menu_item, *sep;
|
||||
static char path[1024];
|
||||
static char path[PATH_MAX];
|
||||
|
||||
snprintf(path, 1024, "%s/xslt", gtkosx_application_get_resource_path());
|
||||
snprintf(path, sizeof(path), "%s/xslt", gtkosx_application_get_resource_path());
|
||||
setenv("SUBSURFACE_XSLT_PATH", path, TRUE);
|
||||
|
||||
g_object_set(G_OBJECT(settings), "gtk-font-name", UI_FONT, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue