SQLite

Check-in [a80f84b5]
Login

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

Overview
Comment:Fix the zipfile extension so that INSERT works even if the pathname of the file being inserted is a NULL. Bug discovered by the Yongheng and Rui fuzzer.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a80f84b511231204658304226de3e075a55afc2e3f39ac063716f7a57f585c06
User & Date: drh 2019-12-19 15:15:40
Context
2019-12-19
17:42
Detect the invalid use of NULLS LAST on an INTEGER PRIMARY KEY definition of a WITHOUT ROWID table. (check-in: 4417c5bf user: drh tags: trunk)
15:15
Fix the zipfile extension so that INSERT works even if the pathname of the file being inserted is a NULL. Bug discovered by the Yongheng and Rui fuzzer. (check-in: a80f84b5 user: drh tags: trunk)
13:17
Fix incorrect SQL generated by the Lemon change of the previous check-in. (check-in: fccfb8a9 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/misc/zipfile.c.

1615
1616
1617
1618
1619
1620
1621

1622
1623
1624
1625
1626
1627
1628

    if( rc==SQLITE_OK ){
      rc = zipfileGetMode(apVal[3], bIsDir, &mode, &pTab->base.zErrMsg);
    }

    if( rc==SQLITE_OK ){
      zPath = (const char*)sqlite3_value_text(apVal[2]);

      nPath = (int)strlen(zPath);
      mTime = zipfileGetTime(apVal[4]);
    }

    if( rc==SQLITE_OK && bIsDir ){
      /* For a directory, check that the last character in the path is a
      ** '/'. This appears to be required for compatibility with info-zip







>







1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629

    if( rc==SQLITE_OK ){
      rc = zipfileGetMode(apVal[3], bIsDir, &mode, &pTab->base.zErrMsg);
    }

    if( rc==SQLITE_OK ){
      zPath = (const char*)sqlite3_value_text(apVal[2]);
      if( zPath==0 ) zPath = "";
      nPath = (int)strlen(zPath);
      mTime = zipfileGetTime(apVal[4]);
    }

    if( rc==SQLITE_OK && bIsDir ){
      /* For a directory, check that the last character in the path is a
      ** '/'. This appears to be required for compatibility with info-zip

Changes to test/zipfile.test.

790
791
792
793
794
795
796














797
798
    SELECT name FROM d JOIN x JOIN fsdir(d) ORDER BY 1;
  } {subdir subdir/x1.txt subdir/x2.txt}

  do_execsql_test 12.5 {
    SELECT name FROM d JOIN x JOIN fsdir('.', d) ORDER BY 1;
  } {. ./x1.txt ./x2.txt}
}















finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>


790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
    SELECT name FROM d JOIN x JOIN fsdir(d) ORDER BY 1;
  } {subdir subdir/x1.txt subdir/x2.txt}

  do_execsql_test 12.5 {
    SELECT name FROM d JOIN x JOIN fsdir('.', d) ORDER BY 1;
  } {. ./x1.txt ./x2.txt}
}

# 2019-12-18 Yongheng and Rui fuzzer
#
do_execsql_test 13.10 {
  DROP TABLE IF EXISTS t0;
  DROP TABLE IF EXISTS t1;
  CREATE TABLE t0(a,b,c,d,e,f,g);
  REPLACE INTO t0(c,b,f) VALUES(10,10,10);
  CREATE VIRTUAL TABLE t1 USING zipfile('h.zip');
  REPLACE INTO t1 SELECT * FROM t0;
  SELECT quote(name),quote(mode),quote(mtime),quote(sz),quote(rawdata),
         quote(data),quote(method) FROM t1;
} {'' 10 10 2 X'3130' X'3130' 0}


finish_test