sane-backends: fix compilation with GCC14
authorRosen Penev <rosenp@gmail.com>
Tue, 28 May 2024 21:32:31 +0000 (14:32 -0700)
committerRosen Penev <rosenp@gmail.com>
Tue, 4 Jun 2024 21:15:08 +0000 (14:15 -0700)
Upstream backport.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
utils/sane-backends/Makefile
utils/sane-backends/patches/010-basename.patch [new file with mode: 0644]

index 67f035eb0af888f1a9d0277415bcc5485b3ee163..49710598bd278abf4c9b14d139bcb57209f02de4 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=sane-backends
 PKG_VERSION:=1.0.32
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://gitlab.com/sane-project/backends/uploads/104f09c07d35519cc8e72e604f11643f
diff --git a/utils/sane-backends/patches/010-basename.patch b/utils/sane-backends/patches/010-basename.patch
new file mode 100644 (file)
index 0000000..f67f94b
--- /dev/null
@@ -0,0 +1,48 @@
+From 373dceaa36039977db43e5864759f3b080e92d2c Mon Sep 17 00:00:00 2001
+From: Ralph Little <skelband@gmail.com>
+Date: Mon, 13 Feb 2023 12:32:35 -0800
+Subject: [PATCH] scanimage: more generic fix for selecting a common basename
+ function.
+
+We have been specially including libgen.h to get a version in other
+platforms such as macOS and FreeBSD. However, it is dangerous to
+make assumptions about which version of basename that we will get.
+So this change reverts to asking for the version that modifies the
+argument and creates a copy of the arg that we *can* modify.
+---
+ frontend/scanimage.c | 24 +++++++++++++++---------
+ 1 file changed, 15 insertions(+), 9 deletions(-)
+
+--- a/frontend/scanimage.c
++++ b/frontend/scanimage.c
+@@ -39,6 +39,7 @@
+ #include <string.h>
+ #include <unistd.h>
+ #include <stdarg.h>
++#include <libgen.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+@@ -1237,7 +1238,21 @@ write_png_header (SANE_Frame format, int
+         if ((is_gray_profile && color_type == PNG_COLOR_TYPE_GRAY) ||
+             (is_rgb_profile && color_type == PNG_COLOR_TYPE_RGB))
+           {
+-            png_set_iCCP(*png_ptr, *info_ptr, basename(icc_profile), PNG_COMPRESSION_TYPE_BASE, icc_buffer, icc_size);
++            char *icc_profile_cp = strdup(icc_profile);
++            if (icc_profile_cp == NULL)
++              {
++                  fprintf(stderr, "Memory allocation failure prevented the setting of PNG ICC profile.\n");
++              }
++            else
++              {
++                  png_set_iCCP (*png_ptr,
++                                *info_ptr,
++                                basename (icc_profile_cp),
++                                PNG_COMPRESSION_TYPE_BASE,
++                                icc_buffer,
++                                icc_size);
++                  free(icc_profile_cp);
++              }
+           }
+         else
+           {