From ae763c3f58b8585a051510375e4914caa3f4f478 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 17 Sep 2012 21:26:06 +0200 Subject: [PATCH] Verify the header in the logbook and profile are identical. Unless we have a bug in the logbook processing logic, both logbook headers should always be identical. But it doesn't hurt to check explicitly. --- src/hw_frog.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/hw_frog.c b/src/hw_frog.c index b9db582..a7992ac 100644 --- a/src/hw_frog.c +++ b/src/hw_frog.c @@ -455,6 +455,15 @@ hw_frog_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void return rc; } + // Verify the header in the logbook and profile are identical. + if (memcmp (profile, header + offset, RB_LOGBOOK_SIZE) != 0) { + ERROR (abstract->context, "Unexpected profile header."); + free (profile); + free (header); + return rc; + + } + if (callback && !callback (profile, length, profile + 9, sizeof (device->fingerprint), userdata)) break; }