[hackers] [ubase] Check setmntent() for failures || sin

From: <git_AT_suckless.org>
Date: Sat, 15 Feb 2014 19:27:50 +0100

commit 3bb0f0fbdde37789ee51e718225cbd278e9167f9
Author: sin <sin_AT_2f30.org>
Date: Sat Feb 15 18:26:01 2014 +0000

    Check setmntent() for failures

diff --git a/swapoff.c b/swapoff.c
index 806d1f0..2d2b7ac 100644
--- a/swapoff.c
+++ b/swapoff.c
_AT_@ -36,6 +36,8 @@ main(int argc, char *argv[])
                 FILE *fp;
 
                 fp = setmntent("/etc/fstab", "r");
+ if (!fp)
+ eprintf("setmntent %s:", "/etc/fstab");
                 while ((me = getmntent(fp)) != NULL) {
                         if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0) {
                                 if (swapoff(me->mnt_fsname) < 0) {
diff --git a/swapon.c b/swapon.c
index 40e6c9f..6b3d32f 100644
--- a/swapon.c
+++ b/swapon.c
_AT_@ -43,6 +43,8 @@ main(int argc, char *argv[])
                 FILE *fp;
 
                 fp = setmntent("/etc/fstab", "r");
+ if (!fp)
+ eprintf("setmntent %s:", "/etc/fstab");
                 while ((me = getmntent(fp)) != NULL) {
                         if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0
                             && (hasmntopt(me, MNTOPT_NOAUTO) == NULL)) {
Received on Sat Feb 15 2014 - 19:27:50 CET

This archive was generated by hypermail 2.3.0 : Sat Feb 15 2014 - 19:36:24 CET