diff options
| author | Colin Cross <ccross@android.com> | 2013-01-29 14:58:57 -0800 |
|---|---|---|
| committer | Colin Cross <ccross@android.com> | 2013-06-17 16:58:02 -0700 |
| commit | a5a860ef20cc5e65d4fa9b57cd72231f63f6d316 (patch) | |
| tree | 455fc158ed467838eee33686f7e89a04453bf168 | |
| parent | 993b6ceeb05677229dee60f1a68c2102c205a7bd (diff) | |
| download | system_core-a5a860ef20cc5e65d4fa9b57cd72231f63f6d316.zip system_core-a5a860ef20cc5e65d4fa9b57cd72231f63f6d316.tar.gz system_core-a5a860ef20cc5e65d4fa9b57cd72231f63f6d316.tar.bz2 | |
init: verify size of property buffers passed to property_get
Verify that the buffer passed as the value parameter to property_get
is always big enough.
(cherry picked from commit 88ac54a4e8d2a63e4fd9c465e115795ace316776)
Change-Id: Iacc2b42bfe4069e0bfcbb1c48474f30126a93139
| -rwxr-xr-x | init/property_service.c | 2 | ||||
| -rw-r--r-- | init/property_service.h | 18 |
2 files changed, 18 insertions, 2 deletions
diff --git a/init/property_service.c b/init/property_service.c index cd4d3c7..86e35f1 100755 --- a/init/property_service.c +++ b/init/property_service.c @@ -265,7 +265,7 @@ static int check_perms(const char *name, unsigned int uid, unsigned int gid, cha return 0; } -int property_get(const char *name, char value[PROP_VALUE_MAX]) +int __property_get(const char *name, char *value) { return __system_property_get(name, value); } diff --git a/init/property_service.h b/init/property_service.h index b08c118..46cbd8f 100644 --- a/init/property_service.h +++ b/init/property_service.h @@ -26,9 +26,25 @@ extern void property_load_boot_defaults(void); extern void load_persist_props(void); extern void start_property_service(void); void get_property_workspace(int *fd, int *sz); -extern int property_get(const char *name, char value[PROP_VALUE_MAX]); +extern int __property_get(const char *name, char *value); extern int property_set(const char *name, const char *value); extern int properties_inited(); int get_property_set_fd(void); +extern void __property_get_size_error() + __attribute__((__error__("property_get called with too small buffer"))); + +static inline +__attribute__ ((always_inline)) +__attribute__ ((gnu_inline)) +__attribute__ ((artificial)) +int property_get(const char *name, char *value) +{ + size_t value_len = __builtin_object_size(value, 0); + if (value_len != PROP_VALUE_MAX) + __property_get_size_error(); + + return __property_get(name, value); +} + #endif /* _INIT_PROPERTY_H */ |
