diff options
Diffstat (limited to 'include/cutils/properties.h')
-rw-r--r-- | include/cutils/properties.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/include/cutils/properties.h b/include/cutils/properties.h index 25fd67a..2c70165 100644 --- a/include/cutils/properties.h +++ b/include/cutils/properties.h @@ -17,6 +17,10 @@ #ifndef __CUTILS_PROPERTIES_H #define __CUTILS_PROPERTIES_H +#include <sys/cdefs.h> +#include <stddef.h> +#include <sys/system_properties.h> + #ifdef __cplusplus extern "C" { #endif @@ -28,8 +32,8 @@ extern "C" { ** WARNING: system/bionic/include/sys/system_properties.h also defines ** these, but with different names. (TODO: fix that) */ -#define PROPERTY_KEY_MAX 32 -#define PROPERTY_VALUE_MAX 92 +#define PROPERTY_KEY_MAX PROP_NAME_MAX +#define PROPERTY_VALUE_MAX PROP_VALUE_MAX /* property_get: returns the length of the value which will never be ** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated. @@ -46,6 +50,22 @@ 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"); +__errordecl(__property_get_too_small_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 /* |