Merge "Don't read /data/local.prop on user builds"
diff --git a/init/util.c b/init/util.c
index 13c9ca2..cb00f84 100755
--- a/init/util.c
+++ b/init/util.c
@@ -129,11 +129,23 @@
char *data;
int sz;
int fd;
+ struct stat sb;
data = 0;
fd = open(fn, O_RDONLY);
if(fd < 0) return 0;
+ // for security reasons, disallow world-writable
+ // or group-writable files
+ if (fstat(fd, &sb) < 0) {
+ ERROR("fstat failed for '%s'\n", fn);
+ goto oops;
+ }
+ if ((sb.st_mode & (S_IWGRP | S_IWOTH)) != 0) {
+ ERROR("skipping insecure file '%s'\n", fn);
+ goto oops;
+ }
+
sz = lseek(fd, 0, SEEK_END);
if(sz < 0) goto oops;