OSDN Git Service

Revert "libc: make system properties more secure."
authorNick Kralevich <nnk@google.com>
Tue, 22 Jan 2013 20:44:11 +0000 (12:44 -0800)
committerNick Kralevich <nnk@google.com>
Tue, 22 Jan 2013 20:44:11 +0000 (12:44 -0800)
This reverts commit f10c5a2215b3da2e226e8bd148c86e2c146d8e90.

Bug: 8045561

libc/bionic/system_properties.c
libc/include/sys/_system_properties.h

index 8e53acc..caa5ca6 100644 (file)
@@ -31,7 +31,6 @@
 #include <stddef.h>
 #include <errno.h>
 #include <poll.h>
-#include <fcntl.h>
 
 #include <sys/mman.h>
 
@@ -39,7 +38,6 @@
 #include <sys/un.h>
 #include <sys/select.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <netinet/in.h>
 #include <unistd.h>
 
@@ -57,34 +55,33 @@ prop_area *__system_property_area__ = (void*) &dummy_props;
 int __system_properties_init(void)
 {
     prop_area *pa;
-    int fd;
-    struct stat fd_stat;
+    int s, fd;
+    unsigned sz;
+    char *env;
 
     if(__system_property_area__ != ((void*) &dummy_props)) {
         return 0;
     }
 
-    fd = open(PROP_FILENAME, O_RDONLY | O_NOFOLLOW);
-
-    if (fd < 0) {
+    env = getenv("ANDROID_PROPERTY_WORKSPACE");
+    if (!env) {
         return -1;
     }
-
-    if (fstat(fd, &fd_stat) < 0) {
-        close(fd);
+    fd = atoi(env);
+    env = strchr(env, ',');
+    if (!env) {
         return -1;
     }
-
-    pa = mmap(0, fd_stat.st_size, PROT_READ, MAP_SHARED, fd, 0);
-
-    close(fd);
+    sz = atoi(env + 1);
+    
+    pa = mmap(0, sz, PROT_READ, MAP_SHARED, fd, 0);
     
     if(pa == MAP_FAILED) {
         return -1;
     }
 
     if((pa->magic != PROP_AREA_MAGIC) || (pa->version != PROP_AREA_VERSION)) {
-        munmap(pa, fd_stat.st_size);
+        munmap(pa, sz);
         return -1;
     }
 
@@ -221,6 +218,8 @@ static int send_prop_msg(prop_msg *msg)
 int __system_property_set(const char *key, const char *value)
 {
     int err;
+    int tries = 0;
+    int update_seen = 0;
     prop_msg msg;
 
     if(key == 0) return -1;
index 10c0fae..42a7f6c 100644 (file)
@@ -41,7 +41,6 @@ typedef struct prop_msg prop_msg;
 #define PROP_AREA_VERSION 0x45434f76
 
 #define PROP_SERVICE_NAME "property_service"
-#define PROP_FILENAME "/dev/__properties__"
 
 /* #define PROP_MAX_ENTRIES 247 */
 /* 247 -> 32620 bytes (<32768) */