From 4b13704cbec7249ba223608143026142b8729318 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Thu, 13 Jan 2005 03:35:29 +0100 Subject: [PATCH] Fix crash when /proc/acpi/ac_adapter/ is not present, for instance, on pre-ACPI and non-Linux systems. --- e2fsck/ChangeLog | 6 ++++++ e2fsck/unix.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 0fff501..fb48f11 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,9 @@ +2005-01-13 Matthias Andree + + * unix.c: Do not call closedir if the handle is zero, to avoid + crashes when the /proc/acpi/ac_adapter directory is + missing, for instance on non-ACPI or non-Linux systems. + 2005-01-09 Theodore Ts'o * pass1b.c: As part of converting configure.in from using the diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 7e55f87..43a64b5 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -238,7 +238,8 @@ static int is_on_batt(void) return 1; } } - closedir(d); + if (d) + closedir(d); return 0; } -- 1.8.3.1