From: drh Date: Fri, 12 Jul 2013 21:09:24 +0000 (+0000) Subject: Make sure the shell does not try to put a zero terminator on the end of an X-Git-Tag: version-3.8.0~88 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8dd675e43f8c59a2802aec13a9a3d8d0b36dbc8a;p=thirdparty%2Fsqlite.git Make sure the shell does not try to put a zero terminator on the end of an unallocated zero-length string when running ".import" on an empty file. FossilOrigin-Name: 92adaee5bd31c152dbc1592f4aeb5d8da957a1ea --- diff --git a/manifest b/manifest index 5db174f506..6c619adf69 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sdescription\sof\show\ssqlite3_progress_handler()\sworks\sso\sthat\s\nthe\sN\sparameter\sis\s"approximate".\s\sThis\saligns\swith\sthe\scurrent\simplementation.\nThis\sis\sa\sdocumentation\schange\sonly.\s\sNo\schanges\sto\scode. -D 2013-07-11T19:04:23.647 +C Make\ssure\sthe\sshell\sdoes\snot\stry\sto\sput\sa\szero\sterminator\son\sthe\send\sof\san\nunallocated\szero-length\sstring\swhen\srunning\s".import"\son\san\sempty\sfile. +D 2013-07-12T21:09:24.523 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -217,7 +217,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 89f9003e8316ee3a172795459efc2a0274e1d5a8 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 91b62654caf8dfe292fb8882715e575d34ad3874 -F src/shell.c c8cd06e6b66250a3ea0149c4edec30de14f57b6f +F src/shell.c 4c02ec99e42aeb624bb221b253273da6c910b814 F src/sqlite.h.in c8b27ba43bb35a26b6067b8f24f06c24af2d1b64 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc @@ -1103,7 +1103,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 6557c407983b067449deb76bc4c5248de64e07dc -R 045649ed68015430e04b85aae90e1909 +P 7d829bdea3adcda50fbe930acb4e1ce73fd874e6 +R 3ed94849e5c017401e30c707fda6984e U drh -Z c98b2f615dfc222d1805fcdb692cca6b +Z e4e9f4e449a4a8d9a8571763475fda13 diff --git a/manifest.uuid b/manifest.uuid index 5d6223a30d..83ce9c684d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7d829bdea3adcda50fbe930acb4e1ce73fd874e6 \ No newline at end of file +92adaee5bd31c152dbc1592f4aeb5d8da957a1ea \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 79548fa1e4..f0815538ab 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1721,7 +1721,6 @@ static char *csv_read_one_field(CSVReader *p){ || (c==EOF && pc==cQuote) ){ do{ p->n--; }while( p->z[p->n]!=cQuote ); - p->z[p->n] = 0; p->cTerm = c; break; } @@ -1732,7 +1731,6 @@ static char *csv_read_one_field(CSVReader *p){ if( c==EOF ){ fprintf(stderr, "%s:%d: unterminated %c-quoted field\n", p->zFile, startLine, cQuote); - p->z[p->n] = 0; p->cTerm = EOF; break; } @@ -1748,9 +1746,9 @@ static char *csv_read_one_field(CSVReader *p){ p->nLine++; if( p->n>1 && p->z[p->n-1]=='\r' ) p->n--; } - p->z[p->n] = 0; p->cTerm = c; } + if( p->z ) p->z[p->n] = 0; return p->z; }