summaryrefslogtreecommitdiff
path: root/egg
diff options
context:
space:
mode:
authorCorentin Noël <corentin.noel@collabora.com>2022-05-30 23:52:41 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2022-06-05 07:33:19 +0000
commitb6a26c64394f924c2766f57a9218213ad9bf1d70 (patch)
tree3d364b527ca1dab07e6b05f78682601200a428ad /egg
parent46da8a9ad06e8c903944cbe09a55b06b5ea891db (diff)
downloadgcr-b6a26c64394f924c2766f57a9218213ad9bf1d70.tar.gz
secure-memory: Fix odr-violation by using a private settertintou/fix-ci
Diffstat (limited to 'egg')
-rw-r--r--egg/egg-secure-memory-private.h27
-rw-r--r--egg/egg-secure-memory.c9
-rw-r--r--egg/test-secmem.c8
3 files changed, 38 insertions, 6 deletions
diff --git a/egg/egg-secure-memory-private.h b/egg/egg-secure-memory-private.h
new file mode 100644
index 0000000..7be32cc
--- /dev/null
+++ b/egg/egg-secure-memory-private.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2022 Collabora Ltd. (https://collabora.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Corentin Noël <corentin.noel@collabora.com>
+ */
+
+#ifndef EGG_SECURE_MEMORY_PRIVATE_H
+#define EGG_SECURE_MEMORY_PRIVATE_H
+
+#include <stdlib.h>
+
+void egg_set_secure_warnings (int val);
+
+#endif /* EGG_SECURE_MEMORY_PRIVATE_H */
diff --git a/egg/egg-secure-memory.c b/egg/egg-secure-memory.c
index bcc067e..c244010 100644
--- a/egg/egg-secure-memory.c
+++ b/egg/egg-secure-memory.c
@@ -71,7 +71,7 @@
EGG_SECURE_GLOBALS.unlock ();
static int show_warning = 1;
-int egg_secure_warnings = 1;
+static int egg_secure_warnings = 1;
/*
* We allocate all memory in units of sizeof(void*). This
@@ -1383,3 +1383,10 @@ egg_secure_strfree (char *str)
egg_secure_strclear (str);
egg_secure_free_full (str, EGG_SECURE_USE_FALLBACK);
}
+
+void
+egg_set_secure_warnings (int val)
+{
+ egg_secure_warnings = val;
+}
+
diff --git a/egg/test-secmem.c b/egg/test-secmem.c
index 8a63983..5fc0d1b 100644
--- a/egg/test-secmem.c
+++ b/egg/test-secmem.c
@@ -23,6 +23,7 @@
#include "config.h"
#include "egg/egg-secure-memory.h"
+#include "egg/egg-secure-memory-private.h"
#include <glib.h>
@@ -33,9 +34,6 @@
EGG_SECURE_DEFINE_GLIB_GLOBALS ();
-/* Declared in egg-secure-memory.c */
-extern int egg_secure_warnings;
-
EGG_SECURE_DECLARE (tests);
/*
@@ -163,7 +161,7 @@ test_multialloc (void)
memory = g_ptr_array_new ();
/* Don't print "can't allocate" warnings */
- egg_secure_warnings = 0;
+ egg_set_secure_warnings (0);
for (i = 0; TRUE; ++i) {
@@ -216,7 +214,7 @@ test_multialloc (void)
egg_secure_free (memory->pdata[i]);
g_ptr_array_free (memory, TRUE);
- egg_secure_warnings = 1;
+ egg_set_secure_warnings (1);
}
static void