For 'zipfile', detect attempts to cause a duplicate entry via UPDATE.
FossilOrigin-Name: cf78a882799424610209e9ac5e76771db3f5e6704ffa181f9598eb0986d93eb8
This commit is contained in:
parent
d42d8ae337
commit
2cc8f4831e
@ -1524,6 +1524,7 @@ static int zipfileUpdate(
|
||||
u8 *pFree = 0; /* Free this */
|
||||
char *zFree = 0; /* Also free this */
|
||||
ZipfileEntry *pOld = 0;
|
||||
int bUpdate = 0;
|
||||
int bIsDir = 0;
|
||||
u32 iCrc32 = 0;
|
||||
|
||||
@ -1536,6 +1537,12 @@ static int zipfileUpdate(
|
||||
if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
|
||||
const char *zDelete = (const char*)sqlite3_value_text(apVal[0]);
|
||||
int nDelete = (int)strlen(zDelete);
|
||||
if( nVal>1 ){
|
||||
const char *zUpdate = (const char*)sqlite3_value_text(apVal[1]);
|
||||
if( zUpdate && zipfileComparePath(zUpdate, zDelete, nDelete)!=0 ){
|
||||
bUpdate = 1;
|
||||
}
|
||||
}
|
||||
for(pOld=pTab->pFirstEntry; 1; pOld=pOld->pNext){
|
||||
if( zipfileComparePath(pOld->cds.zFile, zDelete, nDelete)==0 ){
|
||||
break;
|
||||
@ -1613,8 +1620,9 @@ static int zipfileUpdate(
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that we're not inserting a duplicate entry */
|
||||
if( pOld==0 && rc==SQLITE_OK ){
|
||||
/* Check that we're not inserting a duplicate entry -OR- updating an
|
||||
** entry with a path, thereby making it into a duplicate. */
|
||||
if( (pOld==0 || bUpdate) && rc==SQLITE_OK ){
|
||||
ZipfileEntry *p;
|
||||
for(p=pTab->pFirstEntry; p; p=p->pNext){
|
||||
if( zipfileComparePath(p->cds.zFile, zPath, nPath)==0 ){
|
||||
|
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Another\sWin32\sportability\sfix\sfor\sthe\s'zipfile'\stests.
|
||||
D 2018-03-17T00:44:29.550
|
||||
C For\s'zipfile',\sdetect\sattempts\sto\scause\sa\sduplicate\sentry\svia\sUPDATE.
|
||||
D 2018-03-17T02:13:13.194
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F Makefile.in 7016fc56c6b9bfe5daac4f34be8be38d8c0b5fab79ccbfb764d3b23bf1c6fff3
|
||||
@ -304,7 +304,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178
|
||||
F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9
|
||||
F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
|
||||
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
|
||||
F ext/misc/zipfile.c e4e4f8289a8dee7e4f78547dacfb6548bcd83a02b52c0bc9205d8fbfb7f4b8a1
|
||||
F ext/misc/zipfile.c 7d0dd1cdd09fd7fa9837523044db65e8af109219675dbd17b7da3fb05a17795f
|
||||
F ext/misc/zorder.c b0ff58fa643afa1d846786d51ea8d5c4b6b35aa0254ab5a82617db92f3adda64
|
||||
F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e
|
||||
F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842
|
||||
@ -1611,7 +1611,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf
|
||||
F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc
|
||||
F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa
|
||||
F test/zerodamage.test 9c41628db7e8d9e8a0181e59ea5f189df311a9f6ce99cc376dc461f66db6f8dc
|
||||
F test/zipfile.test dbad090b506b9da943400e285e6723a53bdb3591aaa8f3138df892eae6ccb243
|
||||
F test/zipfile.test 2a923f6ead6a0f9b61d936881f3ee2aeaabe15fc65c196456f58ea9b4b450f9b
|
||||
F test/zipfile2.test 63bfa89686d12f87f77f8813cd64e948a71dc006e1d6e4c75f5cd1b371010421
|
||||
F test/zipfilefault.test 44d4d7a7f7cca7521d569d7f71026b241d65a6b1757aa409c1a168827edbbc2c
|
||||
F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5
|
||||
@ -1712,7 +1712,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 9d2b0f8b84aac862b0572b183e3ba53ea8c0d8742aaa3c3fbe59f6036054fd1a
|
||||
R 6c26f8c914e1431f7c5f7a3d351a4cdb
|
||||
P 9f604418ca21472d84d754f4c3b7f170e5c2bff05e8cee86640e45b43bc53a49
|
||||
R 36dc2795c05e1e4419391901e9f5285a
|
||||
U mistachkin
|
||||
Z c29417f3c6894392a7bcf8dd9bbc8937
|
||||
Z b9c6a70c30965228c26a28ea9d8e3504
|
||||
|
@ -1 +1 @@
|
||||
9f604418ca21472d84d754f4c3b7f170e5c2bff05e8cee86640e45b43bc53a49
|
||||
cf78a882799424610209e9ac5e76771db3f5e6704ffa181f9598eb0986d93eb8
|
@ -717,5 +717,44 @@ do_execsql_test 10.6 {
|
||||
SELECT name, data FROM z;
|
||||
} {a0 four}
|
||||
|
||||
do_execsql_test 11.1 {
|
||||
DELETE FROM z;
|
||||
} {}
|
||||
do_execsql_test 11.2 {
|
||||
SELECT name, data FROM z;
|
||||
} {}
|
||||
do_execsql_test 11.3 {
|
||||
INSERT INTO z (name,data) VALUES ('b0','one');
|
||||
SELECT name, data FROM z;
|
||||
} {b0 one}
|
||||
do_execsql_test 11.4 {
|
||||
UPDATE z SET name = 'b1' WHERE name = 'b0';
|
||||
SELECT name, data FROM z;
|
||||
} {b1 one}
|
||||
do_execsql_test 11.5 {
|
||||
INSERT INTO z (name,data) VALUES ('b0','one');
|
||||
SELECT name, data FROM z ORDER BY name;
|
||||
} {b0 one b1 one}
|
||||
do_catchsql_test 11.6 {
|
||||
UPDATE z SET name = 'b1' WHERE name = 'b0';
|
||||
} {1 {duplicate name: "b1"}}
|
||||
do_execsql_test 11.7 {
|
||||
UPDATE z SET data = 'two' WHERE name = 'b0';
|
||||
SELECT name, data FROM z ORDER BY name;
|
||||
} {b0 two b1 one}
|
||||
do_catchsql_test 11.8 {
|
||||
UPDATE z SET name = 'b1';
|
||||
} {1 {duplicate name: "b1"}}
|
||||
do_catchsql_test 11.9 {
|
||||
UPDATE z SET name = 'b2';
|
||||
} {1 {duplicate name: "b2"}}
|
||||
do_execsql_test 11.10 {
|
||||
UPDATE z SET name = name;
|
||||
SELECT name, data FROM z ORDER BY name;
|
||||
} {b0 two b2 one}
|
||||
do_execsql_test 11.11 {
|
||||
UPDATE z SET name = name || 'suffix';
|
||||
SELECT name, data FROM z ORDER BY name;
|
||||
} {b0suffix two b2suffix one}
|
||||
|
||||
finish_test
|
||||
|
Loading…
Reference in New Issue
Block a user