]> Nishi Git Mirror - dataworks.git/commitdiff
check the signature
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sat, 18 May 2024 09:23:40 +0000 (09:23 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sat, 18 May 2024 09:23:40 +0000 (09:23 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@27 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Library/database.c

index dbb0c63d3ea71d6e3c8d4da56836b0150276afb9..9f480cbb973bf5906a071d317989ab3a5eec492d 100644 (file)
@@ -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;