From 1a8f1d96048f32e28ee6ff882c7b698ecf7f6193 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 2 Aug 2016 02:01:51 +0200 Subject: [PATCH] getfsent(): Read only six fields per line The fs.fs_type is only for *BSD, we hard-code it to "rw" in the meantime. Should be safe in most cases. Signed-off-by: Joachim Nilsson --- helpers.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/helpers.c b/helpers.c index 20ff68d0..5a66c20d 100644 --- a/helpers.c +++ b/helpers.c @@ -274,12 +274,15 @@ struct fstab *getfsent(void) static struct fstab fs; fs.fs_spec = lftok(fstab); + if (fs.fs_spec == NULL) + return NULL; + fs.fs_file = lftok(fstab); fs.fs_vfstype = lftok(fstab); fs.fs_mntops = lftok(fstab); - fs.fs_type = (const char *)lftok(fstab); - fs.fs_freq = atoi(lftok(fstab) ?: 0); - fs.fs_passno = atoi(lftok(fstab) ?: 0); + fs.fs_type = "rw"; + fs.fs_freq = atoi(lftok(fstab) ?: "0"); + fs.fs_passno = atoi(lftok(fstab) ?: "0"); return &fs; }