Merge pull request #5417 from pks-t/pks/ntlmclient-htonll deps: ntlmclient: fix missing htonll symbols on FreeBSD and SunOS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/deps/ntlmclient/compat.h b/deps/ntlmclient/compat.h
index efdf345..43bc865 100644
--- a/deps/ntlmclient/compat.h
+++ b/deps/ntlmclient/compat.h
@@ -22,8 +22,30 @@
#endif
#ifdef __linux__
+/* See man page endian(3) */
# include <endian.h>
# define htonll htobe64
+#elif defined(__OpenBSD__)
+/* See man page htobe64(3) */
+# include <endian.h>
+# define htonll htobe64
+#elif defined(__FreeBSD__)
+/* See man page bwaps64(9) */
+# include <sys/endian.h>
+# define htonll bswap64
+#elif defined(sun) || defined(__sun)
+/* See man page byteorder(3SOCKET) */
+# include <sys/types.h>
+# include <netinet/in.h>
+# include <inttypes.h>
+
+# if !defined(htonll)
+# if defined(_BIG_ENDIAN)
+# define htonll(x) (x)
+# else
+# define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl((uint64_t)(x) >> 32))
+# endif
+# endif
#endif
#ifndef MIN
diff --git a/src/transports/auth_ntlm.c b/src/transports/auth_ntlm.c
index 02a861f..d134a3d 100644
--- a/src/transports/auth_ntlm.c
+++ b/src/transports/auth_ntlm.c
@@ -50,10 +50,10 @@ static int ntlm_set_credentials(http_auth_ntlm_context *ctx, git_credential *_cr
cred = (git_credential_userpass_plaintext *)_cred;
if ((sep = strchr(cred->username, '\\')) != NULL) {
- domain = strndup(cred->username, (sep - cred->username));
+ domain = git__strndup(cred->username, (sep - cred->username));
GIT_ERROR_CHECK_ALLOC(domain);
- domainuser = strdup(sep + 1);
+ domainuser = git__strdup(sep + 1);
GIT_ERROR_CHECK_ALLOC(domainuser);
username = domainuser;