diff mbox

quota: fix coredump if projid file dose not exist

Message ID 1467702040-14764-1-git-send-email-wangshilong1991@gmail.com
State Not Applicable, archived
Headers show

Commit Message

Wang Shilong July 5, 2016, 7 a.m. UTC
From: Wang Shilong <wshilong@ddn.com>

if '/etc/projid' dose not exist,@project_file will
be NULL pointer, fclose will cause coredump, add
check in endprent().

Signed-off-by: Wang Shilong <wshilong@ddn.com>
---
 quotasys.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Jan Kara July 6, 2016, 9:44 a.m. UTC | #1
On Tue 05-07-16 16:00:40, Wang Shilong wrote:
> From: Wang Shilong <wshilong@ddn.com>
> 
> if '/etc/projid' dose not exist,@project_file will
> be NULL pointer, fclose will cause coredump, add
> check in endprent().
> 
> Signed-off-by: Wang Shilong <wshilong@ddn.com>

Thanks. I've merged the patch.

							Honza
diff mbox

Patch

diff --git a/quotasys.c b/quotasys.c
index c78e02c..d04f25a 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -98,8 +98,10 @@  void setprent(void)
 /* Close /etc/projid file */
 void endprent(void)
 {
-	fclose(project_file);
-	project_file = NULL;
+	if (project_file) {
+		fclose(project_file);
+		project_file = NULL;
+	}
 }
 
 /* Get next entry in /etc/projid */