Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: sandbox/linux/suid/process_util_linux.c

Issue 1538283002: Switch to standard integer types in sandbox/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: macros Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/linux/suid/process_util.h ('k') | sandbox/linux/suid/sandbox.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Needed for O_DIRECTORY, must be defined before fcntl.h is included 8 // Needed for O_DIRECTORY, must be defined before fcntl.h is included
9 // (and it can be included earlier than the explicit #include below 9 // (and it can be included earlier than the explicit #include below
10 // in some versions of glibc). 10 // in some versions of glibc).
11 #define _GNU_SOURCE 11 #define _GNU_SOURCE
12 12
13 #include "sandbox/linux/suid/process_util.h" 13 #include "sandbox/linux/suid/process_util.h"
14 14
15 #include <fcntl.h> 15 #include <fcntl.h>
16 #include <inttypes.h> 16 #include <inttypes.h>
17 #include <limits.h> 17 #include <limits.h>
18 #include <stddef.h>
18 #include <stdio.h> 19 #include <stdio.h>
19 #include <stdlib.h> 20 #include <stdlib.h>
20 #include <string.h> 21 #include <string.h>
21 #include <sys/stat.h> 22 #include <sys/stat.h>
22 #include <sys/types.h> 23 #include <sys/types.h>
23 #include <unistd.h> 24 #include <unistd.h>
24 25
25 // Ranges for the current (oom_score_adj) and previous (oom_adj) 26 // Ranges for the current (oom_score_adj) and previous (oom_adj)
26 // flavors of OOM score. 27 // flavors of OOM score.
27 static const int kMaxOomScore = 1000; 28 static const int kMaxOomScore = 1000;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 close(dirfd); 70 close(dirfd);
70 71
71 char buf[11]; // 0 <= |score| <= kMaxOomScore; using log_10(2**32) + 1 size 72 char buf[11]; // 0 <= |score| <= kMaxOomScore; using log_10(2**32) + 1 size
72 snprintf(buf, sizeof(buf), "%d", score); 73 snprintf(buf, sizeof(buf), "%d", score);
73 size_t len = strlen(buf); 74 size_t len = strlen(buf);
74 75
75 ssize_t bytes_written = write(fd, buf, len); 76 ssize_t bytes_written = write(fd, buf, len);
76 close(fd); 77 close(fd);
77 return (bytes_written == (ssize_t)len); 78 return (bytes_written == (ssize_t)len);
78 } 79 }
OLDNEW
« no previous file with comments | « sandbox/linux/suid/process_util.h ('k') | sandbox/linux/suid/sandbox.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698