Fix minor problems with passing NULL pointers to memcmp() and memcpy() found by -fsanitize=undefined.

FossilOrigin-Name: 0b06ce6d8e7cff5cd5d467a94522dfef5593d7c26663ce03c2c2b663a2641551
This commit is contained in:
dan 2018-03-23 16:31:34 +00:00
parent 4aafe5957d
commit 3f2cebb6b4
4 changed files with 15 additions and 13 deletions

View File

@ -2061,9 +2061,11 @@ void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
p->body.n += zipfileSerializeLFH(&e, &p->body.a[p->body.n]);
/* Append the data to the body of the new archive */
if( (rc = zipfileBufferGrow(&p->body, nData)) ) goto zipfile_step_out;
memcpy(&p->body.a[p->body.n], aData, nData);
p->body.n += nData;
if( nData>0 ){
if( (rc = zipfileBufferGrow(&p->body, nData)) ) goto zipfile_step_out;
memcpy(&p->body.a[p->body.n], aData, nData);
p->body.n += nData;
}
/* Append the CDS record to the directory of the new archive */
nByte = ZIPFILE_CDS_FIXED_SZ + e.cds.nFile + 9;

View File

@ -839,7 +839,7 @@ static int sessionPreupdateEqual(
}else{
z = sqlite3_value_blob(pVal);
}
if( memcmp(a, z, n) ) return 0;
if( n>0 && memcmp(a, z, n) ) return 0;
a += n;
}
}

View File

@ -1,5 +1,5 @@
C Fix\sthe\s-readonly\soption\son\sthe\sCLI\sso\sthat\sit\sactually\sworks.
D 2018-03-23T16:08:30.593
C Fix\sminor\sproblems\swith\spassing\sNULL\spointers\sto\smemcmp()\sand\smemcpy()\sfound\sby\s-fsanitize=undefined.
D 2018-03-23T16:31:34.359
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 316c771140fe54c17729138f139c7d94b13674b375ccfbb1e6e30202d835e8c8
F ext/misc/zipfile.c c4de8f0ad446ce4a49aae11ff7b771cd7af60d7136c0bcfb53da1475b9075e79
F ext/misc/zorder.c b0ff58fa643afa1d846786d51ea8d5c4b6b35aa0254ab5a82617db92f3adda64
F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e
F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842
@ -404,7 +404,7 @@ F ext/session/sessionfault2.test c76c76fe3c47737cb55cad7a254c0f05d0e3122f13e16de
F ext/session/sessionrebase.test 4e1bcfd26fd8ed8ac571746f56cceeb45184f4d65490ea0d405227cfc8a9cba8
F ext/session/sessionstat1.test 41cd97c2e48619a41cdf8ae749e1b25f34719de638689221aa43971be693bf4e
F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc
F ext/session/sqlite3session.c b411b1fa4640d09e516a880aecaa78a0a96b86c0ad43d838f01ed9bea9e4d502
F ext/session/sqlite3session.c ad85f3e528dd320c55e67e0f567a2d3af4cee65b7cc547cace6899b0e544e67e
F ext/session/sqlite3session.h 5f40a0660ff972c0c50f5fd6b33488fdbd2eb0c1244ea95777f8dbd5e529be04
F ext/session/test_session.c f253742ea01b089326f189b5ae15a5b55c1c9e97452e4a195ee759ba51b404d5
F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3
@ -1717,7 +1717,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 9fe5bebefe909288e583226b5dc32e0465f6b2d8eda850d01820e3f1f8091ddd
R 44b3c3b312da1b61485f5dde8b7011e1
U drh
Z 731f009cfc004d6c131c77accf67b94f
P 0477fb3fd68509547f3bfd588247aac59aa4aa885ed8a21269852eda64e257ad
R 4d19ed142580e06d97255ee7223aa6ae
U dan
Z 6a2da4769910a829b6c436ffbebdac05

View File

@ -1 +1 @@
0477fb3fd68509547f3bfd588247aac59aa4aa885ed8a21269852eda64e257ad
0b06ce6d8e7cff5cd5d467a94522dfef5593d7c26663ce03c2c2b663a2641551