Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // For linux_syscall_support.h. This makes it safe to call embedded system | 5 // For linux_syscall_support.h. This makes it safe to call embedded system |
| 6 // calls when in seccomp mode. | 6 // calls when in seccomp mode. |
| 7 | 7 |
| 8 #include "components/crash/app/breakpad_linux.h" | 8 #include "components/crash/app/breakpad_linux.h" |
| 9 | 9 |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 963 char pid_buf[kUint64StringSize]; | 963 char pid_buf[kUint64StringSize]; |
| 964 uint64_t pid_str_length = my_uint64_len(info.pid); | 964 uint64_t pid_str_length = my_uint64_len(info.pid); |
| 965 my_uint64tos(pid_buf, info.pid, pid_str_length); | 965 my_uint64tos(pid_buf, info.pid, pid_str_length); |
| 966 pid_buf[pid_str_length] = '\0'; | 966 pid_buf[pid_str_length] = '\0'; |
| 967 | 967 |
| 968 char uid_buf[kUint64StringSize]; | 968 char uid_buf[kUint64StringSize]; |
| 969 uid_t uid = geteuid(); | 969 uid_t uid = geteuid(); |
| 970 uint64_t uid_str_length = my_uint64_len(uid); | 970 uint64_t uid_str_length = my_uint64_len(uid); |
| 971 my_uint64tos(uid_buf, uid, uid_str_length); | 971 my_uint64tos(uid_buf, uid, uid_str_length); |
| 972 uid_buf[uid_str_length] = '\0'; | 972 uid_buf[uid_str_length] = '\0'; |
| 973 | |
| 974 size_t buf_len = my_strlen(dumpfile); | |
| 975 char* chrome_flag = reinterpret_cast<char*>(allocator->Alloc(buf_len + 10)); | |
|
vapier
2014/10/13 19:50:50
this is C++ code, so why not just use std::string
stevefung
2014/10/13 20:15:13
I believe we can't use it, because this code runs
| |
| 976 my_strlcat(chrome_flag, "--chrome=", 9); | |
|
Lei Zhang
2014/10/10 19:11:47
I think strlcat takes the size of the dest buffer,
stevefung
2014/10/13 22:28:39
Done.
| |
| 977 my_strlcat(chrome_flag + 9, dumpfile, buf_len); | |
| 978 | |
| 979 buf_len = my_strlen(pid_buf); | |
| 980 char* pid_flag = reinterpret_cast<char*>(allocator->Alloc(buf_len + 7)); | |
| 981 my_strlcat(pid_flag, "--pid=", 6); | |
| 982 my_strlcat(pid_flag + 6, pid_buf, buf_len); | |
| 983 | |
| 984 buf_len = my_strlen(uid_buf); | |
| 985 char* uid_flag = reinterpret_cast<char*>(allocator->Alloc(buf_len + 7)); | |
| 986 my_strlcat(uid_flag, "--uid=", 6); | |
| 987 my_strlcat(uid_flag + 6, uid_buf, buf_len); | |
| 988 | |
| 989 buf_len = my_strlen(exe_buf); | |
| 990 char* exe_flag = reinterpret_cast<char*>(allocator->Alloc(buf_len + 7)); | |
| 991 my_strlcat(exe_flag, "--exe=", 6); | |
| 992 my_strlcat(exe_flag + 6, exe_buf, buf_len); | |
| 993 | |
| 973 const char* args[] = { | 994 const char* args[] = { |
| 974 kCrashReporterBinary, | 995 kCrashReporterBinary, |
| 975 "--chrome", | 996 chrome_flag, |
| 976 dumpfile, | 997 pid_flag, |
| 977 "--pid", | 998 uid_flag, |
| 978 pid_buf, | 999 exe_flag, |
| 979 "--uid", | |
| 980 uid_buf, | |
| 981 "--exe", | |
| 982 exe_buf, | |
| 983 NULL, | 1000 NULL, |
| 984 }; | 1001 }; |
| 985 static const char msg[] = "Cannot upload crash dump: cannot exec " | 1002 static const char msg[] = "Cannot upload crash dump: cannot exec " |
| 986 "/sbin/crash_reporter\n"; | 1003 "/sbin/crash_reporter\n"; |
| 987 #else | 1004 #else |
| 988 // The --header argument to wget looks like: | 1005 // The --header argument to wget looks like: |
| 989 // --header=Content-Type: multipart/form-data; boundary=XYZ | 1006 // --header=Content-Type: multipart/form-data; boundary=XYZ |
| 990 // where the boundary has two fewer leading '-' chars | 1007 // where the boundary has two fewer leading '-' chars |
| 991 static const char header_msg[] = | 1008 static const char header_msg[] = |
| 992 "--header=Content-Type: multipart/form-data; boundary="; | 1009 "--header=Content-Type: multipart/form-data; boundary="; |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1614 } | 1631 } |
| 1615 } | 1632 } |
| 1616 } | 1633 } |
| 1617 #endif // OS_ANDROID | 1634 #endif // OS_ANDROID |
| 1618 | 1635 |
| 1619 bool IsCrashReporterEnabled() { | 1636 bool IsCrashReporterEnabled() { |
| 1620 return g_is_crash_reporter_enabled; | 1637 return g_is_crash_reporter_enabled; |
| 1621 } | 1638 } |
| 1622 | 1639 |
| 1623 } // namespace breakpad | 1640 } // namespace breakpad |
| OLD | NEW |