SQLite

Check-in [ba44724bcc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem causing zipfile to store 0 in place of the CRC32 value for uncompressed files.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ba44724bcca2e87788b7c6d8c5de7fa388360127bd894ee6a171fd66e794fcae
User & Date: dan 2018-01-16 21:09:00.543
Context
2018-01-17
01:15
Fix duplicate test names in 'walfault.test'. (check-in: 7274d05ff4 user: mistachkin tags: trunk)
2018-01-16
21:09
Fix a problem causing zipfile to store 0 in place of the CRC32 value for uncompressed files. (check-in: ba44724bcc user: dan tags: trunk)
21:05
Remove an unused field from the internal definition of the sqlite3_context object. (check-in: 948a26b5a6 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/misc/zipfile.c.
1333
1334
1335
1336
1337
1338
1339

1340
1341
1342
1343
1344
1345
1346
1347

1348
1349
1350
1351
1352
1353
1354

      iMethod = sqlite3_value_int(apVal[8]);
      sz = nIn;
      pData = aIn;
      nData = nIn;
      if( iMethod!=0 && iMethod!=8 ){
        rc = SQLITE_CONSTRAINT;

      }else if( bAuto || iMethod ){
        int nCmp;
        rc = zipfileDeflate(pTab, aIn, nIn, &pFree, &nCmp);
        if( rc==SQLITE_OK ){
          if( iMethod || nCmp<nIn ){
            iMethod = 8;
            pData = pFree;
            nData = nCmp;

          }
        }
        iCrc32 = crc32(0, aIn, nIn);
      }
    }
  }








>
|
|
|
|
|
|
|
|
>







1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356

      iMethod = sqlite3_value_int(apVal[8]);
      sz = nIn;
      pData = aIn;
      nData = nIn;
      if( iMethod!=0 && iMethod!=8 ){
        rc = SQLITE_CONSTRAINT;
      }else{
        if( bAuto || iMethod ){
          int nCmp;
          rc = zipfileDeflate(pTab, aIn, nIn, &pFree, &nCmp);
          if( rc==SQLITE_OK ){
            if( iMethod || nCmp<nIn ){
              iMethod = 8;
              pData = pFree;
              nData = nCmp;
            }
          }
        }
        iCrc32 = crc32(0, aIn, nIn);
      }
    }
  }

Changes to test/zipfile.test.
70
71
72
73
74
75
76









77
78
79
80
81
82
83
do_execsql_test 1.4 {
  SELECT name, mtime, data, method FROM zipfile('test.zip');
} {
  f.txt 1000000000 abcde 0
  g.txt 1000000002 12345 0
  h.txt 1000000004 aaaaaaaaaabbbbbbbbbb 8
}










do_execsql_test 1.5.1 {
  BEGIN;
    INSERT INTO zz(name, mode, mtime, data, method)
    VALUES('i.txt', '-rw-r--r--', 1000000006, 'zxcvb', 0);
    SELECT name FROM zz;
  COMMIT;







>
>
>
>
>
>
>
>
>







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
do_execsql_test 1.4 {
  SELECT name, mtime, data, method FROM zipfile('test.zip');
} {
  f.txt 1000000000 abcde 0
  g.txt 1000000002 12345 0
  h.txt 1000000004 aaaaaaaaaabbbbbbbbbb 8
}

do_execsql_test 1.4.1 {
  SELECT name, json_extract( zipfile_cds(z) , '$.crc32')!=0
  FROM zipfile('test.zip');
} {
  f.txt 1
  g.txt 1
  h.txt 1
}

do_execsql_test 1.5.1 {
  BEGIN;
    INSERT INTO zz(name, mode, mtime, data, method)
    VALUES('i.txt', '-rw-r--r--', 1000000006, 'zxcvb', 0);
    SELECT name FROM zz;
  COMMIT;