summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIngo Bürk <admin@airblader.de>2017-03-08 22:25:51 +0100
committerGitHub <noreply@github.com>2017-03-08 22:25:51 +0100
commit554db9fcc1f92d480a99d2d1e06d2285e4e4738f (patch)
tree8b8fff8b05dfbab21a86e0ad5c481f674d110840 /src
parent37e73e77b0514993cd386a5d12509c88dddba5ed (diff)
parent27952b11f736a7dc1fb4e27a1251481d4f71c751 (diff)
Merge pull request #207 from stapelberg/disk_info
disk: sanitize trailing slashes
Diffstat (limited to 'src')
-rw-r--r--src/print_disk_info.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/print_disk_info.c b/src/print_disk_info.c
index d343fb8..3be81ea 100644
--- a/src/print_disk_info.c
+++ b/src/print_disk_info.c
@@ -141,16 +141,20 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch
* we consider the device not mounted. */
mounted = false;
} else {
+ char *sanitized = sstrdup(path);
+ if (sanitized[strlen(sanitized) - 1] == '/')
+ sanitized[strlen(sanitized) - 1] = '\0';
FILE *mntentfile = setmntent("/etc/mtab", "r");
struct mntent *m;
while ((m = getmntent(mntentfile)) != NULL) {
- if (strcmp(m->mnt_dir, path) == 0) {
+ if (strcmp(m->mnt_dir, sanitized) == 0) {
mounted = true;
break;
}
}
endmntent(mntentfile);
+ free(sanitized);
}
#endif