]> git.proxmox.com Git - mirror_kronosnet.git/commitdiff
Use the preprocessor to reference all remapped zlib symbols in the canary
authorFerenc Wágner <wferi@debian.org>
Fri, 10 Nov 2017 16:10:59 +0000 (17:10 +0100)
committerFerenc Wágner <wferi@debian.org>
Sun, 12 Nov 2017 15:17:24 +0000 (16:17 +0100)
libknet/Makefile.am
libknet/compress_canary.c
libknet/compress_zlib.c
libknet/compress_zlib_remap.h [new file with mode: 0644]
libknet/remap.h [new file with mode: 0644]

index 18cbb82fdeee720c97af866a86b1f8b847819faf..747af0bc6aa26fef98514484326078300efb864d 100644 (file)
@@ -60,11 +60,12 @@ noinst_HEADERS              = \
                          common.h \
                          compat.h \
                          compress.h \
-                         compress_zlib.h \
                          compress_lz4.h \
                          compress_lzo2.h \
                          compress_lzma.h \
                          compress_bzip2.h \
+                         compress_zlib.h \
+                         compress_zlib_remap.h \
                          crypto.h \
                          crypto_nss.h \
                          crypto_openssl.h \
@@ -74,6 +75,7 @@ noinst_HEADERS                = \
                          logging.h \
                          netutils.h \
                          onwire.h \
+                         remap.h \
                          threads_common.h \
                          threads_dsthandler.h \
                          threads_heartbeat.h \
index 9cdf6d534c8f295eea6723e91b7f34658a77c0b6..a9088c617c8be5b4efc34d620119dc8916d5582f 100644 (file)
@@ -4,11 +4,15 @@
 
 #include "config.h"
 
+#define CANARY
+
 char BZ2_bzBuffToBuffCompress(void);
 char LZ4_compress_HC(void);
 char lzma_easy_buffer_encode(void);
 char lzo1x_1_compress(void);
-char compress2(void);
+#include "compress_zlib_remap.h"
+
+#define CANARY_CALL
 
 int main (void)
 {
@@ -26,7 +30,7 @@ int main (void)
     lzo1x_1_compress() +
 #endif
 #ifdef BUILDCOMPZLIB
-    compress2() +
+#include "compress_zlib_remap.h"
 #endif
     0;
 }
index 8623db8ace047dac307b2cebdede4f5dbeeee0bb..f384b4d61fecbbd44ef1837b330a962337b00f21 100644 (file)
  */
 static void *zlib_lib;
 
-/*
- * symbols remapping
- */
-int (*_int_uncompress)(Bytef *dest, uLongf *destLen,
-                      const Bytef *source, uLong sourceLen);
-int (*_int_compress2)(Bytef *dest, uLongf *destLen,
-                     const Bytef *source, uLong sourceLen,
-                     int level);
+#include "compress_zlib_remap.h"
 
 static int zlib_remap_symbols(knet_handle_t knet_h)
 {
diff --git a/libknet/compress_zlib_remap.h b/libknet/compress_zlib_remap.h
new file mode 100644 (file)
index 0000000..7ff16e6
--- /dev/null
@@ -0,0 +1,9 @@
+#include "remap.h"
+
+REMAP_PROTO(int,uncompress,
+           (Bytef *dest, uLongf *destLen,
+            const Bytef *source, uLong sourceLen))
+REMAP_PROTO(int,compress2,
+           (Bytef *dest, uLongf *destLen,
+            const Bytef *source, uLong sourceLen,
+            int level))
diff --git a/libknet/remap.h b/libknet/remap.h
new file mode 100644 (file)
index 0000000..03ccf79
--- /dev/null
@@ -0,0 +1,16 @@
+/* Repeated inclusions define this differently */
+#undef REMAP_PROTO
+
+#ifdef CANARY
+
+/* Canary uses fake prototype to make "calls" uniform */
+#ifdef CANARY_CALL
+#define REMAP_PROTO(ret,name,args) name() +
+#else
+#define REMAP_PROTO(ret,name,args) char name(void);
+#endif /* CANARY_CALL */
+
+#else
+#define REMAP_PROTO(ret,name,args) ret (*_int_ ## name)args;
+
+#endif /* CANARY */