Update talk to 59410372.
R=jiayl@webrtc.org, wu@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/6929004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5367 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/base/asyncsocket.h b/talk/base/asyncsocket.h
index 97859a7..2854558 100644
--- a/talk/base/asyncsocket.h
+++ b/talk/base/asyncsocket.h
@@ -27,6 +27,7 @@
#ifndef TALK_BASE_ASYNCSOCKET_H_
#define TALK_BASE_ASYNCSOCKET_H_
+#ifndef __native_client__
#include "talk/base/common.h"
#include "talk/base/sigslot.h"
@@ -138,4 +139,5 @@
} // namespace talk_base
+#endif // __native_client__
#endif // TALK_BASE_ASYNCSOCKET_H_
diff --git a/talk/base/byteorder.h b/talk/base/byteorder.h
index c6d0dbb..cf26a12 100644
--- a/talk/base/byteorder.h
+++ b/talk/base/byteorder.h
@@ -28,7 +28,7 @@
#ifndef TALK_BASE_BYTEORDER_H_
#define TALK_BASE_BYTEORDER_H_
-#ifdef POSIX
+#if defined(POSIX) && !defined(__native_client__)
#include <arpa/inet.h>
#endif
diff --git a/talk/base/logging.cc b/talk/base/logging.cc
index 4c7eae1..c1d0a53 100644
--- a/talk/base/logging.cc
+++ b/talk/base/logging.cc
@@ -349,6 +349,9 @@
}
#endif // WIN32
+ LogToDebug(debug_level);
+
+#if !defined(__native_client__) // No logging to file in NaCl.
scoped_ptr<FileStream> stream;
if (NO_LOGGING != file_level) {
stream.reset(new FileStream);
@@ -357,8 +360,8 @@
}
}
- LogToDebug(debug_level);
LogToStream(stream.release(), file_level);
+#endif
}
int LogMessage::ParseLogSeverity(const std::string& value) {
diff --git a/talk/base/logging.h b/talk/base/logging.h
index 49e126b..01636e8 100644
--- a/talk/base/logging.h
+++ b/talk/base/logging.h
@@ -376,6 +376,13 @@
LOG_GLE(sev)
#define LAST_SYSTEM_ERROR \
(::GetLastError())
+#elif __native_client__
+#define LOG_ERR_EX(sev, err) \
+ LOG(sev)
+#define LOG_ERR(sev) \
+ LOG(sev)
+#define LAST_SYSTEM_ERROR \
+ (0)
#elif POSIX
#define LOG_ERR_EX(sev, err) \
LOG_ERRNO_EX(sev, err)
diff --git a/talk/base/messagedigest.cc b/talk/base/messagedigest.cc
index d91d067..975991d 100644
--- a/talk/base/messagedigest.cc
+++ b/talk/base/messagedigest.cc
@@ -70,6 +70,19 @@
#endif
}
+bool IsFips180DigestAlgorithm(const std::string& alg) {
+ // These are the FIPS 180 algorithms. According to RFC 4572 Section 5,
+ // "Self-signed certificates (for which legacy certificates are not a
+ // consideration) MUST use one of the FIPS 180 algorithms (SHA-1,
+ // SHA-224, SHA-256, SHA-384, or SHA-512) as their signature algorithm,
+ // and thus also MUST use it to calculate certificate fingerprints."
+ return alg == DIGEST_SHA_1 ||
+ alg == DIGEST_SHA_224 ||
+ alg == DIGEST_SHA_256 ||
+ alg == DIGEST_SHA_384 ||
+ alg == DIGEST_SHA_512;
+}
+
size_t ComputeDigest(MessageDigest* digest, const void* input, size_t in_len,
void* output, size_t out_len) {
digest->Update(input, in_len);
diff --git a/talk/base/messagedigest.h b/talk/base/messagedigest.h
index 734082b..e8f303f 100644
--- a/talk/base/messagedigest.h
+++ b/talk/base/messagedigest.h
@@ -60,6 +60,9 @@
static MessageDigest* Create(const std::string& alg);
};
+// A whitelist of approved digest algorithms from RFC 4572 (FIPS 180).
+bool IsFips180DigestAlgorithm(const std::string& alg);
+
// Functions to create hashes.
// Computes the hash of |in_len| bytes of |input|, using the |digest| hash
diff --git a/talk/base/messagequeue.cc b/talk/base/messagequeue.cc
index 15b700f..64e63ae 100644
--- a/talk/base/messagequeue.cc
+++ b/talk/base/messagequeue.cc
@@ -32,8 +32,13 @@
#include "talk/base/common.h"
#include "talk/base/logging.h"
#include "talk/base/messagequeue.h"
+#if defined(__native_client__)
+#include "talk/base/nullsocketserver.h"
+typedef talk_base::NullSocketServer DefaultSocketServer;
+#else
#include "talk/base/physicalsocketserver.h"
-
+typedef talk_base::PhysicalSocketServer DefaultSocketServer;
+#endif
namespace talk_base {
@@ -129,7 +134,7 @@
// server, and provide it to the MessageQueue, since the Thread controls
// the I/O model, and MQ is agnostic to those details. Anyway, this causes
// messagequeue_unittest to depend on network libraries... yuck.
- default_ss_.reset(new PhysicalSocketServer());
+ default_ss_.reset(new DefaultSocketServer());
ss_ = default_ss_.get();
}
ss_->SetMessageQueue(this);
diff --git a/talk/base/socket.h b/talk/base/socket.h
index e738060..56e3ebc 100644
--- a/talk/base/socket.h
+++ b/talk/base/socket.h
@@ -28,6 +28,14 @@
#ifndef TALK_BASE_SOCKET_H__
#define TALK_BASE_SOCKET_H__
+#if defined(__native_client__)
+namespace talk_base {
+// These should never be defined or instantiated.
+class Socket;
+class AsyncSocket;
+} // namespace talk_base
+#else
+
#include <errno.h>
#ifdef POSIX
@@ -199,4 +207,5 @@
} // namespace talk_base
+#endif // !__native_client__
#endif // TALK_BASE_SOCKET_H__
diff --git a/talk/base/sslfingerprint.h b/talk/base/sslfingerprint.h
index b857789..0dfcdd9 100644
--- a/talk/base/sslfingerprint.h
+++ b/talk/base/sslfingerprint.h
@@ -65,7 +65,7 @@
static SSLFingerprint* CreateFromRfc4572(const std::string& algorithm,
const std::string& fingerprint) {
- if (algorithm.empty())
+ if (algorithm.empty() || !talk_base::IsFips180DigestAlgorithm(algorithm))
return NULL;
if (fingerprint.empty())
diff --git a/talk/base/stream.cc b/talk/base/stream.cc
index b6b48f1..02ae409 100644
--- a/talk/base/stream.cc
+++ b/talk/base/stream.cc
@@ -711,7 +711,7 @@
}
}
-#ifdef POSIX
+#if defined(POSIX) && !defined(__native_client__)
// Have to identically rewrite the FileStream destructor or else it would call
// the base class's Close() instead of the sub-class's.
diff --git a/talk/base/stream.h b/talk/base/stream.h
index d30be29..fceb4a8 100644
--- a/talk/base/stream.h
+++ b/talk/base/stream.h
@@ -28,6 +28,8 @@
#ifndef TALK_BASE_STREAM_H_
#define TALK_BASE_STREAM_H_
+#include <stdio.h>
+
#include "talk/base/basictypes.h"
#include "talk/base/buffer.h"
#include "talk/base/criticalsection.h"
@@ -497,7 +499,6 @@
size_t read_segment_available_;
};
-
// A stream which pushes writes onto a separate thread and
// returns from the write call immediately.
class AsyncWriteStream : public StreamInterface {
@@ -539,7 +540,7 @@
};
-#ifdef POSIX
+#if defined(POSIX) && !defined(__native_client__)
// A FileStream that is actually not a file, but the output or input of a
// sub-command. See "man 3 popen" for documentation of the underlying OS popen()
// function.
diff --git a/talk/base/unixfilesystem.cc b/talk/base/unixfilesystem.cc
index 3c8f4d2..1a5b75e 100644
--- a/talk/base/unixfilesystem.cc
+++ b/talk/base/unixfilesystem.cc
@@ -50,7 +50,6 @@
#include <limits.h>
#include <pwd.h>
#include <stdio.h>
-#include <unistd.h>
#endif // POSIX && !OSX
#if defined(LINUX)
@@ -368,6 +367,8 @@
if (success)
path->SetPathname(path8);
return success;
+#elif defined(__native_client__)
+ return false;
#else // OSX
char buffer[NAME_MAX+1];
size_t len = readlink("/proc/self/exe", buffer, ARRAY_SIZE(buffer) - 1);
@@ -453,6 +454,7 @@
if (!CreateFolder(*path, 0700)) {
return false;
}
+#if !defined(__native_client__)
// If the folder already exists, it may have the wrong mode or be owned by
// someone else, both of which are security problems. Setting the mode
// avoids both issues since it will fail if the path is not owned by us.
@@ -460,6 +462,7 @@
LOG_ERR(LS_ERROR) << "Can't set mode on " << path;
return false;
}
+#endif
return true;
}
@@ -553,3 +556,11 @@
}
} // namespace talk_base
+
+#if defined(__native_client__)
+extern "C" int __attribute__((weak))
+link(const char* oldpath, const char* newpath) {
+ errno = EACCES;
+ return -1;
+}
+#endif