X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Ffileio.c;h=8aa4cdbf053c18f02bc4c7b964cf81ae355c0fa0;hb=4ec29144ddc311d78baa6875631ed6968fd90817;hp=23bc742e75ad71c0674d3345cf580aa0fb693331;hpb=72fd713962ca2c2450e23b01d9e22017a7e28fd4;p=elogind.git diff --git a/src/shared/fileio.c b/src/shared/fileio.c index 23bc742e7..8aa4cdbf0 100644 --- a/src/shared/fileio.c +++ b/src/shared/fileio.c @@ -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);