libcutils: Use strnlen for default property values

Add unit tests to test the corner cases.

Test: unit tests pass before and after the change.
Change-Id: Idafeb8354cd6c7db2a68cd398dafe153453a3940
diff --git a/libcutils/properties.c b/libcutils/properties.c
index 69c6c7f..740c7a9 100644
--- a/libcutils/properties.c
+++ b/libcutils/properties.c
@@ -119,10 +119,7 @@
         return len;
     }
     if (default_value) {
-        len = strlen(default_value);
-        if (len >= PROPERTY_VALUE_MAX) {
-            len = PROPERTY_VALUE_MAX - 1;
-        }
+        len = strnlen(default_value, PROPERTY_VALUE_MAX - 1);
         memcpy(value, default_value, len);
         value[len] = '\0';
     }