Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dereference on null pointer when fclosing hdl->libzfs_mnttab #4902

Closed
ColinIanKing opened this issue Jul 29, 2016 · 2 comments
Closed

dereference on null pointer when fclosing hdl->libzfs_mnttab #4902

ColinIanKing opened this issue Jul 29, 2016 · 2 comments

Comments

@ColinIanKing
Copy link
Contributor

libzfs_util.c, libzfs_init()

Currently there is no file open failure check when opening
/etc/dfs/sharetab. The NULL hdl->libzfs_sharelib file pointer
will lead to a null pointer deference when this is closed, for
example, in the case where libzfs_core_init() fails and the
subsequent cleanup closes hdl->libzfs_sharelib.

I'll send a patch to fix this issue shortly.

ColinIanKing pushed a commit to ColinIanKing/zfs that referenced this issue Jul 29, 2016
Currently there is no file open failure check when opening
/etc/dfs/sharetab.  The NULL hdl->libzfs_sharelib file pointer
will lead to a null pointer deference when this is closed, for
example, in the case where libzfs_core_init() fails and the
subsequent cleanup closes hdl->libzfs_sharelib.

Fix this by checking for an open failure and performing the
necessary clean up if it fails and return NULL.

Found by static analysis with CoverityScan 0.8.5

Closes openzfs#4902

Signed-off-by: Colin Ian King <colin.king@canonical.com>
@behlendorf
Copy link
Contributor

It's probably better to remove this entirely from libzfs_init() / libzfs_close(). It's only used in It's only ever used in is_shared() and it would be better to just handle the open/close there.

@behlendorf
Copy link
Contributor

Resolved by 2bac681.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants