tdecacqu / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
46a556f
From 7802260b72f064fedf744f1071cd80123c3499d4 Mon Sep 17 00:00:00 2001
46a556f
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
46a556f
Date: Wed, 11 Sep 2013 21:50:16 -0400
46a556f
Subject: [PATCH] Allow tabs in environment files
46a556f
46a556f
bash allows them, and so should we.
46a556f
46a556f
string_has_cc is changed to allow tabs, and if they are not wanted,
46a556f
they must be now checked for explicitly. There are two other callers,
46a556f
apart from the env file loaders, and one already checked anyway, and
46a556f
the other is changed to check.
46a556f
46a556f
https://bugs.freedesktop.org/show_bug.cgi?id=68592
46a556f
https://bugs.gentoo.org/show_bug.cgi?id=481554
46a556f
46a556f
Conflicts:
46a556f
	src/test/test-fileio.c
46a556f
---
46a556f
 src/hostname/hostnamed.c | 3 ++-
46a556f
 src/shared/util.c        | 4 ++++
46a556f
 2 files changed, 6 insertions(+), 1 deletion(-)
46a556f
46a556f
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
46a556f
index 0437e33..6a43aeb 100644
46a556f
--- a/src/hostname/hostnamed.c
46a556f
+++ b/src/hostname/hostnamed.c
46a556f
@@ -553,7 +553,8 @@ static DBusHandlerResult hostname_message_handler(
46a556f
                                  * safe than sorry */
46a556f
                                 if (k == PROP_ICON_NAME && !filename_is_safe(name))
46a556f
                                         return bus_send_error_reply(connection, message, NULL, -EINVAL);
46a556f
-                                if (k == PROP_PRETTY_HOSTNAME && string_has_cc(name))
46a556f
+                                if (k == PROP_PRETTY_HOSTNAME &&
46a556f
+                                    (string_has_cc(name) || chars_intersect(name, "\t")))
46a556f
                                         return bus_send_error_reply(connection, message, NULL, -EINVAL);
46a556f
                                 if (k == PROP_CHASSIS && !valid_chassis(name))
46a556f
                                         return bus_send_error_reply(connection, message, NULL, -EINVAL);
46a556f
diff --git a/src/shared/util.c b/src/shared/util.c
46a556f
index 7f633a3..acf4ca2 100644
46a556f
--- a/src/shared/util.c
46a556f
+++ b/src/shared/util.c
46a556f
@@ -5328,6 +5328,10 @@ bool string_is_safe(const char *p) {
46a556f
         return true;
46a556f
 }
46a556f
 
46a556f
+/**
46a556f
+ * Check if a string contains control characters.
46a556f
+ * Spaces and tabs are not considered control characters.
46a556f
+ */
46a556f
 bool string_has_cc(const char *p) {
46a556f
         const char *t;
46a556f