summaryrefslogtreecommitdiffstats
path: root/chrome/browser/zygote_main_linux.cc
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 20:06:51 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 20:06:51 +0000
commit9debcda5ca7a1b952cebb342a845cb0be1bb94c4 (patch)
tree68ce98fc095bb1e151d0f4e23d776df21780a2fa /chrome/browser/zygote_main_linux.cc
parenta763b93742b0e753447be079ce5d097f2a7c2d68 (diff)
downloadchromium_src-9debcda5ca7a1b952cebb342a845cb0be1bb94c4.zip
chromium_src-9debcda5ca7a1b952cebb342a845cb0be1bb94c4.tar.gz
chromium_src-9debcda5ca7a1b952cebb342a845cb0be1bb94c4.tar.bz2
Linux: add support for tm_zone to localtime via the sandbox.
Glibc adds a field to struct tm, tm_zone, which contains a pointer to a string for the current time zone. Since this makes struct tm a non-POD data type, it only works for the non-thread-safe localtime() call, not localtime_r(). However, V8 relies on it so this patch adds support for passing it through our sandbox. BUG=17458 http://codereview.chromium.org/159216 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/zygote_main_linux.cc')
-rw-r--r--chrome/browser/zygote_main_linux.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/chrome/browser/zygote_main_linux.cc b/chrome/browser/zygote_main_linux.cc
index 3d3df87..e59946c 100644
--- a/chrome/browser/zygote_main_linux.cc
+++ b/chrome/browser/zygote_main_linux.cc
@@ -203,7 +203,8 @@ class Zygote {
// Patched dynamic symbol wrapper functions...
namespace sandbox_wrapper {
-void do_localtime(time_t input, struct tm* output) {
+void do_localtime(time_t input, struct tm* output, char* timezone_out,
+ size_t timezone_out_len) {
Pickle request;
request.WriteInt(LinuxSandbox::METHOD_LOCALTIME);
request.WriteString(
@@ -219,24 +220,34 @@ void do_localtime(time_t input, struct tm* output) {
Pickle reply(reinterpret_cast<char*>(reply_buf), r);
void* iter = NULL;
- std::string result;
+ std::string result, timezone;
if (!reply.ReadString(&iter, &result) ||
+ !reply.ReadString(&iter, &timezone) ||
result.size() != sizeof(struct tm)) {
memset(output, 0, sizeof(struct tm));
return;
}
memcpy(output, result.data(), sizeof(struct tm));
+ if (timezone_out_len) {
+ const size_t copy_len = std::min(timezone_out_len - 1, timezone.size());
+ memcpy(timezone_out, timezone.data(), copy_len);
+ timezone_out[copy_len] = 0;
+ output->tm_zone = timezone_out;
+ } else {
+ output->tm_zone = NULL;
+ }
}
struct tm* localtime(const time_t* timep) {
static struct tm time_struct;
- do_localtime(*timep, &time_struct);
+ static char timezone_string[64];
+ do_localtime(*timep, &time_struct, timezone_string, sizeof(timezone_string));
return &time_struct;
}
struct tm* localtime_r(const time_t* timep, struct tm* result) {
- do_localtime(*timep, result);
+ do_localtime(*timep, result, NULL, 0);
return result;
}