sqlite3-fix-CVE-2017-13685.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. Fix CVE-2017-13685
  2. The dump_callback function in SQLite 3.20.0 allows remote attackers to
  3. cause a denial of service (EXC_BAD_ACCESS and application crash) via a
  4. crafted file.
  5. References:
  6. https://sqlite.org/src/info/02f0f4c54f2819b3
  7. http://www.mail-archive.com/sqlite-users%40mailinglists.sqlite.org/msg105314.html
  8. Upstream-Status: Backport [https://sqlite.org/src/info/cf0d3715caac9149]
  9. CVE: CVE-2017-13685
  10. Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
  11. Index: src/shell.c
  12. ==================================================================
  13. --- src/shell.c
  14. +++ src/shell.c
  15. @@ -2657,10 +2657,11 @@
  16. int *aiType /* Column types */
  17. ){
  18. int i;
  19. ShellState *p = (ShellState*)pArg;
  20. + if( azArg==0 ) return 0;
  21. switch( p->cMode ){
  22. case MODE_Line: {
  23. int w = 5;
  24. if( azArg==0 ) break;
  25. for(i=0; i<nArg; i++){
  26. @@ -3007,10 +3008,11 @@
  27. */
  28. static int captureOutputCallback(void *pArg, int nArg, char **azArg, char **az){
  29. ShellText *p = (ShellText*)pArg;
  30. int i;
  31. UNUSED_PARAMETER(az);
  32. + if( azArg==0 ) return 0;
  33. if( p->n ) appendText(p, "|", 0);
  34. for(i=0; i<nArg; i++){
  35. if( i ) appendText(p, ",", 0);
  36. if( azArg[i] ) appendText(p, azArg[i], 0);
  37. }
  38. @@ -3888,11 +3890,11 @@
  39. const char *zType;
  40. const char *zSql;
  41. ShellState *p = (ShellState *)pArg;
  42. UNUSED_PARAMETER(azNotUsed);
  43. - if( nArg!=3 ) return 1;
  44. + if( nArg!=3 || azArg==0 ) return 0;
  45. zTable = azArg[0];
  46. zType = azArg[1];
  47. zSql = azArg[2];
  48. if( strcmp(zTable, "sqlite_sequence")==0 ){