[systemd-devel] [PATCH] Actually fix capability logging when effective caps are 0

Shawn Landden shawn at churchofgit.com
Thu Sep 19 08:59:37 PDT 2013


---
 src/shared/fileio.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/shared/fileio.c b/src/shared/fileio.c
index 01b803c..909a58f 100644
--- a/src/shared/fileio.c
+++ b/src/shared/fileio.c
@@ -662,6 +662,8 @@ int get_status_field(const char *filename, const char *pattern, char **field) {
 
         assert(filename);
         assert(field);
+        assert(pattern);
+        assert(strlen(pattern) >= 2);
 
         r = read_full_file(filename, &status, NULL);
         if (r < 0)
@@ -677,13 +679,11 @@ int get_status_field(const char *filename, const char *pattern, char **field) {
          * always maps to the same string, irrespective of the total
          * capability set size. For other numbers it shouldn't matter.
          */
-        if (*t) {
-                t += strspn(t, WHITESPACE "0");
-                /* Back off one char if there's nothing but whitespace
-                   and zeros */
-                if (!*t)
-                        t --;
-        }
+        t += strspn(t, WHITESPACE "0");
+        /* Back off to last '0' if there's nothing but whitespace
+           and zeros */
+        if (*(t - 1) == '\n')
+                t -= 2;
 
         len = strcspn(t, WHITESPACE);
 
-- 
1.8.4.rc3



More information about the systemd-devel mailing list