Replace snprintf() with __libc_format_buffer()

If snprintf() is called from the linker, it may erroneously return a
null string.  The libc internal __libc_format_buffer() does not have
this problem, so it is now used instead.

Bug: 26756577

Change-Id: I37a97e27f59b3c0a087f54a6603cc3aff7f07522
diff --git a/libc/bionic/system_properties.cpp b/libc/bionic/system_properties.cpp
index 2720455..9c992da 100644
--- a/libc/bionic/system_properties.cpp
+++ b/libc/bionic/system_properties.cpp
@@ -753,7 +753,8 @@
     }
 
     char filename[PROP_FILENAME_MAX];
-    int len = snprintf(filename, sizeof(filename), "%s/%s", property_filename, context_);
+    int len = __libc_format_buffer(filename, sizeof(filename), "%s/%s",
+                                   property_filename, context_);
     if (len < 0 || len > PROP_FILENAME_MAX) {
         lock_.unlock();
         return false;
@@ -788,7 +789,8 @@
 
 bool context_node::check_access() {
     char filename[PROP_FILENAME_MAX];
-    int len = snprintf(filename, sizeof(filename), "%s/%s", property_filename, context_);
+    int len = __libc_format_buffer(filename, sizeof(filename), "%s/%s",
+                                   property_filename, context_);
     if (len < 0 || len > PROP_FILENAME_MAX) {
         return false;
     }
@@ -810,7 +812,8 @@
 
 static bool map_system_property_area(bool access_rw, bool* fsetxattr_failed) {
     char filename[PROP_FILENAME_MAX];
-    int len = snprintf(filename, sizeof(filename), "%s/properties_serial", property_filename);
+    int len = __libc_format_buffer(filename, sizeof(filename),
+                                   "%s/properties_serial", property_filename);
     if (len < 0 || len > PROP_FILENAME_MAX) {
         __system_property_area__ = nullptr;
         return false;