[PATCH fstools] libfstools: avoid segfault in find_mount_point

Stijn Tintel stijn at linux-ipv6.be
Tue Dec 21 09:39:10 PST 2021


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 at linux-ipv6.be>
---
 libfstools/find.c | 3 +++
 1 file changed, 3 insertions(+)

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;
 
-- 
2.32.0




More information about the openwrt-devel mailing list