From 8e12ad8308742f0fd905c48d26c149b59349b6ee Mon Sep 17 00:00:00 2001 From: Kenneth Lyons Date: Fri, 10 Mar 2017 11:24:56 -0800 Subject: [PATCH] disk: don't remove trailing slash if path is a single character --- src/print_disk_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/print_disk_info.c b/src/print_disk_info.c index 3be81ea..fb73480 100644 --- a/src/print_disk_info.c +++ b/src/print_disk_info.c @@ -142,7 +142,7 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch mounted = false; } else { char *sanitized = sstrdup(path); - if (sanitized[strlen(sanitized) - 1] == '/') + if (strlen(sanitized) > 1 && sanitized[strlen(sanitized) - 1] == '/') sanitized[strlen(sanitized) - 1] = '\0'; FILE *mntentfile = setmntent("/etc/mtab", "r"); struct mntent *m; -- 2.39.5