2016-07-05 07:59:40

by Wang Shilong

[permalink] [raw]
Subject: [PATCH] quota: fix coredump if projid file dose not exist

From: Wang Shilong <[email protected]>

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 <[email protected]>
---
quotasys.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

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 */
--
2.7.4



2016-07-06 10:03:44

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH] quota: fix coredump if projid file dose not exist

On Tue 05-07-16 16:00:40, Wang Shilong wrote:
> From: Wang Shilong <[email protected]>
>
> 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 <[email protected]>

Thanks. I've merged the patch.

Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR