From: nishi Date: Sat, 18 May 2024 09:23:40 +0000 (+0000) Subject: check the signature X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=9ef8ffb90c20beb2fd78c38c06479c98558415cf;p=dataworks.git check the signature git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@27 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- 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;