From 9ef8ffb90c20beb2fd78c38c06479c98558415cf Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 18 May 2024 09:23:40 +0000 Subject: [PATCH] check the signature git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@27 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- Library/database.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Library/database.c b/Library/database.c index dbb0c63..9f480cb 100644 --- a/Library/database.c +++ b/Library/database.c @@ -62,6 +62,12 @@ struct dataworks_db* dataworks_database_open(const char* fname) { if(fp == NULL) { return NULL; } + char readsig[sizeof(sig)]; + fread(readsig, 1, sizeof(sig), fp); + if(memcmp(readsig, sig, sizeof(sig)) != 0){ + fclose(fp); + return NULL; + } struct dataworks_db* db = malloc(sizeof(*db)); db->fp = fp; return db; -- 2.43.0