diff options
author | Nick Kralevich <nnk@google.com> | 2013-05-23 10:01:42 -0700 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2013-05-23 11:05:16 -0700 |
commit | 0e54ec825e6eae234a486c2049039fb6986a39b8 (patch) | |
tree | 86af7cef94213c8818dbbd0f60c22751d628dcd2 /include/cutils | |
parent | 53df3ade9bacce57099bb9eeb2a34bb5945d463e (diff) | |
download | system_core-0e54ec825e6eae234a486c2049039fb6986a39b8.zip system_core-0e54ec825e6eae234a486c2049039fb6986a39b8.tar.gz system_core-0e54ec825e6eae234a486c2049039fb6986a39b8.tar.bz2 |
property_get: do argument checking.
Try to verify, at compile time, that the supplied
value buffer is large enough.
Change-Id: I91fa560d3ceff87609194269356ac634bdbf2ede
Diffstat (limited to 'include/cutils')
-rw-r--r-- | include/cutils/properties.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/cutils/properties.h b/include/cutils/properties.h index 7e4ed93..228b73e 100644 --- a/include/cutils/properties.h +++ b/include/cutils/properties.h @@ -17,6 +17,8 @@ #ifndef __CUTILS_PROPERTIES_H #define __CUTILS_PROPERTIES_H +#include <sys/cdefs.h> +#include <stddef.h> #include <sys/system_properties.h> #ifdef __cplusplus @@ -48,6 +50,23 @@ int property_set(const char *key, const char *value); int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie); +#if defined(__BIONIC_FORTIFY) + +extern int __property_get_real(const char *, char *, const char *) + __asm__(__USER_LABEL_PREFIX__ "property_get"); +extern void __property_get_too_small_error() + __attribute__((__error__("property_get() called with too small of a buffer"))); + +__BIONIC_FORTIFY_INLINE +int property_get(const char *key, char *value, const char *default_value) { + size_t bos = __bos(value); + if (bos < PROPERTY_VALUE_MAX) { + __property_get_too_small_error(); + } + return __property_get_real(key, value, default_value); +} + +#endif #ifdef HAVE_SYSTEM_PROPERTY_SERVER /* |