From d3cf85f44a01354575b3ab10b356f1bc423f0869 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Thu, 9 Apr 2015 17:33:34 +1000 Subject: [PATCH] * imdb-1to2 : db header check --- src/imdb-1to2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/imdb-1to2.c b/src/imdb-1to2.c index 775f227..c6231e5 100644 --- a/src/imdb-1to2.c +++ b/src/imdb-1to2.c @@ -46,6 +46,15 @@ int main(int argc, char **argv) { if ((st.st_size % IMDB_REC_LEN) != 0) usage("database size expected to be multiples to 48"); + if (lseek(in, 0, SEEK_SET) < 0) + usage(strerror(errno)); + + if (read(in, in_buf, IMDB_REC_LEN) != IMDB_REC_LEN) + usage("can't read header of database"); + + if (memcmp(in_buf, "DB of image fingerprints (ver 1)", 32) != 0) + usage("wrong database header / version mismatch"); + imdb_rec_total = (st.st_size / IMDB_REC_LEN); printf("Processing %lu records\n", imdb_rec_total - 1);