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

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

Issue 10093005: Better check if argc is 0 because argv[0] is later used. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « AUTHORS ('k') | no next file » | 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 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandbox 5 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandbox
6 6
7 #define _GNU_SOURCE 7 #define _GNU_SOURCE
8 #include <asm/unistd.h> 8 #include <asm/unistd.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 374 }
375 375
376 free(saved_envvar); 376 free(saved_envvar);
377 } 377 }
378 378
379 return true; 379 return true;
380 } 380 }
381 381
382 int main(int argc, char **argv) { 382 int main(int argc, char **argv) {
383 if (argc <= 1) { 383 if (argc <= 1) {
384 if (argc == 0) {
385 return 1;
386 }
387
384 fprintf(stderr, "Usage: %s <renderer process> <args...>\n", argv[0]); 388 fprintf(stderr, "Usage: %s <renderer process> <args...>\n", argv[0]);
385 return 1; 389 return 1;
386 } 390 }
387 391
388 // In the SUID sandbox, if we succeed in calling MoveToNewNamespaces() 392 // In the SUID sandbox, if we succeed in calling MoveToNewNamespaces()
389 // below, then the zygote and all the renderers are in an alternate PID 393 // below, then the zygote and all the renderers are in an alternate PID
390 // namespace and do not know their real PIDs. As such, they report the wrong 394 // namespace and do not know their real PIDs. As such, they report the wrong
391 // PIDs to the task manager. 395 // PIDs to the task manager.
392 // 396 //
393 // To fix this, when the zygote spawns a new renderer, it gives the renderer 397 // To fix this, when the zygote spawns a new renderer, it gives the renderer
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (!DropRoot()) 436 if (!DropRoot())
433 return 1; 437 return 1;
434 if (!SetupChildEnvironment()) 438 if (!SetupChildEnvironment())
435 return 1; 439 return 1;
436 440
437 execv(argv[1], &argv[1]); 441 execv(argv[1], &argv[1]);
438 FatalError("execv failed"); 442 FatalError("execv failed");
439 443
440 return 1; 444 return 1;
441 } 445 }
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698