aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorSteve Wills <swills@FreeBSD.org>2018-11-10 01:39:20 +0800
committerSteve Wills <swills@FreeBSD.org>2018-11-10 01:39:20 +0800
commitc72df2577b7d32dd863e6e1197f657047ab18681 (patch)
treef5fcb6af399a919d30cc9f50612961b41a27ea06 /security
parentfb09b59b5da0d2b1fe61c93d137ce9f068f5424b (diff)
downloadfreebsd-ports-gnome-c72df2577b7d32dd863e6e1197f657047ab18681.tar.gz
freebsd-ports-gnome-c72df2577b7d32dd863e6e1197f657047ab18681.tar.zst
freebsd-ports-gnome-c72df2577b7d32dd863e6e1197f657047ab18681.zip
security/yafic: Fix OpenSSL 1.1.x build
PR: 232302 Submitted by: Allan Saddi <allan@saddi.com> (maintainer)
Diffstat (limited to 'security')
-rw-r--r--security/yafic/Makefile2
-rw-r--r--security/yafic/files/patch-crypto.c188
2 files changed, 189 insertions, 1 deletions
diff --git a/security/yafic/Makefile b/security/yafic/Makefile
index d94dbcb4993c..4160bb312798 100644
--- a/security/yafic/Makefile
+++ b/security/yafic/Makefile
@@ -3,7 +3,7 @@
PORTNAME= yafic
PORTVERSION= 1.2.2
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= security
MASTER_SITES= SF
diff --git a/security/yafic/files/patch-crypto.c b/security/yafic/files/patch-crypto.c
new file mode 100644
index 000000000000..a5091236f233
--- /dev/null
+++ b/security/yafic/files/patch-crypto.c
@@ -0,0 +1,188 @@
+--- crypto.c.orig 2004-03-21 04:02:32.000000000 -0800
++++ crypto.c 2018-10-15 15:18:25.842905000 -0700
+@@ -56,6 +56,30 @@
+
+ static EVP_PKEY *pkey;
+
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++
++static void *OPENSSL_zalloc (size_t num)
++{
++ void *ret = OPENSSL_malloc (num);
++
++ if (ret != NULL)
++ memset (ret, 0, num);
++ return ret;
++}
++
++EVP_MD_CTX *EVP_MD_CTX_new (void)
++{
++ return OPENSSL_zalloc (sizeof (EVP_MD_CTX));
++}
++
++void EVP_MD_CTX_free (EVP_MD_CTX *ctx)
++{
++ EVP_MD_CTX_cleanup (ctx);
++ OPENSSL_free (ctx);
++}
++
++#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
++
+ static void
+ opensslError (const char *what)
+ {
+@@ -100,7 +124,7 @@
+ SignFile (int fd, const char *filename, const char *sigfile)
+ {
+ const EVP_MD *mdType;
+- EVP_MD_CTX ctx;
++ EVP_MD_CTX *ctx;
+ ssize_t len;
+ unsigned char *sig = NULL;
+ unsigned int sigLen;
+@@ -111,8 +135,12 @@
+ if (!pkey)
+ return;
+
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ mdType = EVP_PKEY_type (pkey->type) == EVP_PKEY_DSA ? EVP_dss1 () :
+ EVP_sha1 ();
++#else
++ mdType = EVP_sha1 ();
++#endif
+
+ if (!sigfile) {
+ int tlen = strlen (filename) + 4 + 1;
+@@ -122,21 +150,23 @@
+ sigfile = tsigfile;
+ }
+
++ if ((ctx = EVP_MD_CTX_new ()) == NULL)
++ opensslError ("EVP_MD_CTX_new");
+ #ifdef HAVE_EVP_MD_CTX_INIT
+- EVP_MD_CTX_init (&ctx);
++ EVP_MD_CTX_init (ctx);
+ #endif
+ #ifdef EVP_DIGESTINIT_VOID
+- EVP_SignInit (&ctx, mdType);
++ EVP_SignInit (ctx, mdType);
+ #else
+- if (!EVP_SignInit (&ctx, mdType))
++ if (!EVP_SignInit (ctx, mdType))
+ opensslError ("EVP_SignInit");
+ #endif
+
+ while ((len = read (fd, HashBuffer, HASH_BUFFER_SIZE)) > 0) {
+ #ifdef EVP_DIGESTINIT_VOID
+- EVP_SignUpdate (&ctx, HashBuffer, len);
++ EVP_SignUpdate (ctx, HashBuffer, len);
+ #else
+- if (!EVP_SignUpdate (&ctx, HashBuffer, len))
++ if (!EVP_SignUpdate (ctx, HashBuffer, len))
+ opensslError ("EVP_SignUpdate");
+ #endif
+ }
+@@ -146,7 +176,7 @@
+
+ sig = mymalloc (EVP_PKEY_size (pkey));
+
+- if (EVP_SignFinal (&ctx, sig, &sigLen, pkey)) {
++ if (EVP_SignFinal (ctx, sig, &sigLen, pkey)) {
+ if ((f = open (sigfile, O_CREAT|O_WRONLY|O_TRUNC, 0600)) != -1) {
+ if (write (f, sig, sigLen) != sigLen)
+ yaficError (sigfile);
+@@ -162,15 +192,16 @@
+ if (sig) free (sig);
+ if (tsigfile) free (tsigfile);
+ #ifdef HAVE_EVP_MD_CTX_CLEANUP
+- EVP_MD_CTX_cleanup (&ctx);
++ EVP_MD_CTX_cleanup (ctx);
+ #endif
++ EVP_MD_CTX_free (ctx);
+ }
+
+ void
+ VerifyFile (int fd, const char *filename, const char *sigfile)
+ {
+ const EVP_MD *mdType;
+- EVP_MD_CTX ctx;
++ EVP_MD_CTX *ctx;
+ ssize_t len;
+ unsigned char *sig = NULL;
+ int f;
+@@ -181,8 +212,12 @@
+ if (!pkey)
+ return;
+
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ mdType = EVP_PKEY_type (pkey->type) == EVP_PKEY_DSA ? EVP_dss1 () :
+ EVP_sha1 ();
++#else
++ mdType = EVP_sha1 ();
++#endif
+
+ if (!sigfile) {
+ int tlen = strlen (filename) + 4 + 1;
+@@ -195,13 +230,15 @@
+ fprintf (stderr, "Verifying %s: ", filename);
+ fflush (stderr);
+
++ if ((ctx = EVP_MD_CTX_new ()) == NULL)
++ opensslError ("EVP_MD_CTX_new");
+ #ifdef HAVE_EVP_MD_CTX_INIT
+- EVP_MD_CTX_init (&ctx);
++ EVP_MD_CTX_init (ctx);
+ #endif
+ #ifdef EVP_DIGESTINIT_VOID
+- EVP_VerifyInit (&ctx, mdType);
++ EVP_VerifyInit (ctx, mdType);
+ #else
+- if (!EVP_VerifyInit (&ctx, mdType)) {
++ if (!EVP_VerifyInit (ctx, mdType)) {
+ fprintf (stderr, "Error\n");
+ opensslError ("EVP_VerifyInit");
+ }
+@@ -209,9 +246,9 @@
+
+ while ((len = read (fd, HashBuffer, HASH_BUFFER_SIZE)) > 0) {
+ #ifdef EVP_DIGESTINIT_VOID
+- EVP_VerifyUpdate (&ctx, HashBuffer, len);
++ EVP_VerifyUpdate (ctx, HashBuffer, len);
+ #else
+- if (!EVP_VerifyUpdate (&ctx, HashBuffer, len)) {
++ if (!EVP_VerifyUpdate (ctx, HashBuffer, len)) {
+ fprintf (stderr, "Error\n");
+ opensslError ("EVP_SignUpdate");
+ }
+@@ -233,7 +270,7 @@
+
+ close (f);
+
+- ret = EVP_VerifyFinal (&ctx, sig, len, pkey);
++ ret = EVP_VerifyFinal (ctx, sig, len, pkey);
+ if (ret < 0) {
+ fprintf (stderr, "Error\n");
+ opensslError ("EVP_VerifyFinal");
+@@ -254,8 +291,9 @@
+ if (sig) free (sig);
+ if (tsigfile) free (tsigfile);
+ #ifdef HAVE_EVP_MD_CTX_CLEANUP
+- EVP_MD_CTX_cleanup (&ctx);
++ EVP_MD_CTX_cleanup (ctx);
+ #endif
++ EVP_MD_CTX_free (ctx);
+ }
+
+ const char *
+@@ -265,7 +303,11 @@
+
+ if (pkey) {
+ int bits = EVP_PKEY_bits (pkey);
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ int type = EVP_PKEY_type (pkey->type);
++#else
++ int type = EVP_PKEY_base_id (pkey);
++#endif
+
+ switch (type) {
+ case EVP_PKEY_RSA: