new package: vde2 (#7451)
This commit is contained in:
parent
310793630d
commit
5048f8206c
118
packages/vde2/Fix_parallel_make.patch
Normal file
118
packages/vde2/Fix_parallel_make.patch
Normal file
@ -0,0 +1,118 @@
|
||||
From 7dd9ed46d5dca125ca45d679ac9f3acbfb0f9300 Mon Sep 17 00:00:00 2001
|
||||
From: orbea <orbea@riseup.net>
|
||||
Date: Wed, 17 Mar 2021 15:16:09 -0700
|
||||
Subject: [PATCH] build: Fix parallel make.
|
||||
|
||||
---
|
||||
configure.ac | 3 ++-
|
||||
src/Makefile.am | 2 +-
|
||||
src/lib/Makefile.am | 11 +++--------
|
||||
src/lib/vdemgmt/Makefile.am | 18 ++++++++++++++++++
|
||||
src/lib/{ => vdemgmt}/libvdemgmt.c | 0
|
||||
src/lib/{ => vdemgmt}/vdemgmt.pc.in | 0
|
||||
6 files changed, 24 insertions(+), 10 deletions(-)
|
||||
create mode 100644 src/lib/vdemgmt/Makefile.am
|
||||
rename src/lib/{ => vdemgmt}/libvdemgmt.c (100%)
|
||||
rename src/lib/{ => vdemgmt}/vdemgmt.pc.in (100%)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 2aedfd9..43fafe6 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -265,10 +265,11 @@ AC_CONFIG_FILES(
|
||||
[src/Makefile]
|
||||
[src/lib/Makefile]
|
||||
[src/lib/vdesnmp.pc]
|
||||
- [src/lib/vdemgmt.pc]
|
||||
[src/lib/vdeplug.pc]
|
||||
[src/lib/vdehist.pc]
|
||||
[src/lib/python/Makefile]
|
||||
+ [src/lib/vdemgmt/Makefile]
|
||||
+ [src/lib/vdemgmt/vdemgmt.pc]
|
||||
[src/vde_switch/Makefile]
|
||||
[src/kvde_switch/Makefile]
|
||||
[src/vde_over_ns/Makefile]
|
||||
diff --git a/src/Makefile.am b/src/Makefile.am
|
||||
index d7bbc0f..b458e44 100644
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -59,7 +59,7 @@ if ENABLE_PROFILE
|
||||
AM_LDFLAGS = -pg --coverage
|
||||
endif
|
||||
|
||||
-vde_autolink_LDADD = $(LDADD) lib/libvdemgmt.la
|
||||
+vde_autolink_LDADD = $(LDADD) lib/vdemgmt/libvdemgmt.la
|
||||
vde_plug2tap_LDADD = $(LDADD) lib/libvdeplug.la
|
||||
if ENABLE_PCAP
|
||||
vde_pcapplug_LDADD = $(LDADD) lib/libvdeplug.la -lpcap
|
||||
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
|
||||
index c746504..e05bec3 100644
|
||||
--- a/src/lib/Makefile.am
|
||||
+++ b/src/lib/Makefile.am
|
||||
@@ -1,7 +1,7 @@
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include \
|
||||
-DSYSCONFDIR="\"$(sysconfdir)\"" -DLOCALSTATEDIR="\"$(localstatedir)\""
|
||||
LIBADD = $(top_builddir)/src/common/libvdecommon.la
|
||||
-SUBDIRS =
|
||||
+SUBDIRS = vdemgmt
|
||||
|
||||
if ENABLE_PROFILE
|
||||
AM_CFLAGS = -pg --coverage
|
||||
@@ -9,17 +9,13 @@ if ENABLE_PROFILE
|
||||
endif
|
||||
|
||||
lib_LTLIBRARIES = \
|
||||
- libvdemgmt.la \
|
||||
libvdesnmp.la \
|
||||
libvdeplug.la \
|
||||
libvdehist.la
|
||||
|
||||
# read before touching http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
|
||||
|
||||
-libvdemgmt_la_LIBADD = $(LIBADD)
|
||||
-libvdemgmt_la_LDFLAGS = $(AM_LDFLAGS) -version-number 0:0:1 -export-dynamic
|
||||
-
|
||||
-libvdesnmp_la_LIBADD = $(LIBADD) $(top_builddir)/src/lib/libvdemgmt.la
|
||||
+libvdesnmp_la_LIBADD = $(LIBADD) $(top_builddir)/src/lib/vdemgmt/libvdemgmt.la
|
||||
libvdesnmp_la_LDFLAGS = $(AM_LDFLAGS) -version-number 0:0:1 -export-dynamic
|
||||
|
||||
libvdeplug_la_LIBADD = $(LIBADD)
|
||||
@@ -33,5 +29,4 @@ SUBDIRS += . python
|
||||
endif
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
-pkgconfig_DATA = vdesnmp.pc vdemgmt.pc vdeplug.pc vdehist.pc
|
||||
-
|
||||
+pkgconfig_DATA = vdesnmp.pc vdeplug.pc vdehist.pc
|
||||
diff --git a/src/lib/vdemgmt/Makefile.am b/src/lib/vdemgmt/Makefile.am
|
||||
new file mode 100644
|
||||
index 0000000..82233e7
|
||||
--- /dev/null
|
||||
+++ b/src/lib/vdemgmt/Makefile.am
|
||||
@@ -0,0 +1,18 @@
|
||||
+AM_CPPFLAGS = -I$(top_srcdir)/include \
|
||||
+ -DSYSCONFDIR="\"$(sysconfdir)\"" -DLOCALSTATEDIR="\"$(localstatedir)\""
|
||||
+LIBADD = $(top_builddir)/src/common/libvdecommon.la
|
||||
+
|
||||
+if ENABLE_PROFILE
|
||||
+ AM_CFLAGS = -pg --coverage
|
||||
+ AM_LDFLAGS = -pg --coverage
|
||||
+endif
|
||||
+
|
||||
+lib_LTLIBRARIES = libvdemgmt.la
|
||||
+
|
||||
+# read before touching http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
|
||||
+
|
||||
+libvdemgmt_la_LIBADD = $(LIBADD)
|
||||
+libvdemgmt_la_LDFLAGS = $(AM_LDFLAGS) -version-number 0:0:1 -export-dynamic
|
||||
+
|
||||
+pkgconfigdir = $(libdir)/pkgconfig
|
||||
+pkgconfig_DATA = vdemgmt.pc
|
||||
diff --git a/src/lib/libvdemgmt.c b/src/lib/vdemgmt/libvdemgmt.c
|
||||
similarity index 100%
|
||||
rename from src/lib/libvdemgmt.c
|
||||
rename to src/lib/vdemgmt/libvdemgmt.c
|
||||
diff --git a/src/lib/vdemgmt.pc.in b/src/lib/vdemgmt/vdemgmt.pc.in
|
||||
similarity index 100%
|
||||
rename from src/lib/vdemgmt.pc.in
|
||||
rename to src/lib/vdemgmt/vdemgmt.pc.in
|
16
packages/vde2/build.sh
Normal file
16
packages/vde2/build.sh
Normal file
@ -0,0 +1,16 @@
|
||||
TERMUX_PKG_HOMEPAGE=https://github.com/virtualsquare/vde-2
|
||||
TERMUX_PKG_DESCRIPTION="Virtual Distributed Ethernet for emulators like qemu"
|
||||
TERMUX_PKG_LICENSE="custom"
|
||||
TERMUX_PKG_LICENSE_FILE="COPYING, COPYING.libvdeplug, COPYING.slirpvde"
|
||||
TERMUX_PKG_MAINTAINER="@termux"
|
||||
TERMUX_PKG_VERSION=2.3.2
|
||||
TERMUX_PKG_SRCURL=https://downloads.sourceforge.net/vde/vde2-$TERMUX_PKG_VERSION.tar.bz2
|
||||
TERMUX_PKG_SHA256=cbea9b7e03097f87a6b5e98b07890d2275848f1fe4b9fcda77b8994148bc9542
|
||||
TERMUX_PKG_DEPENDS="libpcap,libtool , openssl, libc++"
|
||||
TERMUX_PKG_BUILD_IN_SRC=true
|
||||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --disable-python"
|
||||
|
||||
termux_step_pre_configure() {
|
||||
autoreconf --install
|
||||
CFLAGS+=" -Dindex=strchr -Drindex=strrchr"
|
||||
}
|
19
packages/vde2/src-vde_switch-fstp.c.patch
Normal file
19
packages/vde2/src-vde_switch-fstp.c.patch
Normal file
@ -0,0 +1,19 @@
|
||||
diff -uNr vde2-2.3.2/src/vde_switch/fstp.c vde2-2.3.2.mod/src/vde_switch/fstp.c
|
||||
--- a/src/vde_switch/fstp.c 2011-11-23 18:41:17.000000000 +0200
|
||||
+++ b/src/vde_switch/fstp.c 2021-09-04 11:44:37.154602292 +0300
|
||||
@@ -30,14 +30,14 @@
|
||||
#ifdef FSTP
|
||||
#include <fstp.h>
|
||||
/*********************** sending macro used by FSTP & Core ******************/
|
||||
-void inline ltonstring(unsigned long l,unsigned char *s) {
|
||||
+void ltonstring(unsigned long l,unsigned char *s) {
|
||||
s[3]=l; l>>=8;
|
||||
s[2]=l; l>>=8;
|
||||
s[1]=l; l>>=8;
|
||||
s[0]=l;
|
||||
}
|
||||
|
||||
-unsigned long inline nstringtol(unsigned char *s) {
|
||||
+unsigned long nstringtol(unsigned char *s) {
|
||||
return (s[0]<<24)+(s[1]<<16)+(s[2]<<8)+s[3];
|
||||
}
|
264
packages/vde2/upsteam-bionic-support.patch
Normal file
264
packages/vde2/upsteam-bionic-support.patch
Normal file
@ -0,0 +1,264 @@
|
||||
From 370488067045ce84c89f88cfd70577be14c9a48c Mon Sep 17 00:00:00 2001
|
||||
From: Daniele Lacamera <danielinux@users.noreply.github.com>
|
||||
Date: Wed, 20 Mar 2013 10:26:31 +0000
|
||||
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -41,6 +41,9 @@
|
||||
|
||||
AC_CHECK_HEADERS([openssl/blowfish.h], [],
|
||||
[add_cryptcab_support=no ; warn_cryptcab=yes])
|
||||
+
|
||||
+AC_CHECK_HEADERS([sysexits.h], [],
|
||||
+ [add_over_ns_support=no ; warn_over_ns=yes])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
@@ -91,7 +94,11 @@
|
||||
# Define VDE_LINUX or VDE_DARWIN
|
||||
case "$build_os" in
|
||||
linux*)
|
||||
- AC_DEFINE([VDE_LINUX], 1, [If defined, this is a Linux system])
|
||||
+ if expr "$host_os" : ".*android" > /dev/null; then
|
||||
+ AC_DEFINE([VDE_BIONIC], 1, [If defined, this is a Linux/bionic system])
|
||||
+ else
|
||||
+ AC_DEFINE([VDE_LINUX], 1, [If defined, this is a Linux system])
|
||||
+ fi
|
||||
;;
|
||||
darwin*)
|
||||
AC_DEFINE([VDE_DARWIN], 1, [If defined, this is a Darwin system])
|
||||
@@ -123,6 +130,12 @@
|
||||
AS_HELP_STRING([--disable-cryptcab],
|
||||
[Disable libcrypto-dependend vde_cryptcab compilation]),
|
||||
[if test $enableval = "no" ; then add_cryptcab_support=no ; warn_cryptcab=no ; fi])
|
||||
+
|
||||
+# Disable vde_over_ns? (not working on android, maybe unwanted)
|
||||
+AC_ARG_ENABLE([vde_over_ns],
|
||||
+ AS_HELP_STRING([--disable-vde_over_ns],
|
||||
+ [Disable vde_over_ns compilation]),
|
||||
+ [if test $enableval = "no" ; then add_over_ns_support=no ; warn_over_ns=no ; fi])
|
||||
|
||||
# Check of tuntap device
|
||||
AC_ARG_ENABLE([tuntap],
|
||||
@@ -212,6 +225,7 @@
|
||||
|
||||
|
||||
AM_CONDITIONAL(ENABLE_CRYPTCAB, test "$add_cryptcab_support" = yes)
|
||||
+AM_CONDITIONAL(ENABLE_VDE_OVER_NS, test "$add_over_ns_support" = yes)
|
||||
AM_CONDITIONAL(ENABLE_PYTHON, test "$enable_python" = yes)
|
||||
AM_CONDITIONAL(ENABLE_PCAP, test "$add_pcap" = yes)
|
||||
AM_CONDITIONAL(CAN_MAKE_LIBVDETAP, test "$can_make_libvdetap" = yes)
|
||||
@@ -307,6 +321,14 @@
|
||||
fi
|
||||
fi
|
||||
|
||||
+if ! test x$add_over_ns_support = "xyes" ; then
|
||||
+ if test x$warn_over_ns = "xyes" ; then
|
||||
+ AC_MSG_WARN([VDE vde_over_ns support has been disabled because your libc
|
||||
+ sysexits.h could not be found.])
|
||||
+ AS_ECHO
|
||||
+ fi
|
||||
+fi
|
||||
+
|
||||
if ! test x$enable_python = "xyes" ; then
|
||||
AC_MSG_WARN([Python libraries support has been disabled because python is
|
||||
not installed on your system, or because it could not be found. Please install
|
||||
|
||||
diff --git a/vde-2/src/Makefile.am b/vde-2/src/Makefile.am
|
||||
index 49f8b78..8f79680 100644
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -29,6 +29,10 @@
|
||||
|
||||
if ENABLE_CRYPTCAB
|
||||
SUBDIRS += vde_cryptcab
|
||||
+endif
|
||||
+
|
||||
+if ENABLE_VDE_OVER_NS
|
||||
+ SUBDIRS += vde_over_ns
|
||||
endif
|
||||
|
||||
if ENABLE_KERNEL_SWITCH
|
||||
|
||||
diff --git a/vde-2/src/lib/libvdeplug.c b/vde-2/src/lib/libvdeplug.c
|
||||
index aa76b6a..e3623d9 100644
|
||||
--- a/src/lib/libvdeplug.c
|
||||
+++ b/src/lib/libvdeplug.c
|
||||
@@ -189,10 +189,10 @@
|
||||
}
|
||||
} else {
|
||||
char *split;
|
||||
- if((split = strstr(given_sockname,"->")) != NULL && rindex(split,':') != NULL)
|
||||
+ if((split = strstr(given_sockname,"->")) != NULL && strrchr(split,':') != NULL)
|
||||
flags |= VDEFLAG_UDP_SOCKET;
|
||||
else if(given_sockname[strlen(given_sockname)-1] == ']'
|
||||
- && (split=rindex(given_sockname,'[')) != NULL) {
|
||||
+ && (split=strrchr(given_sockname,'[')) != NULL) {
|
||||
*split=0;
|
||||
split++;
|
||||
port=atoi(split);
|
||||
@@ -282,14 +282,14 @@
|
||||
hints.ai_socktype=SOCK_DGRAM;
|
||||
*dst=0;
|
||||
dst+=2;
|
||||
- dstport=rindex(dst,':');
|
||||
+ dstport=strrchr(dst,':');
|
||||
if (dstport==NULL) {
|
||||
errno=EINVAL;
|
||||
goto abort;
|
||||
}
|
||||
*dstport=0;
|
||||
dstport++;
|
||||
- srcport=rindex(src,':');
|
||||
+ srcport=strrchr(src,':');
|
||||
if (srcport==NULL) {
|
||||
srcport=src;
|
||||
src=NULL;
|
||||
diff --git a/vde-2/src/vde_l3/vde_l3.c b/vde-2/src/vde_l3/vde_l3.c
|
||||
index 3c4f72e..6a63467 100644
|
||||
--- a/src/vde_l3/vde_l3.c
|
||||
+++ b/src/vde_l3/vde_l3.c
|
||||
@@ -40,7 +40,7 @@
|
||||
#define MAXCMD 255
|
||||
#define DEBUG 0
|
||||
|
||||
-#if defined(VDE_FREEBSD) || defined(VDE_DARWIN)
|
||||
+#if defined(VDE_FREEBSD) || defined(VDE_DARWIN) || defined(VDE_BIONIC)
|
||||
#define ICMP_DEST_UNREACH 3
|
||||
#define ICMP_PROT_UNREACH 2
|
||||
#endif
|
||||
diff --git a/vde-2/src/vde_plug2tap.c b/vde-2/src/vde_plug2tap.c
|
||||
index 02b2d58..c769353 100644
|
||||
--- a/src/vde_plug2tap.c
|
||||
+++ b/src/vde_plug2tap.c
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#define BUFSIZE 2048
|
||||
|
||||
-#ifdef VDE_LINUX
|
||||
+#if defined VDE_LINUX || defined VDE_BIONIC
|
||||
#include <net/if.h>
|
||||
#include <linux/if_tun.h>
|
||||
#endif
|
||||
@@ -112,7 +112,7 @@ static void setsighandlers()
|
||||
{ SIGUSR2, "SIGUSR2", 1 },
|
||||
{ SIGPROF, "SIGPROF", 1 },
|
||||
{ SIGVTALRM, "SIGVTALRM", 1 },
|
||||
-#ifdef VDE_LINUX
|
||||
+#if defined VDE_LINUX || defined VDE_BIONIC
|
||||
{ SIGPOLL, "SIGPOLL", 1 },
|
||||
#ifdef SIGSTKFLT
|
||||
{ SIGSTKFLT, "SIGSTKFLT", 1 },
|
||||
@@ -172,6 +172,29 @@ int open_tap(char *dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
+#ifdef VDE_BIONIC
|
||||
+int open_tap(char *dev)
|
||||
+{
|
||||
+ struct ifreq ifr;
|
||||
+ int fd;
|
||||
+
|
||||
+ if((fd = open("/dev/tun", O_RDWR)) < 0){
|
||||
+ printlog(LOG_ERR,"Failed to open /dev/tun %s",strerror(errno));
|
||||
+ return(-1);
|
||||
+ }
|
||||
+ memset(&ifr, 0, sizeof(ifr));
|
||||
+ ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
|
||||
+ strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1);
|
||||
+ /*printf("dev=\"%s\", ifr.ifr_name=\"%s\"\n", ifr.ifr_name, dev);*/
|
||||
+ if(ioctl(fd, TUNSETIFF, (void *) &ifr) < 0){
|
||||
+ printlog(LOG_ERR,"TUNSETIFF failed %s",strerror(errno));
|
||||
+ close(fd);
|
||||
+ return(-1);
|
||||
+ }
|
||||
+ return(fd);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
#if defined(VDE_DARWIN) || defined(VDE_FREEBSD)
|
||||
int open_tap(char *dev)
|
||||
{
|
||||
diff --git a/vde-2/src/vde_switch/port.c b/vde-2/src/vde_switch/port.c
|
||||
index 94c5660..f86897c 100644
|
||||
--- a/src/vde_switch/port.c
|
||||
+++ b/src/vde_switch/port.c
|
||||
@@ -188,6 +188,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
+#ifdef VDE_BIONIC
|
||||
+ static inline int user_belongs_to_group(uid_t uid, gid_t gid) { return 0; }
|
||||
+#else
|
||||
/* 1 if user belongs to the group, 0 otherwise) */
|
||||
static int user_belongs_to_group(uid_t uid, gid_t gid)
|
||||
{
|
||||
@@ -216,6 +219,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
|
||||
|
||||
/* Access Control check:
|
||||
diff --git a/vde-2/src/vde_switch/tuntap.c b/vde-2/src/vde_switch/tuntap.c
|
||||
index 9f3c0a2..59f3501 100644
|
||||
--- a/src/vde_switch/tuntap.c
|
||||
+++ b/src/vde_switch/tuntap.c
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#ifdef HAVE_TUNTAP
|
||||
|
||||
-#ifdef VDE_LINUX
|
||||
+#if defined(VDE_LINUX) || defined(VDE_BIONIC)
|
||||
#include <net/if.h>
|
||||
#include <linux/if_tun.h>
|
||||
#endif
|
||||
@@ -152,6 +152,29 @@
|
||||
}
|
||||
return outc;
|
||||
}
|
||||
+
|
||||
+#ifdef VDE_BIONIC
|
||||
+int open_tap(char *dev)
|
||||
+{
|
||||
+ struct ifreq ifr;
|
||||
+ int fd;
|
||||
+
|
||||
+ if((fd = open("/dev/tun", O_RDWR)) < 0){
|
||||
+ printlog(LOG_ERR,"Failed to open /dev/tun %s",strerror(errno));
|
||||
+ return(-1);
|
||||
+ }
|
||||
+ memset(&ifr, 0, sizeof(ifr));
|
||||
+ ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
|
||||
+ strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1);
|
||||
+ /*printf("dev=\"%s\", ifr.ifr_name=\"%s\"\n", ifr.ifr_name, dev);*/
|
||||
+ if(ioctl(fd, TUNSETIFF, (void *) &ifr) < 0){
|
||||
+ printlog(LOG_ERR,"TUNSETIFF failed %s",strerror(errno));
|
||||
+ close(fd);
|
||||
+ return(-1);
|
||||
+ }
|
||||
+ return(fd);
|
||||
+}
|
||||
+#endif
|
||||
|
||||
#ifdef VDE_LINUX
|
||||
int open_tap(char *dev)
|
||||
|
||||
diff --git a/vde-2/src/vdetaplib/libvdetap.c b/vde-2/src/vdetaplib/libvdetap.c
|
||||
index 00cd401..910811c 100644
|
||||
--- a/src/vdetaplib/libvdetap.c
|
||||
+++ b/src/vdetaplib/libvdetap.c
|
||||
@@ -154,7 +154,12 @@
|
||||
return "";
|
||||
}
|
||||
|
||||
+
|
||||
+#ifdef VDE_BIONIC
|
||||
+int ioctl(int fd, int command, ...)
|
||||
+#else
|
||||
int ioctl(int fd, unsigned long int command, ...)
|
||||
+#endif
|
||||
{
|
||||
va_list ap;
|
||||
char *data;
|
@ -0,0 +1,92 @@
|
||||
--- a/src/vde_cryptcab/cryptcab.c 2011-11-23 16:41:17.000000000 +0000
|
||||
+++ b/src/vde_cryptcab/cryptcab.c 2017-03-20 22:54:20.452975075 +0000
|
||||
@@ -22,7 +22,7 @@
|
||||
exit(1);
|
||||
}
|
||||
|
||||
-static EVP_CIPHER_CTX ctx;
|
||||
+static EVP_CIPHER_CTX *ctx;
|
||||
static int ctx_initialized = 0;
|
||||
static int encryption_disabled = 0;
|
||||
static int nfd;
|
||||
@@ -30,6 +30,10 @@
|
||||
static struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700};
|
||||
static int verbose = 0;
|
||||
|
||||
+#if OPENSSL_VERSION_NUMBER < 0x10100000
|
||||
+#define EVP_CIPHER_CTX_reset(x) EVP_CIPHER_CTX_cleanup(x)
|
||||
+#endif
|
||||
+
|
||||
void vc_printlog(int priority, const char *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
@@ -103,19 +107,21 @@
|
||||
}
|
||||
|
||||
if (!ctx_initialized) {
|
||||
- EVP_CIPHER_CTX_init (&ctx);
|
||||
+ ctx = EVP_CIPHER_CTX_new ();
|
||||
+ if (!ctx)
|
||||
+ return -1;
|
||||
ctx_initialized = 1;
|
||||
}
|
||||
|
||||
- EVP_EncryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv);
|
||||
- if (EVP_EncryptUpdate (&ctx, dst, &olen, src, len) != 1)
|
||||
+ EVP_EncryptInit (ctx, EVP_bf_cbc (), p->key, p->iv);
|
||||
+ if (EVP_EncryptUpdate (ctx, dst, &olen, src, len) != 1)
|
||||
{
|
||||
fprintf (stderr,"error in encrypt update\n");
|
||||
olen = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
- if (EVP_EncryptFinal (&ctx, dst + olen, &tlen) != 1)
|
||||
+ if (EVP_EncryptFinal (ctx, dst + olen, &tlen) != 1)
|
||||
{
|
||||
fprintf (stderr,"error in encrypt final\n");
|
||||
olen = -1;
|
||||
@@ -124,7 +130,7 @@
|
||||
olen += tlen;
|
||||
|
||||
cleanup:
|
||||
- EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
+ EVP_CIPHER_CTX_reset(ctx);
|
||||
return olen;
|
||||
}
|
||||
|
||||
@@ -138,19 +144,21 @@
|
||||
}
|
||||
|
||||
if (!ctx_initialized) {
|
||||
- EVP_CIPHER_CTX_init (&ctx);
|
||||
+ ctx = EVP_CIPHER_CTX_new ();
|
||||
+ if (!ctx)
|
||||
+ return -1;
|
||||
ctx_initialized = 1;
|
||||
}
|
||||
|
||||
- EVP_DecryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv);
|
||||
- if (EVP_DecryptUpdate (&ctx, dst, &olen, src, len) != 1)
|
||||
+ EVP_DecryptInit (ctx, EVP_bf_cbc (), p->key, p->iv);
|
||||
+ if (EVP_DecryptUpdate (ctx, dst, &olen, src, len) != 1)
|
||||
{
|
||||
fprintf (stderr,"error in decrypt update\n");
|
||||
olen = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
- if (EVP_DecryptFinal (&ctx, dst + olen, &tlen) != 1)
|
||||
+ if (EVP_DecryptFinal (ctx, dst + olen, &tlen) != 1)
|
||||
{
|
||||
fprintf (stderr,"error in decrypt final\n");
|
||||
olen = -1;
|
||||
@@ -159,7 +167,7 @@
|
||||
olen += tlen;
|
||||
|
||||
cleanup:
|
||||
- EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
+ EVP_CIPHER_CTX_reset (ctx);
|
||||
return olen;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user