I hope this is a properly formatted patch file with a minimal fix for the
bug.
I also submitted this patch downstream on Ubuntu Launchpad
From 95c797cfaa16cd2bc5999a6e18b5c974fd686c7f Mon Sep 17 00:00:00 2001
From: "Joseph A. Oswald, III" <[email protected]>
Date: Sat, 27 Dec 2025 11:36:26 -0500
Subject: [PATCH] * crc/makecrc.c: use explictly sized uint16|32_t types.  
 Closes: #1123798   (LP: #2136046)

---
 debian/changelog                          |  8 +++
 debian/patches/makecrc-integer-size.patch | 82 +++++++++++++++++++++++
 debian/patches/series                     |  1 +
 3 files changed, 91 insertions(+)
 create mode 100644 debian/patches/makecrc-integer-size.patch

diff --git a/debian/changelog b/debian/changelog
index ffcf850..173a9d0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+macutils (2.0b3-17.1ubuntu1) UNRELEASED; urgency=medium
+
+  * crc/makecrc.c: use explictly sized uint16|32_t types.
+    Closes: #1123798
+    (LP: #2136046)
+
+ -- Joseph Oswald <[email protected]>  Sat, 27 Dec 2025 11:33:58 -0500
+
 macutils (2.0b3-17.1) unstable; urgency=medium
 
   * Non-maintainer upload.
diff --git a/debian/patches/makecrc-integer-size.patch b/debian/patches/makecrc-integer-size.patch
new file mode 100644
index 0000000..c991cac
--- /dev/null
+++ b/debian/patches/makecrc-integer-size.patch
@@ -0,0 +1,82 @@
+From: "Joseph A. Oswald, III" <[email protected]>
+Date: Sat, 27 Dec 2025 11:22:39 -0500
+Subject: * crc/makecrc.c: use explictly sized uint16|32_t types. Closes:
+ #1123798 (LP: #2136046)
+
+---
+ crc/makecrc.c | 28 ++++++++++++++++++++--------
+ 1 file changed, 20 insertions(+), 8 deletions(-)
+
+diff --git a/crc/makecrc.c b/crc/makecrc.c
+index f4621bb..eecbef1 100755
+--- a/crc/makecrc.c
++++ b/crc/makecrc.c
+@@ -34,6 +34,7 @@
+ #include <string.h>
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <stdint.h>
+ 
+ static void initcrctab();
+ 
+@@ -54,8 +55,8 @@ char *name;
+ int poly, init, swapped, bits;
+ {
+     register  int b, i;
+-    unsigned short v;
+-    unsigned long vv;
++    uint16_t v;
++    uint32_t vv;
+     FILE *fd;
+     char buf[20];
+     
+@@ -66,12 +67,17 @@ int poly, init, swapped, bits;
+ 	(void)fprintf(stderr, "Cannot open %s for writing\n", buf);
+ 	exit(1);
+     }
+-    (void)fprintf(fd, "unsigned long %s_crcinit = %d;\n", name, init);
++    (void)fprintf(fd, "#include <stdint.h>\n\n");
++    if (bits == 16) {
++      (void)fprintf(fd, "uint16_t %s_crcinit = %d;\n", name, init);
++    } else {
++      (void)fprintf(fd, "uint32_t %s_crcinit = %d;\n", name, init);
++    }
+     (void)fprintf(fd, "\n");
+     if(bits == 16) {
+-	(void)fprintf(fd, "static unsigned short crctab[256] = {\n");
++	(void)fprintf(fd, "static uint16_t crctab[256] = {\n");
+     } else {
+-	(void)fprintf(fd, "static unsigned long crctab[256] = {\n");
++	(void)fprintf(fd, "static uint32_t crctab[256] = {\n");
+     }
+     (void)fprintf(fd, "    ");
+     if(bits == 16) {
+@@ -111,19 +117,25 @@ int poly, init, swapped, bits;
+     }
+     (void)fprintf(fd, "};\n");
+     (void)fprintf(fd, "\n");
+-    (void)fprintf(fd, "unsigned long %s_updcrc(icrc, icp, icnt)\n", name);
+-    (void)fprintf(fd, "    unsigned long icrc;\n");
++    if (bits == 16) {
++      (void)fprintf(fd, "uint16_t %s_updcrc(icrc, icp, icnt)\n", name);
++      (void)fprintf(fd, "    uint16_t icrc;\n");
++    } else {
++      (void)fprintf(fd, "uint32_t %s_updcrc(icrc, icp, icnt)\n", name);
++      (void)fprintf(fd, "    uint32_t icrc;\n");
++    }
+     (void)fprintf(fd, "    unsigned char *icp;\n");
+     (void)fprintf(fd, "    int icnt;\n");
+     (void)fprintf(fd, "{\n");
+     if(bits == 16) {
+ 	(void)fprintf(fd, "#define M1 0xff\n");
+ 	(void)fprintf(fd, "#define M2 0xff00\n");
++	(void)fprintf(fd, "    register uint16_t crc = icrc;\n");
+     } else {
+ 	(void)fprintf(fd, "#define M1 0xffffff\n");
+ 	(void)fprintf(fd, "#define M2 0xffffff00\n");
++	(void)fprintf(fd, "    register uint32_t crc = icrc;\n");
+     }
+-    (void)fprintf(fd, "    register unsigned long crc = icrc;\n");
+     (void)fprintf(fd, "    register unsigned char *cp = icp;\n");
+     (void)fprintf(fd, "    register int cnt = icnt;\n");
+     (void)fprintf(fd, "\n");
diff --git a/debian/patches/series b/debian/patches/series
index 6bca343..5b2b12f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 debian-changes-2.0b3-16
 warnings-2.0b3-17.diff
 gcc-15.patch
+makecrc-integer-size.patch
-- 
2.43.0

Reply via email to