libmcrypt: rebuild for C99

This commit is contained in:
Đoàn Trần Công Danh 2024-02-20 08:20:20 +07:00
parent e2236ebd6a
commit d541b85fc4
6 changed files with 189 additions and 1 deletions

View file

@ -0,0 +1,18 @@
--- a/KNOWN-BUGS 2008-12-13 15:31:49.000000000 -0500
+++ /dev/null 2008-12-13 02:05:21.751517562 -0500
@@ -1 +0,0 @@
-- cast-256 and rc6 do not work properly on Alpha (64 bit) machines
--- a/lib/mcrypt_modules.h.orig 2008-12-13 15:33:06.000000000 -0500
+++ b/lib/mcrypt_modules.h 2008-12-13 15:25:01.000000000 -0500
@@ -1,7 +1,7 @@
-#define rotl32(x,n) (((x) << ((word32)(n))) | ((x) >> (32 - (word32)(n))))
-#define rotr32(x,n) (((x) >> ((word32)(n))) | ((x) << (32 - (word32)(n))))
-#define rotl16(x,n) (((x) << ((word16)(n))) | ((x) >> (16 - (word16)(n))))
-#define rotr16(x,n) (((x) >> ((word16)(n))) | ((x) << (16 - (word16)(n))))
+#define rotl32(x,n) (((x) << ((word32)(n & 31))) | ((x) >> (32 - (word32)(n & 31))))
+#define rotr32(x,n) (((x) >> ((word32)(n & 31))) | ((x) << (32 - (word32)(n & 31))))
+#define rotl16(x,n) (((x) << ((word16)(n & 15))) | ((x) >> (16 - (word16)(n & 15))))
+#define rotr16(x,n) (((x) >> ((word16)(n & 15))) | ((x) << (16 - (word16)(n & 15))))
/* Use hardware rotations.. when available */
#ifdef swap32

View file

@ -0,0 +1,16 @@
--- libmcrypt-2.5.8/libltdl/configure.in
+++ libmcrypt-2.5.8/libltdl/configure.in
@@ -2,13 +2,6 @@
AC_INIT(ltdl.c)
-dnl We shouldn't be using these internal macros of autoconf,
-dnl but CONFIG_AUX_DIR($with_auxdir) breaks automake.
-AC_ARG_WITH(auxdir,
-[ --with-auxdir=DIR path to autoconf auxiliary files],
-[AC_CONFIG_AUX_DIRS($with_auxdir)],
-[AC_CONFIG_AUX_DIR_DEFAULT])
-
if test -z "$enable_ltdl_install$enable_ltdl_convenience"; then
if test -f ${srcdir}/ltmain.sh; then
# if libltdl is libtoolized, it is assumed to be stand-alone and

View file

@ -0,0 +1,12 @@
diff -up libmcrypt-2.5.8/modules/algorithms/twofish.c.BAD libmcrypt-2.5.8/modules/algorithms/twofish.c
--- libmcrypt-2.5.8/modules/algorithms/twofish.c.BAD 2008-08-25 17:38:21.000000000 -0400
+++ libmcrypt-2.5.8/modules/algorithms/twofish.c 2008-08-25 17:38:30.000000000 -0400
@@ -499,7 +499,7 @@ static void f_rnd(int i, word32* blk, TW
/* encrypt a block of text */
WIN32DLL_DEFINE void _mcrypt_encrypt(TWI * pkey, word32 * in_blk)
{
- word32 t0, t1, blk[4];
+ word32 t0 = 0, t1 = 0, blk[4];
#ifdef WORDS_BIGENDIAN
blk[0] = byteswap32(in_blk[0]) ^ pkey->l_key[0];
blk[1] = byteswap32(in_blk[1]) ^ pkey->l_key[1];

View file

@ -0,0 +1,35 @@
diff -up libmcrypt-2.5.8/modules/algorithms/des.c.BAD libmcrypt-2.5.8/modules/algorithms/des.c
--- libmcrypt-2.5.8/modules/algorithms/des.c.BAD 2008-08-25 17:40:29.000000000 -0400
+++ libmcrypt-2.5.8/modules/algorithms/des.c 2008-08-25 17:40:51.000000000 -0400
@@ -35,9 +35,12 @@
/* #define NULL 0 */
-static void permute_ip(), permute_fp(), perminit_ip(), spinit(),
-perminit_fp();
-static word32 f();
+static void permute_ip(char *, DES_KEY *, char *);
+static void permute_fp(char *, DES_KEY *, char *);
+static void perminit_ip(DES_KEY *);
+static void spinit(DES_KEY *);
+static void perminit_fp(DES_KEY *);
+static word32 f(DES_KEY *, register word32, register char *);
/* Tables defined in the Data Encryption Standard documents */
diff -up libmcrypt-2.5.8/modules/algorithms/tripledes.c.BAD libmcrypt-2.5.8/modules/algorithms/tripledes.c
--- libmcrypt-2.5.8/modules/algorithms/tripledes.c.BAD 2008-08-25 17:40:56.000000000 -0400
+++ libmcrypt-2.5.8/modules/algorithms/tripledes.c 2008-08-25 17:41:13.000000000 -0400
@@ -36,8 +36,10 @@
/* #define NULL 0 */
-static void permute(), perminit(), spinit();
-static word32 f();
+static void permute(char *, char[16][16][8], char *);
+static void perminit(char[16][16][8], char[64]);
+static void spinit(TRIPLEDES_KEY *, int);
+static word32 f(TRIPLEDES_KEY *, int, register word32, register char *);
/* Tables defined in the Data Encryption Standard documents */

View file

@ -0,0 +1,98 @@
https://src.fedoraproject.org/rpms/libmcrypt/blob/e02fbd614a5b7ba093e9e15ab322e7eb02d64e3b/f/libmcrypt-c99.patch
Add return and argument types to fake prototypes in mcrypt_symb.c.
This avoids build failures with future compilers that do not support
implicit function declarations.
Also fix a minor type error in the perminit calls in the Triple DES
implementation.
Submitted upstream: <https://sourceforge.net/p/mcrypt/patches/15/>
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a1a09578858aaf3c..a92f150627a1f610 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -23,8 +23,8 @@ mcrypt_symb.c: mcrypt_internal.h
@echo "/* This is automatically created. Don't touch... */" >> mcrypt_symb.c
@echo "" >> mcrypt_symb.c
-@for i in $(EXTRA_ALGOS); do \
- if test -f ../modules/algorithms/$$i.c; then cat ../modules/algorithms/$$i.c 2>/dev/null|grep define|grep LTX|awk '{print "extern "$$3"();";}' >> mcrypt_symb.c 2>/dev/null; fi; \
- if test -f ../modules/modes/$$i.c; then cat ../modules/modes/$$i.c 2>/dev/null|grep define|grep LTX|awk '{print "extern "$$3"();";}' >> mcrypt_symb.c 2>/dev/null; fi; \
+ if test -f ../modules/algorithms/$$i.c; then cat ../modules/algorithms/$$i.c 2>/dev/null|grep define|grep LTX|awk '{print "extern void "$$3"(void);";}' >> mcrypt_symb.c 2>/dev/null; fi; \
+ if test -f ../modules/modes/$$i.c; then cat ../modules/modes/$$i.c 2>/dev/null|grep define|grep LTX|awk '{print "extern void "$$3"(void);";}' >> mcrypt_symb.c 2>/dev/null; fi; \
done
@echo "" >> mcrypt_symb.c
@echo "const mcrypt_preloaded mps[] = {" >> mcrypt_symb.c
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 1baaa1e94be1abce..e0e690d1c831370f 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -561,8 +561,8 @@ mcrypt_symb.c: mcrypt_internal.h
@echo "/* This is automatically created. Don't touch... */" >> mcrypt_symb.c
@echo "" >> mcrypt_symb.c
-@for i in $(EXTRA_ALGOS); do \
- if test -f ../modules/algorithms/$$i.c; then cat ../modules/algorithms/$$i.c 2>/dev/null|grep define|grep LTX|awk '{print "extern "$$3"();";}' >> mcrypt_symb.c 2>/dev/null; fi; \
- if test -f ../modules/modes/$$i.c; then cat ../modules/modes/$$i.c 2>/dev/null|grep define|grep LTX|awk '{print "extern "$$3"();";}' >> mcrypt_symb.c 2>/dev/null; fi; \
+ if test -f ../modules/algorithms/$$i.c; then cat ../modules/algorithms/$$i.c 2>/dev/null|grep define|grep LTX|awk '{print "extern void "$$3"(void);";}' >> mcrypt_symb.c 2>/dev/null; fi; \
+ if test -f ../modules/modes/$$i.c; then cat ../modules/modes/$$i.c 2>/dev/null|grep define|grep LTX|awk '{print "extern void "$$3"(void);";}' >> mcrypt_symb.c 2>/dev/null; fi; \
done
@echo "" >> mcrypt_symb.c
@echo "const mcrypt_preloaded mps[] = {" >> mcrypt_symb.c
diff --git a/modules/algorithms/tripledes.c b/modules/algorithms/tripledes.c
index 98e9bd45b4f336b1..2737d2fd8fd02a3f 100644
--- a/modules/algorithms/tripledes.c
+++ b/modules/algorithms/tripledes.c
@@ -201,8 +201,8 @@ static int _mcrypt_desinit(TRIPLEDES_KEY * key)
spinit(key, 0);
spinit(key, 1);
spinit(key, 2);
- perminit(&key->iperm, ip);
- perminit(&key->fperm, fp);
+ perminit(key->iperm, ip);
+ perminit(key->fperm, fp);
return 0;
https://src.fedoraproject.org/rpms/libmcrypt/blob/e02fbd614a5b7ba093e9e15ab322e7eb02d64e3b/f/libmcrypt-configure-c99-2.patch
Fix glitches in the readdir and bcopy probes. They were
just invalid.
diff --git a/configure b/configure
index d0fb8783e147654b..4fe7660a16359171 100755
--- a/configure
+++ b/configure
@@ -6639,7 +6639,7 @@ fi
done
-for ac_func in readdir,,
+for ac_func in readdir
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -6741,7 +6741,7 @@ fi
done
-for ac_func in bcopy,,
+for ac_func in bcopy
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/configure.in b/configure.in
index a815778931728ec2..f0c9a0e8f73e1153 100644
--- a/configure.in
+++ b/configure.in
@@ -204,8 +204,8 @@ AC_FUNC_MEMCMP
AC_FUNC_REALLOC
AC_CHECK_FUNCS([bzero memmove memset mlock readdir_r strchr strdup strrchr])
-AC_CHECK_FUNCS([readdir,,])
-AC_CHECK_FUNCS([bcopy,,])
+AC_CHECK_FUNCS([readdir])
+AC_CHECK_FUNCS([bcopy])
dnl Checks for libraries.
AC_C_BIGENDIAN

View file

@ -1,8 +1,9 @@
# Template file for 'libmcrypt'
pkgname=libmcrypt
version=2.5.8
revision=3
revision=4
build_style=gnu-configure
hostmakedepends="automake libtool libltdl-devel"
short_desc="A data encryption library"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later"
@ -10,6 +11,14 @@ homepage="http://mcrypt.sourceforge.net/"
distfiles="${SOURCEFORGE_SITE}/mcrypt/$pkgname-$version.tar.bz2"
checksum=bf2f1671f44af88e66477db0982d5ecb5116a5c767b0a0d68acb34499d41b793
pre_configure() {
sed 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/g' \
configure.in >configure.ac
sed 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/g' \
libltdl/configure.in >libltdl/configure.ac
autoreconf -fi
}
libmcrypt-devel_package() {
short_desc+=" - development files"
depends="${sourcepkg}>=${version}_${revision}"