From d51820e8dea4f5bd9d06ff22335bead7409864b2 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Fri, 6 Apr 2012 09:53:45 -0700 Subject: [PATCH] dumpstate: don't follow symlinks when creating /data/anr/traces.txt Make Android more robust against symlink attacks when /data/anr is world-writable. Bug: 5614000 Change-Id: I9a7e4c4ec9aa4300ac30a968db0dcd276f364ab6 --- cmds/dumpstate/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c index 25505f818..45565052a 100644 --- a/cmds/dumpstate/utils.c +++ b/cmds/dumpstate/utils.c @@ -383,7 +383,7 @@ const char *dump_vm_traces() { } /* create a new, empty traces.txt file to receive stack dumps */ - int fd = open(traces_path, O_CREAT | O_WRONLY | O_TRUNC, 0666); /* -rw-rw-rw- */ + int fd = open(traces_path, O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW, 0666); /* -rw-rw-rw- */ if (fd < 0) { fprintf(stderr, "%s: %s\n", traces_path, strerror(errno)); return NULL;