user debian-rele...@lists.debian.org
usertags 997184 + bsp-2022-10-de-karlsruhe
tags 997184 + patch
thank you

Hi,

the attached patch fixes the build errors caused by the new
GCC version.

Kind regards,
  Reiner
From 8525b3f41ef3acf2130167cc0072c38452253cc0 Mon Sep 17 00:00:00 2001
From: Reiner Herrmann <rei...@reiner-h.de>
Date: Sun, 16 Oct 2022 19:32:38 +0200
Subject: [PATCH] Fix FTBFS with GCC 12

Closes: #997184
---
 debian/patches/gcc12.patch | 246 +++++++++++++++++++++++++++++++++++++
 debian/patches/series      |   1 +
 2 files changed, 247 insertions(+)
 create mode 100644 debian/patches/gcc12.patch

diff --git a/debian/patches/gcc12.patch b/debian/patches/gcc12.patch
new file mode 100644
index 0000000..540c788
--- /dev/null
+++ b/debian/patches/gcc12.patch
@@ -0,0 +1,246 @@
+Author: Reiner Herrmann <rei...@reiner-h.de>
+Bug-Debian: https://bugs.debian.org/997184
+Description: Fix FTBFS with GCC 12
+ - make sure global variables are declared in only one place
+   to fix "multiple definition" linking errors
+ - use fixed format string to prevent format string vulnerabilities
+
+--- a/src/hexedit.h
++++ b/src/hexedit.h
+@@ -343,7 +343,7 @@
+ 
+ 
+    /* Global structure, keep most global variables here. */
+-struct
++struct Global
+ {
+    WINDOW *wmain, *wstatus, *whelp; /* three windows used throughout. */
+    unsigned long filesize;          /* size of the file buffer. */
+@@ -365,7 +365,7 @@
+                                     /* buf end. */
+    int beeping;                     /* Allow beeping or not. */
+    int help_msg_count;              /* Number of messages in help menu. */
+-} Globals;
++};
+ 
+ 
+ struct foundit
+@@ -400,7 +400,7 @@
+    int s;
+    struct Change *base;
+    struct Change *top;
+-} UndoStack;
++};
+ 
+ 
+ struct FileNames
+--- a/src/init.c
++++ b/src/init.c
+@@ -35,6 +35,9 @@
+ 
+ extern char **environ;
+ 
++struct Global Globals;
++extern struct ChangeLog UndoStack;
++
+ 
+    /* This is called once at the start of the program.  Handles HEXEDIT
+     * Environment variable, command line arguments, sets up signal
+@@ -385,7 +388,7 @@
+          box (wpopup, 0, 0);
+          wmove (wpopup, 1, (FILE_ERR_WIDTH / 2)
+                  - (strlen (msg) / 2));
+-         wprintw (wpopup, (char *) msg);
++         wprintw (wpopup, "%s", (char *) msg);
+          wmove (wpopup, FILE_ERR_HEIGHT - 3, (FILE_ERR_WIDTH / 2) -
+                 (strlen (strerror (errno)) + strlen ("Reason: ")) / 2);
+          wprintw (wpopup, "Reason: %s", 
+--- a/src/misc.c
++++ b/src/misc.c
+@@ -26,6 +26,8 @@
+ #endif
+ #endif
+ 
++extern struct Global Globals;
++extern struct ChangeLog UndoStack;
+ 
+ int
+ mappos (int pos)
+--- a/src/undo.c
++++ b/src/undo.c
+@@ -15,6 +15,8 @@
+ #include "hexedit.h"
+ #include <assert.h>
+ 
++struct ChangeLog UndoStack;
++extern struct Global Globals;
+ 
+ void
+ pushUndo (int type, unsigned long offset,
+--- a/src/widgets.c
++++ b/src/widgets.c
+@@ -14,6 +14,8 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
++
+ #define S_BOX_COLOR  (COLOR_PAIR(4) | A_BOLD)
+ 
+ 
+@@ -366,7 +368,7 @@
+    if (!rstr.str)
+    {
+       wmove (win, 4, boxleft);
+-      wprintw (win, (char *) NOT_ENOUGH_MEMORY);
++      wprintw (win, "%s", (char *) NOT_ENOUGH_MEMORY);
+       getch ();
+       return NULL;
+    }
+--- a/src/windows.c
++++ b/src/windows.c
+@@ -14,6 +14,7 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
+ 
+    /* Brings up Jump to offset window, to relocate to a different part
+     * of the file.  Uses one string box and takes input in octal, decimal, 
+--- a/src/calc.c
++++ b/src/calc.c
+@@ -14,6 +14,8 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
++
+    /* Used only for redraw function after Control-C */
+ struct calcEntryBox *bbox;
+ struct calcEntryBox *obox;
+--- a/src/print.c
++++ b/src/print.c
+@@ -14,6 +14,8 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
++
+ static long findNewline   (unsigned long);
+ static void drawAscii     (unsigned long off);
+ static void drawAsciiDump (unsigned long, unsigned long *);
+--- a/src/calckeys.c
++++ b/src/calckeys.c
+@@ -14,6 +14,7 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
+ 
+ void
+ calcNumberKey (struct calcEntryBox *binbox, struct calcEntryBox *octbox,
+--- a/src/edit.c
++++ b/src/edit.c
+@@ -15,6 +15,8 @@
+ #include "hexedit.h"
+ #include <assert.h>
+ 
++extern struct Global Globals;
++
+ /* The routines in this file are very messy and ugly and not much thought
+  * went into thinking how to minimize the amount of code, I only did it
+  * real fast, making every case I could think of a separate code block,
+--- a/src/file.c
++++ b/src/file.c
+@@ -30,6 +30,8 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
++
+ struct FileNames *fp = NULL;     /* used to traverse the list of files */
+ struct FileNames **pages = NULL; /* node that starts a new page */
+ int current_page = 0;
+--- a/src/filebuf.c
++++ b/src/filebuf.c
+@@ -15,6 +15,7 @@
+ #include "hexedit.h"
+ #include <assert.h>
+ 
++extern struct Global Globals;
+ 
+ void
+ initbuffer (FILE *filep, unsigned long front, unsigned long end)
+--- a/src/filekeys.c
++++ b/src/filekeys.c
+@@ -14,6 +14,8 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
++
+ #define NAME_POS 57   /* Magic number of where filename always starts */
+ 
+ extern struct FileNames *fp;
+--- a/src/hash.c
++++ b/src/hash.c
+@@ -24,6 +24,7 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
+ 
+    /* All the books say this should usually be a prime number */
+ #define HASH_TABLE_SIZE   1009
+--- a/src/help.c
++++ b/src/help.c
+@@ -13,6 +13,8 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
++
+    /* we need to modify these two strings to display the correct message,
+     * how to insert/delete if enabled, or how to enable it.
+     */
+--- a/src/hexkeys.c
++++ b/src/hexkeys.c
+@@ -14,6 +14,7 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
+ 
+ void
+ hexMode (wchar_t in)
+--- a/src/main.c
++++ b/src/main.c
+@@ -16,6 +16,7 @@
+ #include "hexedit.h"
+ #include <assert.h>
+ 
++extern struct Global Globals;
+ 
+ int
+ main (int argc, char **argv)
+--- a/src/search.c
++++ b/src/search.c
+@@ -14,6 +14,8 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
++
+ static unsigned char curr;
+ 
+ 
+--- a/src/asciikey.c
++++ b/src/asciikey.c
+@@ -13,6 +13,7 @@
+ 
+ #include "hexedit.h"
+ 
++extern struct Global Globals;
+ 
+ void
+ asciiMode (wchar_t in)
diff --git a/debian/patches/series b/debian/patches/series
index 478f137..e1af50e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -16,3 +16,4 @@ quit_immediately_if_unmodified.patch
 enforce_readonly_mode.patch
 fix_buffer_overruns.patch
 fix_spelling_errors.patch
+gcc12.patch
-- 
2.37.2

Attachment: signature.asc
Description: PGP signature

Reply via email to