Skip to contentSkip to conversation

enca: Fix cross builds

PATCH New Anuj Mittal 1 participant 8 messages Sep 24, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/8 enca: Fix cross builds

From: Khem Raj <[email protected]>

Some portions are built using host CC, which
is important when doing cross compile to pass correct flags otherwise it fails when using newer host compiler e.g. gcc-14

(cherry picked from commit 32eb26264323888e77154c2aeadc9994a4a54d5d)
---
 meta-oe/recipes-support/enca/enca/cross.patch | 68 +++++++++++++++++++
 .../enca/enca/makefile-remove-tools.patch     | 14 ----
 meta-oe/recipes-support/enca/enca_1.19.bb     | 24 ++-----
 3 files changed, 73 insertions(+), 33 deletions(-)
 create mode 100644 meta-oe/recipes-support/enca/enca/cross.patch
 delete mode 100644 meta-oe/recipes-support/enca/enca/makefile-remove-tools.patch
meta-oe/recipes-support/enca/enca/cross.patch new file +68 -0
new file mode 100644
index 0000000000..7749dee088
@@ -0,0 +1,68 @@
+From: Helmut Grohne <[email protected]>
+Subject: build make_hash with the build arch compiler
+
+Also note that we cannot include config.h in make_hash.c, because it is
+specific to the host architecture.
+
+Sourced from debian - https://salsa.debian.org/debian/enca/-/blob/master/debian/patches/cross.patch?ref_type=heads
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+
+Index: enca-1.19/configure.ac
+===================================================================
+--- enca-1.19.orig/configure.ac
++++ enca-1.19/configure.ac
+@@ -35,6 +35,7 @@
+ dnl Checks for programs.
+ AC_PROG_AWK
+ AC_PROG_CC
++AX_PROG_CC_FOR_BUILD
+ AC_GNU_SOURCE
+ AC_AIX
+ AC_ISC_POSIX
+Index: enca-1.19/tools/Makefile.am
+===================================================================
+--- enca-1.19.orig/tools/Makefile.am
++++ enca-1.19/tools/Makefile.am
+@@ -2,7 +2,8 @@
+ noinst_HEADERS = encodings.h
+ noinst_SCRIPTS = expand_table.pl
+ 
+-make_hash_SOURCES = make_hash.c
++make_hash$(EXEEXT): make_hash.c
++	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o $@ $<
+ 
+ BUILT_SOURCES = $(noinst_HEADERS)
+ 
+Index: enca-1.19/tools/make_hash.c
+===================================================================
+--- enca-1.19.orig/tools/make_hash.c
++++ enca-1.19/tools/make_hash.c
+@@ -17,25 +17,9 @@
+   with this program; if not, write to the Free Software Foundation, Inc.,
+   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+-#ifdef HAVE_CONFIG_H
+-#  include "config.h"
+-#endif /* HAVE_CONFIG_H */
+-
+ #include <stdlib.h>
+ #include <stdio.h>
+-
+-#ifdef HAVE_STRING_H
+-#  include <string.h>
+-#else /* HAVE_STRING_H */
+-#  ifdef HAVE_STRINGS_H
+-#    include <strings.h>
+-#  endif /* HAVE_STRINGS_H */
+-#endif /* HAVE_STRING_H */
+-
+-#ifdef HAVE_MEMORY_H
+-#  include <memory.h>
+-#endif /* HAVE_MEMORY_H */
+-
++#include <string.h>
+ #include <unistd.h>
+ #include <ctype.h>
+ 
meta-oe/recipes-support/enca/enca/makefile-remove-tools.patch deleted +0 -14
deleted file mode 100644
index 756745d839..0000000000
@@ -1,14 +0,0 @@
-Upstream-Status: Pending
-
---- enca-1.19/Makefile.am.orig	2006-06-29 15:34:55.000000000 +0100
-+++ enca-1.19/Makefile.am	2006-06-29 15:35:20.000000000 +0100
-@@ -1,7 +1,7 @@
- if MAINTAINER_MODE
--SUBDIRS = tools data script lib src devel-docs test
-+SUBDIRS = data script lib src devel-docs test
- else
--SUBDIRS = tools script lib src devel-docs
-+SUBDIRS = script lib src devel-docs
- endif
- man_MANS = man/enca.1
- 
meta-oe/recipes-support/enca/enca_1.19.bb +5 -19
index 774f05f7c4..61da50ba52 100644
@@ -2,33 +2,19 @@ SUMMARY = "Enca is an Extremely Naive Charset Analyser"
 SECTION = "libs"
 HOMEPAGE = "https://cihar.com/software/enca/"
 
-DEPENDS += "gettext-native"
+DEPENDS += "gettext-native autoconf-archive-native"
 
 LICENSE = "GPL-2.0-only"
 LIC_FILES_CHKSUM = "file://COPYING;md5=24b9569831c46d4818450b55282476b4"
 
 SRC_URI = "https://dl.cihar.com/enca/enca-${PV}.tar.gz \
+    file://cross.patch \
     file://dont-run-tests.patch \
-    file://makefile-remove-tools.patch \
     file://libenca-003-iconv.patch \
-    file://0001-Do-not-use-MKTEMP_PROG-in-cross-build.patch"
+    file://0001-Do-not-use-MKTEMP_PROG-in-cross-build.patch \
+    "
 SRC_URI[sha256sum] = "4c305cc59f3e57f2cfc150a6ac511690f43633595760e1cb266bf23362d72f8a"
 
 inherit autotools
 
-do_configure:prepend() {
-    # remove failing test which checks for something that isn't even used
-    sed -i -e '/ye_FUNC_SCANF_MODIF_SIZE_T/d' ${S}/configure.ac
-}
-
-do_configure:append() {
-    sed -i s:-I/usr/include::g ${B}/Makefile
-    sed -i s:-I/usr/include::g ${B}/*/Makefile
-}
-
-do_compile() {
-    cd ${S}/tools && ${BUILD_CC} -o make_hash make_hash.c
-    cd ${B}
-    oe_runmake
-}
-
+EXTRA_OECONF += "MKTEMP_PROG=mktemp"
#1 lore raw

PATCH 2/8 ckermit: Define return type for main

From: Khem Raj <[email protected]>

Newer compilers e.g. clang19+ will treat implicit function prototypes as errors, therefore define main() with a valid return type

Fixes
ckwart.c:531:1: error: return type defaults to ‘int’ [-Wimplicit-int]

  531 | main(argc,argv) int argc; char **argv; {
      | ^~~~
(cherry picked from commit 9813fb56d22acad36d70158335b8ee9f4a05ad89)
---
 meta-oe/recipes-support/ckermit/ckermit_302.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/recipes-support/ckermit/ckermit_302.bb +1 -1
index 53f2b9d2c5..1ee776cefe 100644
@@ -45,7 +45,7 @@ do_compile () {
         -DNORESEND -DNOAUTODL -DNOSTREAMING -DNOHINTS -DNOCKXYZ -DNOLEARN \
         -DNOMKDIR -DNOPERMS -DNOCKTIMERS -DNOCKREGEX -DNOREALPATH \
         -DCK_SMALL -DNOLOGDIAL -DNORENAME -DNOWHATAMI \
-        -DNOARROWKEYS"
+        -DNOARROWKEYS -DMAINTYPE=int"
 }
 
 do_install () {
#2 lore raw

PATCH 3/8 ckermit: Fix build with GCC-15

In reply to Anuj Mittal

From: Khem Raj <[email protected]>

Also fix native pieces to build with gcc-14 while here

(cherry picked from commit f8ece969ea279f37938a54e6d8c01e9937753f03)
---
 meta-oe/recipes-support/ckermit/ckermit_302.bb | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
meta-oe/recipes-support/ckermit/ckermit_302.bb +3 -2
index 1ee776cefe..e9c3a53e38 100644
@@ -28,7 +28,7 @@ do_compile () {
     # The original makefile doesn't differentiate between CC and CC_FOR_BUILD,
     # so we build wart manually. Note that you need a ckwart.o with the proper
     # timestamp to make this hack work:
-    ${BUILD_CC} -c ckwart.c
+    ${BUILD_CC} -DMAINTYPE=int -c -o ckwart.o ckwart.c
     ${BUILD_CC} -o wart ckwart.o
     ./wart ckcpro.w ckcpro.c
 
@@ -45,7 +45,8 @@ do_compile () {
         -DNORESEND -DNOAUTODL -DNOSTREAMING -DNOHINTS -DNOCKXYZ -DNOLEARN \
         -DNOMKDIR -DNOPERMS -DNOCKTIMERS -DNOCKREGEX -DNOREALPATH \
         -DCK_SMALL -DNOLOGDIAL -DNORENAME -DNOWHATAMI \
-        -DNOARROWKEYS -DMAINTYPE=int"
+        -DNOARROWKEYS -DMAINTYPE=int \
+        -D_DEFAULT_SOURCE -ansi"
 }
 
 do_install () {
#3 lore raw

PATCH 4/8 procmail: fix build failure with gcc-14

In reply to Anuj Mittal

From: Wang Mingyu <[email protected]>

(cherry picked from commit a7d98292771c4248a8a6deb370d762dd96cad989)
---
 meta-oe/recipes-support/procmail/procmail_3.22.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/recipes-support/procmail/procmail_3.22.bb +1 -1
index 16917666a4..abb87f9935 100644
@@ -33,7 +33,7 @@ do_configure() {
 }
 
 do_compile() {
-    oe_runmake -i TARGET_CFLAGS="$TARGET_CFLAGS -Wno-comments -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" LDFLAGS0="${LDFLAGS}"
+    oe_runmake -i CFLAGS="$TARGET_CFLAGS -Wno-comments -Wno-implicit-int -Wno-implicit-function-declaration -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" LDFLAGS0="${LDFLAGS}"
 }
 
 do_install() {
#4 lore raw

PATCH 5/8 procmail: patch CVE-2014-3618

In reply to Anuj Mittal

From: Peter Marko <[email protected]>

Take patch from Debian.
https://sources.debian.org/data/main/p/procmail/3.22-20%2Bdeb7u1/debian/patches/CVE-2014-3618.patch

(cherry picked from commit 8378820dab0b6955fb0e2b27f24a1626f9124e5b)
---
 .../procmail/procmail/CVE-2014-3618.patch     | 29 +++++++++++++++++++
 .../recipes-support/procmail/procmail_3.22.bb |  4 ++-
 2 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-support/procmail/procmail/CVE-2014-3618.patch
meta-oe/recipes-support/procmail/procmail/CVE-2014-3618.patch new file +29 -0
new file mode 100644
index 0000000000..b041924361
@@ -0,0 +1,29 @@
+Description: Fix heap-overflow in formail
+ CVE-2014-3618: Heap-overflow in formail when processing
+ specially-crafted email headers.
+Origin: http://www.openwall.com/lists/oss-security/2014/09/03/8
+Bug-Debian: https://bugs.debian.org/704675
+Bug-Debian: https://bugs.debian.org/760443
+Forwarded: not-needed
+Last-Update: 2014-09-04
+
+CVE: CVE-2014-3618
+Upstream-Status: Inactive-Upstream [lastrelease: 2001]
+Signed-off-by: Peter Marko <[email protected]>
+
+--- a/src/formisc.c
++++ b/src/formisc.c
+@@ -84,12 +84,11 @@ normal:	   *target++= *start++;
+ 	case '"':*target++=delim='"';start++;
+       }
+      ;{ int i;
+-	do
++	while(*start)
+ 	   if((i= *target++= *start++)==delim)	 /* corresponding delimiter? */
+ 	      break;
+ 	   else if(i=='\\'&&*start)		    /* skip quoted character */
+ 	      *target++= *start++;
+-	while(*start);						/* anything? */
+       }
+      hitspc=2;
+    }
meta-oe/recipes-support/procmail/procmail_3.22.bb +3 -1
index abb87f9935..4806bf5f80 100644
@@ -12,7 +12,9 @@ SRC_URI = "http://www.ring.gr.jp/archives/net/mail/${BPN}/${BP}.tar.gz \
     file://from-debian-to-fix-compile-errors.patch \
     file://from-debian-to-modify-parameters.patch \
     file://from-debian-to-fix-man-file.patch \
-    file://man-file-mailstat.1-from-debian.patch"
+    file://man-file-mailstat.1-from-debian.patch \
+    file://CVE-2014-3618.patch \
+"
 SRC_URI[md5sum] = "1678ea99b973eb77eda4ecf6acae53f1"
 SRC_URI[sha256sum] = "087c75b34dd33d8b9df5afe9e42801c9395f4bf373a784d9bc97153b0062e117"
 
#5 lore raw

PATCH 6/8 procmail: patch CVE-2017-16844.

In reply to Anuj Mittal

From: Peter Marko <[email protected]>

Take patch from Debian.
https://sources.debian.org/data/main/p/procmail/3.22-26%2Bdeb10u1/debian/patches/30

(cherry picked from commit 3d97f4c13d5f5810659e107f6461f0b63f6fa92a)
---
 .../procmail/procmail/CVE-2017-16844.patch    | 20 +++++++++++++++++++
 .../recipes-support/procmail/procmail_3.22.bb |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 meta-oe/recipes-support/procmail/procmail/CVE-2017-16844.patch
meta-oe/recipes-support/procmail/procmail/CVE-2017-16844.patch new file +20 -0
new file mode 100644
index 0000000000..6e04989c33
@@ -0,0 +1,20 @@
+From: Santiago Vila <[email protected]>
+Subject: Fix heap-based buffer overflow in loadbuf()
+Bug-Debian: http://bugs.debian.org/876511
+X-Debian-version: 3.22-26
+
+CVE: CVE-2017-16844
+Upstream-Status: Inactive-Upstream [lastrelease: 2001]
+Signed-off-by: Peter Marko <[email protected]>
+
+--- a/src/formisc.c
++++ b/src/formisc.c
+@@ -103,7 +103,7 @@
+ }
+ 							    /* append to buf */
+ void loadbuf(text,len)const char*const text;const size_t len;
+-{ if(buffilled+len>buflen)			  /* buf can't hold the text */
++{ while(buffilled+len>buflen)			  /* buf can't hold the text */
+      buf=realloc(buf,buflen+=Bsize);
+   tmemmove(buf+buffilled,text,len);buffilled+=len;
+ }
meta-oe/recipes-support/procmail/procmail_3.22.bb +1 -0
index 4806bf5f80..16fcf84dad 100644
@@ -14,6 +14,7 @@ SRC_URI = "http://www.ring.gr.jp/archives/net/mail/${BPN}/${BP}.tar.gz \
     file://from-debian-to-fix-man-file.patch \
     file://man-file-mailstat.1-from-debian.patch \
     file://CVE-2014-3618.patch \
+    file://CVE-2017-16844.patch \
 "
 SRC_URI[md5sum] = "1678ea99b973eb77eda4ecf6acae53f1"
 SRC_URI[sha256sum] = "087c75b34dd33d8b9df5afe9e42801c9395f4bf373a784d9bc97153b0062e117"
#6 lore raw

PATCH 7/8 procmail: Fix build with GCC-14

In reply to Anuj Mittal

From: Khem Raj <[email protected]>

aids building on newer build hosts which now have moved to gcc-14 as well, so using cmdline option just for target compile is not enough as it runs tests using host compiler as well

(cherry picked from commit 6d13c58e386d478b8788f440b7815cb866b9d6f0)
---
 .../procmail/procmail/gcc14.patch             | 127 ++++++++++++++++++
 .../recipes-support/procmail/procmail_3.22.bb |   4 +-
 2 files changed, 130 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-support/procmail/procmail/gcc14.patch
meta-oe/recipes-support/procmail/procmail/gcc14.patch new file +127 -0
new file mode 100644
index 0000000000..5ca56fa006
@@ -0,0 +1,127 @@
+From: Santiago Vila <[email protected]>
+Subject: Fix build with gcc-14
+Bug-Debian: https://bugs.debian.org/1075398
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+--- a/initmake
++++ b/initmake
+@@ -124,7 +124,7 @@ else
+ fi
+ 
+ cat >_autotst.c <<HERE
+-main()
++int main()
+ { return 0;
+ }
+ HERE
+@@ -200,7 +200,7 @@ cat >_autotst.c <<HERE
+ #include <sys/types.h>
+ #include <stdio.h>
+ #include <sys/stat.h>
+-main()
++int main()
+ { struct stat buf;return!&buf;
+ }
+ HERE
+--- a/src/autoconf
++++ b/src/autoconf
+@@ -414,6 +414,12 @@ cat >_autotst.c <<HERE
+ int dolock,child[NR_of_forks],timeout,fdcollect;
+ char dirlocktest[]="_locktest";
+ 
++#include <stdlib.h>
++int killchildren();
++int fdlock(int fd);
++int sfdlock(int fd);
++int fdunlock();
++
+ void stimeout()
+ { timeout=1;close(fdcollect);killchildren();
+ }
+@@ -435,7 +441,7 @@ unsigned sfork()
+   return pid;
+ }
+ 
+-int main(argc,argv)char*argv[];
++int main(int argc,char*argv[])
+ { int goodlock,testlock,i,pip[2],pipw[2];time_t otimet;unsigned dtimet;
+   static char filename[]="_locktst.l0";
+   close(0);goodlock=0;testlock=FIRST_lock;signal(SIGPIPE,SIG_DFL);
+@@ -585,13 +591,13 @@ int killchildren()
+   return 0;
+ }
+ 
+-int sfdlock(fd)
++int sfdlock(int fd)
+ { int i;unsigned gobble[GOBBLE>>2];
+   for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0);		 /* SunOS crash test */
+   return fdlock(fd);
+ }
+ 
+-static oldfdlock;
++static int oldfdlock;
+ #ifdef F_SETLKW
+ static struct flock flck;		/* why can't it be a local variable? */
+ #endif
+@@ -599,7 +605,7 @@ static struct flock flck;		/* why can't
+ static off_t oldlockoffset;
+ #endif
+ 
+-int fdlock(fd)
++int fdlock(int fd)
+ { int i;unsigned gobble[GOBBLE>>2];
+   for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0);		 /* SunOS crash test */
+   oldfdlock=fd;fd=0;
+@@ -993,11 +999,11 @@ int main(){int i;i=1;
+  i+=WIFEXITED(i);
+  i+=WIFSTOPPED(i);
+  i+=WEXITSTATUS(i);
+- i+=WSIGTERM(i);
++ i+=WTERMSIG(i);
+  return i;}
+ HERE
+ 
+-echo 'Testing for WIFEXITED(), WIFSTOPPED(), WEXITSTATUS() & WSIGTERM()'
++echo 'Testing for WIFEXITED(), WIFSTOPPED(), WEXITSTATUS() & WTERMSIG()'
+ if $MAKE _autotst.$O >_autotst.rrr 2>&1
+ then
+    $FGREP -v include/ <_autotst.rrr >_autotst.$O
+@@ -1029,6 +1035,8 @@ cat >_autotst.c <<HERE
+ #ifndef NO_COMSAT
+ #include "network.h"
+ #endif
++int setrgid();
++int setresgid();
+ int main(){char a[2];
+  endpwent();endgrent();memmove(a,"0",1);bcopy("0",a,1);strcspn(a,"0");
+  strtol("0",(char**)0,10);strchr("0",'0');strpbrk(a,"0");rename(a,"0");
+@@ -1059,7 +1067,7 @@ echo 'Testing for memmove, strchr, strpb
+ echo '	rename, setrgid, setegid, pow, opendir, mkdir, waitpid, fsync,'
+ echo '	ftruncate, strtod, strncasecmp, strerror, strlcat,'
+ echo '	memset, bzero, and _exit'
+-if $MAKE _autotst.$O >$DEVNULL 2>&1
++if $MAKE _autotst.$O >_autotst.rrr 2>&1
+ then
+ :
+ else
+@@ -1196,7 +1204,7 @@ unsigned long dobench(strstr,iter,haysta
+   return (unsigned long)clock()-to;
+ }
+ #endif
+-int main(argc,argv)int argc;const char*argv[];
++int main(int argc,const char*argv[])
+ { if(argc==1)
+    { char*haystack;
+ #ifdef BENCHSIZE
+--- a/src/mailfold.c
++++ b/src/mailfold.c
+@@ -378,7 +378,7 @@ void concon(ch)const int ch;   /* flip b
+    }
+ }
+ 
+-void readmail(rhead,tobesent)const long tobesent;
++void readmail(int rhead,const long tobesent)
+ { char*chp,*pastend;static size_t contlengthoffset;
+   ;{ long dfilled;
+      if(rhead==2)		  /* already read, just examine what we have */
meta-oe/recipes-support/procmail/procmail_3.22.bb +3 -1
index 16fcf84dad..604dd285e8 100644
@@ -15,6 +15,7 @@ SRC_URI = "http://www.ring.gr.jp/archives/net/mail/${BPN}/${BP}.tar.gz \
     file://man-file-mailstat.1-from-debian.patch \
     file://CVE-2014-3618.patch \
     file://CVE-2017-16844.patch \
+    file://gcc14.patch \
 "
 SRC_URI[md5sum] = "1678ea99b973eb77eda4ecf6acae53f1"
 SRC_URI[sha256sum] = "087c75b34dd33d8b9df5afe9e42801c9395f4bf373a784d9bc97153b0062e117"
@@ -25,6 +26,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=a71e50e197a992c862379e576e669757 \
 
 DEPENDS = "libnet"
 inherit autotools-brokensep
+
 do_configure() {
     find examples -type f | xargs chmod 644
     export CC="${BUILD_CC}"
@@ -36,7 +38,7 @@ do_configure() {
 }
 
 do_compile() {
-    oe_runmake -i CFLAGS="$TARGET_CFLAGS -Wno-comments -Wno-implicit-int -Wno-implicit-function-declaration -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" LDFLAGS0="${LDFLAGS}"
+    oe_runmake -i CFLAGS="$TARGET_CFLAGS -Wno-comments -Wno-implicit-function-declaration -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" LDFLAGS0="${LDFLAGS}"
 }
 
 do_install() {
#7 lore raw

PATCH 8/8 procmail: Add -Wno-implicit-int to fix error of do_compile

In reply to Anuj Mittal

From: Wang Mingyu <[email protected]>

Without the option -Wno-implicit-int , the following error will occur and the command procmail will not be installed to target. lmtp.c:54:8: error: type defaults to 'int' in declaration of 'ctopfd' [-Wimplicit-int]

   54 | static ctopfd;
      |        ^~~~~~

make[1]: [Makefile:239: lmtp.o] Error 1 (ignored)

(cherry picked from commit d23de74dc8f80b8a4abb21801dcfbef611664e9a)
---
 meta-oe/recipes-support/procmail/procmail_3.22.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/recipes-support/procmail/procmail_3.22.bb +1 -1
index 604dd285e8..5da6ce2603 100644
@@ -38,7 +38,7 @@ do_configure() {
 }
 
 do_compile() {
-    oe_runmake -i CFLAGS="$TARGET_CFLAGS -Wno-comments -Wno-implicit-function-declaration -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" LDFLAGS0="${LDFLAGS}"
+    oe_runmake -i CFLAGS="$TARGET_CFLAGS -Wno-comments -Wno-implicit-int -Wno-implicit-function-declaration -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" LDFLAGS0="${LDFLAGS}"
 }
 
 do_install() {