summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2013-02-01 23:18:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-02-01 23:18:39 +0000
commitcc62beebffc4f7df7073411fbba776e3a4bc27eb (patch)
tree88455491e1a839ace707b445b87dfe48b75e7c50
parentef89911ed69ebde624d661f22c01e5d243869fb1 (diff)
parent75cc88546b893280add608becfd5887470573813 (diff)
downloadsystem_core-cc62beebffc4f7df7073411fbba776e3a4bc27eb.zip
system_core-cc62beebffc4f7df7073411fbba776e3a4bc27eb.tar.gz
system_core-cc62beebffc4f7df7073411fbba776e3a4bc27eb.tar.bz2
Merge "property_get: do argument checking."
-rw-r--r--include/cutils/properties.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/cutils/properties.h b/include/cutils/properties.h
index 25fd67a..5ec8c2c 100644
--- a/include/cutils/properties.h
+++ b/include/cutils/properties.h
@@ -17,6 +17,9 @@
#ifndef __CUTILS_PROPERTIES_H
#define __CUTILS_PROPERTIES_H
+#include <sys/cdefs.h>
+#include <stddef.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -62,6 +65,23 @@ enum {
};
#endif /*HAVE_SYSTEM_PROPERTY_SERVER*/
+#ifdef __BIONIC_FORTIFY_INLINE
+
+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 = __builtin_object_size(value, 0);
+ if (bos < PROPERTY_VALUE_MAX) {
+ __property_get_too_small_error();
+ }
+ return __property_get_real(key, value, default_value);
+}
+
+#endif /* __BIONIC_FORTIFY_INLINE */
#ifdef __cplusplus
}