aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-03-19 07:57:16 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-03-19 07:57:26 +0100
commit10c09f98b2c29516aa5f71d7f9dc0e24145baccc (patch)
treed0f8f271c69c9ff66ad9a4f37b48f4abd8024a48
parent601327be8ca971895bef8f3e5cdde86ca220e8d6 (diff)
parent8752b5c882fb94f223b117153bdac024f1dfb25f (diff)
downloadbitcoin-10c09f98b2c29516aa5f71d7f9dc0e24145baccc.tar.xz
Merge pull request #5926
8752b5c 0.10 fix for crashes on OSX 10.6 (Cory Fields)
-rw-r--r--src/compat.h4
-rw-r--r--src/compat/strnlen.cpp7
-rw-r--r--src/protocol.cpp2
3 files changed, 5 insertions, 8 deletions
diff --git a/src/compat.h b/src/compat.h
index dffd4ecf52..477dd2bfeb 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -88,8 +88,6 @@ typedef u_int SOCKET;
#define THREAD_PRIORITY_ABOVE_NORMAL (-2)
#endif
-#if HAVE_DECL_STRNLEN == 0
-size_t strnlen( const char *start, size_t max_len);
-#endif // HAVE_DECL_STRNLEN
+size_t strnlen_int( const char *start, size_t max_len);
#endif // BITCOIN_COMPAT_H
diff --git a/src/compat/strnlen.cpp b/src/compat/strnlen.cpp
index 7f3e159887..7dafd98c0b 100644
--- a/src/compat/strnlen.cpp
+++ b/src/compat/strnlen.cpp
@@ -7,12 +7,11 @@
#endif
#include <cstring>
-
-#if HAVE_DECL_STRNLEN == 0
-size_t strnlen( const char *start, size_t max_len)
+// OSX 10.6 is missing strnlen at runtime, but builds targetting it will still
+// succeed. Define our own version here to avoid a crash.
+size_t strnlen_int( const char *start, size_t max_len)
{
const char *end = (const char *)memchr(start, '\0', max_len);
return end ? (size_t)(end - start) : max_len;
}
-#endif // HAVE_DECL_STRNLEN
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 72fdd753a8..f03d6e7589 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -40,7 +40,7 @@ CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSize
std::string CMessageHeader::GetCommand() const
{
- return std::string(pchCommand, pchCommand + strnlen(pchCommand, COMMAND_SIZE));
+ return std::string(pchCommand, pchCommand + strnlen_int(pchCommand, COMMAND_SIZE));
}
bool CMessageHeader::IsValid() const