/ Check-in [0b06ce6d]
Login

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

Overview
Comment:Fix minor problems with passing NULL pointers to memcmp() and memcpy() found by -fsanitize=undefined.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0b06ce6d8e7cff5cd5d467a94522dfef5593d7c26663ce03c2c2b663a2641551
User & Date: dan 2018-03-23 16:31:34
Context
2018-03-23
17:36
Fix typos in sqlite3session.h preventing documentation webpages from being generated. Also mark all new sessions functions (those related to rebasing) as experimental. check-in: de974235 user: dan tags: trunk
16:31
Fix minor problems with passing NULL pointers to memcmp() and memcpy() found by -fsanitize=undefined. check-in: 0b06ce6d user: dan tags: trunk
16:08
Fix the -readonly option on the CLI so that it actually works. check-in: 0477fb3f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/zipfile.c.

  2057   2057   
  2058   2058     /* Append the LFH to the body of the new archive */
  2059   2059     nByte = ZIPFILE_LFH_FIXED_SZ + e.cds.nFile + 9;
  2060   2060     if( (rc = zipfileBufferGrow(&p->body, nByte)) ) goto zipfile_step_out;
  2061   2061     p->body.n += zipfileSerializeLFH(&e, &p->body.a[p->body.n]);
  2062   2062   
  2063   2063     /* Append the data to the body of the new archive */
  2064         -  if( (rc = zipfileBufferGrow(&p->body, nData)) ) goto zipfile_step_out;
  2065         -  memcpy(&p->body.a[p->body.n], aData, nData);
  2066         -  p->body.n += nData;
         2064  +  if( nData>0 ){
         2065  +    if( (rc = zipfileBufferGrow(&p->body, nData)) ) goto zipfile_step_out;
         2066  +    memcpy(&p->body.a[p->body.n], aData, nData);
         2067  +    p->body.n += nData;
         2068  +  }
  2067   2069   
  2068   2070     /* Append the CDS record to the directory of the new archive */
  2069   2071     nByte = ZIPFILE_CDS_FIXED_SZ + e.cds.nFile + 9;
  2070   2072     if( (rc = zipfileBufferGrow(&p->cds, nByte)) ) goto zipfile_step_out;
  2071   2073     p->cds.n += zipfileSerializeCDS(&e, &p->cds.a[p->cds.n]);
  2072   2074   
  2073   2075     /* Increment the count of entries in the archive */

Changes to ext/session/sqlite3session.c.

   835    835           a += sessionVarintGet(a, &n);
   836    836           if( sqlite3_value_bytes(pVal)!=n ) return 0;
   837    837           if( eType==SQLITE_TEXT ){
   838    838             z = sqlite3_value_text(pVal);
   839    839           }else{
   840    840             z = sqlite3_value_blob(pVal);
   841    841           }
   842         -        if( memcmp(a, z, n) ) return 0;
          842  +        if( n>0 && memcmp(a, z, n) ) return 0;
   843    843           a += n;
   844    844         }
   845    845       }
   846    846     }
   847    847   
   848    848     return 1;
   849    849   }