| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The following is the C version of code from base/process_utils_linux.cc. | 5 // The following is the C version of code from base/process_utils_linux.cc. | 
| 6 // We shouldn't link against C++ code in a setuid binary. | 6 // We shouldn't link against C++ code in a setuid binary. | 
| 7 | 7 | 
|  | 8 #include "sandbox/linux/suid/process_util.h" | 
|  | 9 | 
| 8 #define _GNU_SOURCE  // needed for O_DIRECTORY | 10 #define _GNU_SOURCE  // needed for O_DIRECTORY | 
| 9 | 11 | 
| 10 #include "process_util.h" |  | 
| 11 |  | 
| 12 #include <fcntl.h> | 12 #include <fcntl.h> | 
| 13 #include <inttypes.h> | 13 #include <inttypes.h> | 
| 14 #include <limits.h> | 14 #include <limits.h> | 
| 15 #include <stdio.h> | 15 #include <stdio.h> | 
| 16 #include <stdlib.h> | 16 #include <stdlib.h> | 
| 17 #include <string.h> | 17 #include <string.h> | 
| 18 #include <sys/stat.h> | 18 #include <sys/stat.h> | 
| 19 #include <sys/types.h> | 19 #include <sys/types.h> | 
| 20 #include <unistd.h> | 20 #include <unistd.h> | 
| 21 | 21 | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 66   close(dirfd); | 66   close(dirfd); | 
| 67 | 67 | 
| 68   char buf[11];  // 0 <= |score| <= kMaxOomScore; using log_10(2**32) + 1 size | 68   char buf[11];  // 0 <= |score| <= kMaxOomScore; using log_10(2**32) + 1 size | 
| 69   snprintf(buf, sizeof(buf), "%d", score); | 69   snprintf(buf, sizeof(buf), "%d", score); | 
| 70   size_t len = strlen(buf); | 70   size_t len = strlen(buf); | 
| 71 | 71 | 
| 72   ssize_t bytes_written = write(fd, buf, len); | 72   ssize_t bytes_written = write(fd, buf, len); | 
| 73   close(fd); | 73   close(fd); | 
| 74   return (bytes_written == len); | 74   return (bytes_written == len); | 
| 75 } | 75 } | 
| OLD | NEW | 
|---|