From 687aef13911c14cca8fc4711b27e7c8b52a204ad Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Tue, 31 Jul 2012 16:28:11 +0100 Subject: [PATCH] Add a simple safety check to avoid crashes, currently I do not do full file check (MD5, etc...) but this will catch most problems. --- src/epgdb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/epgdb.c b/src/epgdb.c index 43843044..69eb7d84 100644 --- a/src/epgdb.c +++ b/src/epgdb.c @@ -179,6 +179,12 @@ void epg_init ( void ) int msglen = (rp[0] << 24) | (rp[1] << 16) | (rp[2] << 8) | rp[3]; remain -= 4; rp += 4; + + /* Safety check */ + if (msglen > remain) { + tvhlog(LOG_ERR, "epgdb", "corruption detected, some/all data lost"); + break; + } /* Extract message */ htsmsg_t *m = htsmsg_binary_deserialize(rp, msglen, NULL);