From 7410616cd9dbbec97cf98d75324da5cda2b2f7a2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 30 Apr 2015 20:21:00 +0200 Subject: core: rework unit name validation and manipulation logic A variety of changes: - Make sure all our calls distuingish OOM from other errors if OOM is not the only error possible. - Be much stricter when parsing escaped paths, do not accept trailing or leading escaped slashes. - Change unit validation to take a bit mask for allowing plain names, instance names or template names or an combination thereof. - Refuse manipulating invalid unit name --- src/journal/journalctl.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/journal') diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 666aa20480..627e43ba35 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1135,9 +1135,9 @@ static int add_units(sd_journal *j) { STRV_FOREACH(i, arg_system_units) { _cleanup_free_ char *u = NULL; - u = unit_name_mangle(*i, MANGLE_GLOB); - if (!u) - return log_oom(); + r = unit_name_mangle(*i, UNIT_NAME_GLOB, &u); + if (r < 0) + return r; if (string_is_glob(u)) { r = strv_push(&patterns, u); @@ -1181,9 +1181,9 @@ static int add_units(sd_journal *j) { STRV_FOREACH(i, arg_user_units) { _cleanup_free_ char *u = NULL; - u = unit_name_mangle(*i, MANGLE_GLOB); - if (!u) - return log_oom(); + r = unit_name_mangle(*i, UNIT_NAME_GLOB, &u); + if (r < 0) + return r; if (string_is_glob(u)) { r = strv_push(&patterns, u); @@ -1840,9 +1840,8 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; r = add_units(j); - strv_free(arg_system_units); - strv_free(arg_user_units); - + arg_system_units = strv_free(arg_system_units); + arg_user_units = strv_free(arg_user_units); if (r < 0) { log_error_errno(r, "Failed to add filter for units: %m"); return EXIT_FAILURE; -- cgit v1.2.3-54-g00ecf