update_engine: check type when reading Services property of
connection manager.

Before reading the first element of the Services array, verify that the
value is, in fact, an array of the correct type. This prevents a crash in
the case where the new connection manager (shill) sends the Services as an
array of D-Bus strings, rather than an array of D-Bus object paths.

BUG=chromium-os:27987
TEST=manual, unit tests

Manual testing: ran image_to_live with DUT running flimflam and shill. With
flimflam, update_engine behaves as before patch. With shill, the patch
resolves a crash that would occur when copying the first element of the
Services property into |out_path|.

Change-Id: I4e1d02b5ae471dce9d8b87a0c7a4f2d859c88df7
Reviewed-on: https://gerrit.chromium.org/gerrit/18508
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: mukesh agrawal <quiche@chromium.org>
Commit-Ready: mukesh agrawal <quiche@chromium.org>
diff --git a/dbus_interface.h b/dbus_interface.h
index ec266b5..24ed7c4 100644
--- a/dbus_interface.h
+++ b/dbus_interface.h
@@ -11,6 +11,16 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
+#ifndef DBUS_TYPE_G_OBJECT_PATH_ARRAY
+#define DBUS_TYPE_G_OBJECT_PATH_ARRAY \
+  (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
+#endif
+
+#ifndef DBUS_TYPE_G_STRING_ARRAY
+#define DBUS_TYPE_G_STRING_ARRAY \
+  (dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING))
+#endif
+
 namespace chromeos_update_engine {
 
 class DbusGlibInterface {