chiark / gitweb /
Fix capability logging when effective caps are 0
[elogind.git] / src / shared / fileio.c
index 23bc742e75ad71c0674d3345cf580aa0fb693331..8aa4cdbf053c18f02bc4c7b964cf81ae355c0fa0 100644 (file)
@@ -677,7 +677,13 @@ 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.
          */
-        t += strspn(t, WHITESPACE "0");
+        if (*t) {
+                t += strspn(t, WHITESPACE "0");
+                /* Back off one char if there's nothing but whitespace
+                   and zeros */
+                if (!*t)
+                        t --;
+        }
 
         len = strcspn(t, WHITESPACE);