Return when invalid config ID was provided through adb command and
change the separator of config_uid and config_id to underscore from dash
to disambiguate negative config ids

Bug: 73896814
Test: statsd_test
Change-Id: Ib0604e9f4c104560d570a64208a9e94d7526f8d6
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index 26db3af..bf6cee7 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -423,6 +423,13 @@
             }
 
             if (args[1] == "update") {
+                char* endp;
+                int64_t configID = strtoll(name.c_str(), &endp, 10);
+                if (endp == name.c_str() || *endp != '\0') {
+                    fprintf(err, "Error parsing config ID.\n");
+                    return UNKNOWN_ERROR;
+                }
+
                 // Read stream into buffer.
                 string buffer;
                 if (!android::base::ReadFdToString(fileno(in), &buffer)) {
@@ -438,7 +445,7 @@
                 }
 
                 // Add / update the config.
-                mConfigManager->UpdateConfig(ConfigKey(uid, StrToInt64(name)), config);
+                mConfigManager->UpdateConfig(ConfigKey(uid, configID), config);
             } else {
                 if (argCount == 2) {
                     cmd_remove_all_configs(out);