SQLite

Check-in [1cda511deb]
Login

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

Overview
Comment:Harden the utf8-to-mbcs converter in the quota module against failures.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | quota-stdio
Files: files | file ages | folders
SHA1: 1cda511deb625868395a23c95346e14d0c300670
User & Date: drh 2011-12-14 00:04:52.373
Context
2011-12-15
17:42
Use _commit() rather than FlushFileBuffers() as a substitute for fsync() on windows. Also cast for C++ and add support for SQLITE_FCNTL_VFSNAME. (Closed-Leaf check-in: e85cfe9a17 user: drh tags: quota-stdio)
2011-12-14
00:04
Harden the utf8-to-mbcs converter in the quota module against failures. (check-in: 1cda511deb user: drh tags: quota-stdio)
2011-12-13
23:26
Enhancements to test_quota.c: Remove the external dependency on sqlite3_win32_utf8_to_msbc(). Add an extra parameter to quota_fflush() that will also do an fsync (or the equivalent). (check-in: 92f4188f90 user: drh tags: quota-stdio)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/test_quota.c.
423
424
425
426
427
428
429

430
431
432
433
434
435
436
437
438
439
440
441
442
  int nMbcs;         /* Bytes of MBCS */
  LPWSTR zTmpWide;   /* The UTF16 text */
  char *zMbcs;       /* The MBCS text */
  int codepage;      /* Code page used by fopen() */

  n = strlen(zUtf8);
  nWide = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, NULL, 0);

  zTmpWide = sqlite3_malloc( nWide*sizeof(zTmpWide[0]) );
  if( zTmpWide==0 ) return 0;
  MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zTmpWide, nWide);
  codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
  nMbcs = WideCharToMultiByte(codepage, 0, zTmpWide, nWide, 0, 0, 0, 0);
  zMbcs = sqlite3_malloc( nMbcs+1 );
  if( zMbcs ){
    WideCharToMultiByte(codepage, 0, zTmpWide, nWide, zMbcs, nMbcs, 0, 0);
  }
  sqlite3_free(zTmpWide);
  return zMbcs;
#else
  return (char*)zUtf8;  /* No-op on unix */







>
|




|







423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
  int nMbcs;         /* Bytes of MBCS */
  LPWSTR zTmpWide;   /* The UTF16 text */
  char *zMbcs;       /* The MBCS text */
  int codepage;      /* Code page used by fopen() */

  n = strlen(zUtf8);
  nWide = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, NULL, 0);
  if( nWide==0 ) return 0;
  zTmpWide = sqlite3_malloc( (nWide+1)*sizeof(zTmpWide[0]) );
  if( zTmpWide==0 ) return 0;
  MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zTmpWide, nWide);
  codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
  nMbcs = WideCharToMultiByte(codepage, 0, zTmpWide, nWide, 0, 0, 0, 0);
  zMbcs = nMbcs ? sqlite3_malloc( nMbcs+1 ) : 0;
  if( zMbcs ){
    WideCharToMultiByte(codepage, 0, zTmpWide, nWide, zMbcs, nMbcs, 0, 0);
  }
  sqlite3_free(zTmpWide);
  return zMbcs;
#else
  return (char*)zUtf8;  /* No-op on unix */