diff mbox series

[fstools] libfstools: avoid segfault in find_mount_point

Message ID 20211221173910.2405214-1-stijn@linux-ipv6.be
State Accepted
Delegated to: Stijn Tintel
Headers show
Series [fstools] libfstools: avoid segfault in find_mount_point | expand

Commit Message

Stijn Tintel Dec. 21, 2021, 5:39 p.m. UTC
If block is NULL, find_mount_point will segfault when comparing it
against the device name found in /proc/self/mountinfo. Avoid this by
checking if block is NULL.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
---
 libfstools/find.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/libfstools/find.c b/libfstools/find.c
index cefdd23..1d91c51 100644
--- a/libfstools/find.c
+++ b/libfstools/find.c
@@ -109,6 +109,9 @@  find_mount_point(char *block, int root_only)
 	int rstat;
 	unsigned int minor, major;
 
+	if (!block)
+		return NULL;
+
 	if (!fp)
 		return NULL;