]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Pad the 26 byte Zonefile header to 32 bytes so that the ZonefileIndex object
authordan <dan@noemail.net>
Tue, 13 Feb 2018 17:33:28 +0000 (17:33 +0000)
committerdan <dan@noemail.net>
Tue, 13 Feb 2018 17:33:28 +0000 (17:33 +0000)
is 8-byte aligned.

FossilOrigin-Name: fdb6c0c5dc5a67ca16dfafc6e677f73936f36e357a2ff288b4958ddee0544603

ext/zonefile/zonefile.c
manifest
manifest.uuid

index a28c0ff77fa4b34141f2155b7a19f6c8ce56b2f2..328b1373a0522f15011a224f1c89de02dc1103c4 100644 (file)
@@ -37,7 +37,7 @@ typedef unsigned long u32;
 
 #define ZONEFILE_MAGIC_NUMBER 0x464B3138
 
-#define ZONEFILE_SZ_HEADER           26
+#define ZONEFILE_SZ_HEADER           32
 #define ZONEFILE_SZ_KEYOFFSETS_ENTRY 20
 
 #define ZONEFILE_DEFAULT_MAXAUTOFRAMESIZE (64*1024)
@@ -209,9 +209,43 @@ static int zonefileGetParams(
   const char *zJson,              /* JSON configuration parameter (or NULL) */
   ZonefileWrite *p                /* Populate this object before returning */
 ){
+  sqlite3 *db = sqlite3_context_db_handle(pCtx);
+  sqlite3_stmt *pStmt = 0;
+  char *zErr = 0;
+  int rc = SQLITE_OK;
+  int rc2;
+
   memset(p, 0, sizeof(ZonefileWrite));
   p->maxAutoFrameSize = ZONEFILE_DEFAULT_MAXAUTOFRAMESIZE;
-  return SQLITE_OK;
+
+  rc = zonefilePrepare(db, &pStmt, &zErr,"SELECT key, value FROM json_each(?)");
+  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
+    const char *zKey = (const char*)sqlite3_column_text(pStmt, 0);
+    int iVal = sqlite3_column_int(pStmt, 1);
+    if( sqlite3_stricmp("maxAutoFrameSize", zKey)==0 ){
+      p->maxAutoFrameSize = iVal;
+    }else
+    if( sqlite3_stricmp("compressionTypeIndexData", zKey)==0 ){
+      p->compressionTypeIndexData = iVal;
+    }else
+    if( sqlite3_stricmp("compressionTypeContent", zKey)==0 ){
+      p->compressionTypeContent = iVal;
+    }else
+    if( sqlite3_stricmp("encryptionType", zKey)==0 ){
+      p->encryptionType = iVal;
+    }else{
+      rc = SQLITE_ERROR;
+      zErr = sqlite3_mprintf("unknown parameter name: \"%s\"", zKey);
+    }
+  }
+  rc2 = sqlite3_finalize(pStmt);
+  if( rc==SQLITE_OK ) rc = rc2;
+
+  if( zErr ){
+    sqlite3_result_error(pCtx, zErr, -1);
+    sqlite3_free(zErr);
+  }
+  return rc;
 }
 
 /*
@@ -405,6 +439,7 @@ static void zonefileWriteFunc(
   pPrev = 0;
 
   /* Create the zonefile header in the in-memory buffer */
+  memset(aHdr, 0, ZONEFILE_SZ_HEADER);
   zonefilePut32(&aHdr[0], ZONEFILE_MAGIC_NUMBER);
   aHdr[4] = sWrite.compressionTypeIndexData;
   aHdr[5] = sWrite.compressionTypeContent;
@@ -416,7 +451,7 @@ static void zonefileWriteFunc(
   aHdr[23] = 0;                   /* Encryption key index */
   aHdr[24] = 0;                   /* extended header version */
   aHdr[25] = 0;                   /* extended header size */
-  assert( ZONEFILE_SZ_HEADER==26 );
+  assert( ZONEFILE_SZ_HEADER>=26 );
 
   rc = zonefileFileWrite(pFd, aHdr, ZONEFILE_SZ_HEADER);
   if( rc==SQLITE_OK ) rc = zonefileFileWrite(pFd, sFrameIdx.a, sFrameIdx.n);
index 97500789e16e261054914b693e36decdb40cdd03..04a99ffff3ec13036e28a66facbfccda82217345 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\ssupport\sfor\sreading\ssimple\s(no\scompression,\sno\sencryption)\szonefile\sfiles.
-D 2018-02-12T20:04:22.636
+C Pad\sthe\s26\sbyte\sZonefile\sheader\sto\s32\sbytes\sso\sthat\sthe\sZonefileIndex\sobject\nis\s8-byte\saligned.
+D 2018-02-13T17:33:28.294
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F Makefile.in 7a3f714b4fcf793108042b7b0a5c720b0b310ec84314d61ba7f3f49f27e550ea
@@ -409,7 +409,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3
 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04
 F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f
 F ext/zonefile/README.md d675dbdffe2cd6d54681b958a13c88433a5022d39ab9ef3d4f487a272603f902
-F ext/zonefile/zonefile.c 31a8627c6fb619f4b87993abb22f2e38f14eb2bdf53130c425ba711d17eedb91
+F ext/zonefile/zonefile.c ed633fa36e07eb7f23484bc05d791c4d694b3b4e9d35badf49e53abdb7d579bc
 F ext/zonefile/zonefile1.test 8904658bd8332dc0d0c77c0c74c9c83dce4123a442bb971d5baf00170f6d0afe
 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
@@ -1708,7 +1708,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 0b7bd1694bf50a5afed22ed3026cefe53c5e7ec334167244e2caa9c56185ff43
-R 33d1fa645c0dd3199e4abbacb34944f8
+P dba42f0e1efae7bad4579d23ad98e2c06e38053abe55f5cb277d7eecea42c56c
+R a2267f09422e3c7541908b968634faac
 U dan
-Z de15678e60eb47332eda44ee08650662
+Z 6e2ce05e6036b2dfe07f6724215b9f81
index 4b45f809108da05e0dd58d5707a80cab40ac759b..39e859fdfec04c19ef201e7ac6526b8499df8a50 100644 (file)
@@ -1 +1 @@
-dba42f0e1efae7bad4579d23ad98e2c06e38053abe55f5cb277d7eecea42c56c
\ No newline at end of file
+fdb6c0c5dc5a67ca16dfafc6e677f73936f36e357a2ff288b4958ddee0544603
\ No newline at end of file