Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Prevent users from creating zipfile() virtual tables without an argument. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
81fdbe0cc5a360f818078d47a5888d0a |
User & Date: | dan 2018-01-30 14:07:55.726 |
Context
2018-01-30
| ||
17:43 | Add tests cases for the zipfile extension. (check-in: 13b786dafd user: dan tags: trunk) | |
14:07 | Prevent users from creating zipfile() virtual tables without an argument. (check-in: 81fdbe0cc5 user: dan tags: trunk) | |
2018-01-29
| ||
19:47 | Add unix-only tests to check that the "unzip" program can unpack archives generated by the zipfile extension. (check-in: 438c5c5237 user: dan tags: trunk) | |
Changes
Changes to ext/misc/zipfile.c.
︙ | ︙ | |||
313 314 315 316 317 318 319 320 321 322 323 324 325 326 | char **pzErr ){ int nByte = sizeof(ZipfileTab) + ZIPFILE_BUFFER_SIZE; int nFile = 0; const char *zFile = 0; ZipfileTab *pNew = 0; int rc; if( argc>3 ){ zFile = argv[3]; nFile = (int)strlen(zFile)+1; } rc = sqlite3_declare_vtab(db, ZIPFILE_SCHEMA); | > > > > > > > > > > > > > > > | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | char **pzErr ){ int nByte = sizeof(ZipfileTab) + ZIPFILE_BUFFER_SIZE; int nFile = 0; const char *zFile = 0; ZipfileTab *pNew = 0; int rc; /* If the table name is not "zipfile", require that the argument be ** specified. This stops zipfile tables from being created as: ** ** CREATE VIRTUAL TABLE zzz USING zipfile(); ** ** It does not prevent: ** ** CREATE VIRTUAL TABLE zipfile USING zipfile(); */ assert( 0==sqlite3_stricmp(argv[0], "zipfile") ); if( (0!=sqlite3_stricmp(argv[2], "zipfile") && argc<4) || argc>4 ){ *pzErr = sqlite3_mprintf("zipfile constructor requires one argument"); return SQLITE_ERROR; } if( argc>3 ){ zFile = argv[3]; nFile = (int)strlen(zFile)+1; } rc = sqlite3_declare_vtab(db, ZIPFILE_SCHEMA); |
︙ | ︙ | |||
1720 1721 1722 1723 1724 1725 1726 | sqlite3_result_error_nomem(context); }else{ sqlite3_result_text(context, zRes, -1, SQLITE_TRANSIENT); sqlite3_free(zRes); } } } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 | sqlite3_result_error_nomem(context); }else{ sqlite3_result_text(context, zRes, -1, SQLITE_TRANSIENT); sqlite3_free(zRes); } } } /* ** xFindFunction method. */ static int zipfileFindFunction( sqlite3_vtab *pVtab, /* Virtual table handle */ int nArg, /* Number of SQL function arguments */ const char *zName, /* Name of SQL function */ void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */ void **ppArg /* OUT: User data for *pxFunc */ ){ if( nArg>0 ){ if( sqlite3_stricmp("zipfile_cds", zName)==0 ){ *pxFunc = zipfileFunctionCds; *ppArg = (void*)pVtab; return 1; } } return 0; } typedef struct ZipfileBuffer ZipfileBuffer; struct ZipfileBuffer { |
︙ | ︙ | |||
2087 2088 2089 2090 2091 2092 2093 | zipfileRollback, /* xRollback */ zipfileFindFunction, /* xFindMethod */ 0, /* xRename */ }; int rc = sqlite3_create_module(db, "zipfile" , &zipfileModule, 0); if( rc==SQLITE_OK ) rc = sqlite3_overload_function(db, "zipfile_cds", -1); | < | 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 | zipfileRollback, /* xRollback */ zipfileFindFunction, /* xFindMethod */ 0, /* xRename */ }; int rc = sqlite3_create_module(db, "zipfile" , &zipfileModule, 0); if( rc==SQLITE_OK ) rc = sqlite3_overload_function(db, "zipfile_cds", -1); if( rc==SQLITE_OK ){ rc = sqlite3_create_function(db, "zipfile", -1, SQLITE_UTF8, 0, 0, zipfileStep, zipfileFinal ); } return rc; } |
︙ | ︙ |
Changes to test/zipfile.test.
︙ | ︙ | |||
354 355 356 357 358 359 360 | } do_catchsql_test 3.2 { SELECT rowid FROM x1 } {1 {no such column: rowid}} #------------------------------------------------------------------------- | < | < | | | < < < < < < < | | | | < | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | } do_catchsql_test 3.2 { SELECT rowid FROM x1 } {1 {no such column: rowid}} #------------------------------------------------------------------------- # Test some error conditions. # do_catchsql_test 4.1 { CREATE VIRTUAL TABLE yyy USING zipfile(); } {1 {zipfile constructor requires one argument}} do_catchsql_test 4.2 { CREATE VIRTUAL TABLE yyy USING zipfile('test.zip', 'test.zip'); } {1 {zipfile constructor requires one argument}} finish_test |