lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230121203230.27624-7-ebiggers@kernel.org>
Date:   Sat, 21 Jan 2023 12:31:58 -0800
From:   Eric Biggers <ebiggers@...nel.org>
To:     linux-ext4@...r.kernel.org
Subject: [PATCH 06/38] lib, misc: eliminate dependency on Winsock

From: Eric Biggers <ebiggers@...gle.com>

Currently Windows builds of e2fsprogs rely on the Windows Socket API
(Winsock) to provide htonl() and ntohl().  For this to actually work,
though, HAVE_WINSOCK_H needs to be defined, and the binaries need to be
linked to -lws2_32.  The Android.bp files do this; however, the
autotools-based build system does not.

Since htonl() and ntohl() are trivial, let's instead just add a file
include/mingw/arpa/inet.h with definitions for these.

Signed-off-by: Eric Biggers <ebiggers@...gle.com>
---
 include/mingw/arpa/inet.h | 5 +++++
 lib/e2p/Android.bp        | 4 ----
 lib/ext2fs/Android.bp     | 2 --
 lib/ext2fs/jfs_compat.h   | 4 ----
 misc/Android.bp           | 1 -
 util/android_config.h     | 1 -
 6 files changed, 5 insertions(+), 12 deletions(-)
 create mode 100644 include/mingw/arpa/inet.h

diff --git a/include/mingw/arpa/inet.h b/include/mingw/arpa/inet.h
new file mode 100644
index 000000000..55dfa3691
--- /dev/null
+++ b/include/mingw/arpa/inet.h
@@ -0,0 +1,5 @@
+#pragma once
+
+/* Windows is always little endian. */
+#define htonl	__builtin_bswap32
+#define ntohl	__builtin_bswap32
diff --git a/lib/e2p/Android.bp b/lib/e2p/Android.bp
index 6f0620af0..050d869b3 100644
--- a/lib/e2p/Android.bp
+++ b/lib/e2p/Android.bp
@@ -59,10 +59,6 @@ cc_library {
                 "-Wno-unused-variable",
                 "-Wno-error=typedef-redefinition",
             ],
-
-            host_ldlibs: [
-                "-lws2_32",
-            ],
         },
     },
 
diff --git a/lib/ext2fs/Android.bp b/lib/ext2fs/Android.bp
index 365ca709f..eb4482d79 100644
--- a/lib/ext2fs/Android.bp
+++ b/lib/ext2fs/Android.bp
@@ -126,8 +126,6 @@ cc_library {
                 "-Wno-unused-variable",
                 "-Wno-error=typedef-redefinition",
             ],
-
-            host_ldlibs: ["-lws2_32"],
         },
     },
 
diff --git a/lib/ext2fs/jfs_compat.h b/lib/ext2fs/jfs_compat.h
index e11cf494e..0e96b56c1 100644
--- a/lib/ext2fs/jfs_compat.h
+++ b/lib/ext2fs/jfs_compat.h
@@ -7,11 +7,7 @@
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
-#ifdef HAVE_WINSOCK_H
-#include <winsock.h>
-#else
 #include <arpa/inet.h>
-#endif
 #include <stdbool.h>
 
 #define printk printf
diff --git a/misc/Android.bp b/misc/Android.bp
index 78e18e420..2baeac2ad 100644
--- a/misc/Android.bp
+++ b/misc/Android.bp
@@ -91,7 +91,6 @@ cc_binary {
                 "-Wno-error"
             ],
             ldflags: ["-static"],
-            host_ldlibs: ["-lws2_32"],
             enabled: true
         },
         android: {
diff --git a/util/android_config.h b/util/android_config.h
index 6ac16fec1..90b8f8a8f 100644
--- a/util/android_config.h
+++ b/util/android_config.h
@@ -36,7 +36,6 @@
 
 #if defined(_WIN32)
 # define HAVE_LINUX_TYPES_H 1
-# define HAVE_WINSOCK_H 1
 #endif
 #if defined(__APPLE__) || defined(__linux__)
 # define HAVE_FCNTL 1
-- 
2.39.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ