[PATCH] Verify the file header magic before importing DLF

Anton Lundin glance at acc.umu.se
Mon Dec 29 07:18:20 PST 2014


Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 parse-xml.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/parse-xml.c b/parse-xml.c
index 7393429..9629800 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -2541,6 +2541,10 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size)
 
 	target_table = &dive_table;
 
+	// Check for the correct file magic
+	if (ptr[0] != 'D' || ptr[1] != 'i' || ptr[2] != 'v' || ptr[3] != 'E')
+		return -1;
+
 	dive_start();
 	divecomputer_start();
 
-- 
2.1.0



More information about the subsurface mailing list