aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest18
-rw-r--r--manifest.uuid2
-rw-r--r--src/test1.c16
-rw-r--r--src/vdbeblob.c20
-rw-r--r--test/incrblob.test34
5 files changed, 61 insertions, 29 deletions
diff --git a/manifest b/manifest
index 54937026b..2a6f0a21e 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\stypo\sthat\sprevents\sthe\ssqlite3_sql()\sinterface\sfrom\sappearing\nin\sthe\sofficial\sdocumentation.\s(CVS\s5761)
-D 2008-10-02T14:33:57
+C Fix\sfor\ssqlite3_blob_write():\sIf\seither\s3rd\sor\s4th\sargument\sis\sless\sthan\szero,\sreturn\sSQLITE_ERROR.\sH17879.\s(CVS\s5762)
+D 2008-10-02T14:49:02
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in e4ab842f9a64ef61d57093539a8aab76b12810db
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -156,7 +156,7 @@ F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8
F src/tclsqlite.c 6a7eeff5afd8f5f10fcb7fd7806e56c725dd2b07
-F src/test1.c c4de690aad182606e5914f6f3c8f43869fbdaaa8
+F src/test1.c fed7656affe3bc687043bb76d13650a40cb21aef
F src/test2.c 897528183edf2839c2a3c991d415905db56f1240
F src/test3.c e85b7ce5c28c3ce7fbdbf7f98e1467b19786c62b
F src/test4.c 41056378671e7b00e6305fa9ac6fa27e6f96f406
@@ -194,7 +194,7 @@ F src/vdbe.h 41c99aaad9167c1b5431993db446de74b2f71fc3
F src/vdbeInt.h b48c74d86a9fb62b707a3186ccca76bb32f1c6be
F src/vdbeapi.c c0f87aabb2bcf8c760ff9cb289119f7f6ba1797a
F src/vdbeaux.c 20a7d109c95e32beee7891fba828c63e419af26c
-F src/vdbeblob.c f93110888ddc246215e9ba1f831d3d375bfd8355
+F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
F src/vdbefifo.c 20fda2a7c4c0bcee1b90eb7e545fefcdbf2e1de7
F src/vdbemem.c ead88713b852576e2a924bc4ae696964bfbaec0a
F src/vtab.c 527c180e9c5fca417c9167d02af4b5039f892b4b
@@ -363,7 +363,7 @@ F test/in.test d49419c6df515852f477fa513f3317181d46bc92
F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75
F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0
F test/in4.test c043f75147295e9f6ad5040a5cda2c485736c2c8
-F test/incrblob.test e50cf41ac64e76ca4f8881ecb8d28fd988503ad5
+F test/incrblob.test 4040ac885090f147345bedb89bf5e9b5eee1c1f0
F test/incrblob2.test c82a780356bdf4d0c77f1adf0ea888248904fc07
F test/incrblob_err.test c577c91d4ed9e8336cdb188b15d6ee2a6fe9604e
F test/incrvacuum.test 9a6346c56ffa141024054ae7ba6c8655edf2d137
@@ -638,7 +638,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 803a1736d56b3c07b8ad38715fe0e39196ecc507
-R 243556cb0b1b86e08eea9d0132581848
-U drh
-Z d6769dceda655ca5c441f3e442cce59a
+P b46814b202f4cc355b925551c90ea811f3f9e44a
+R 362ac30c5f648c7676e341baf41a9564
+U danielk1977
+Z c307b688eb6312afb2158a48404fe616
diff --git a/manifest.uuid b/manifest.uuid
index ef3792536..066c369ea 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-b46814b202f4cc355b925551c90ea811f3f9e44a \ No newline at end of file
+f6074c0b9b5ba51d131509dba2aec80d0fcf3b7e \ No newline at end of file
diff --git a/src/test1.c b/src/test1.c
index 722c09e75..c54173e8d 100644
--- a/src/test1.c
+++ b/src/test1.c
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test1.c,v 1.325 2008/09/11 10:29:16 danielk1977 Exp $
+** $Id: test1.c,v 1.326 2008/10/02 14:49:02 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -1559,7 +1559,7 @@ static int test_blob_read(
}
/*
-** sqlite3_blob_write CHANNEL OFFSET DATA
+** sqlite3_blob_write CHANNEL OFFSET DATA ?NDATA?
**
** This command is used to test the sqlite3_blob_write() in ways that
** the Tcl channel interface does not. The first argument should
@@ -1588,16 +1588,13 @@ static int test_blob_write(
unsigned char *zBuf;
int nBuf;
- if( objc!=4 ){
- Tcl_WrongNumArgs(interp, 1, objv, "CHANNEL OFFSET DATA");
+ if( objc!=4 && objc!=5 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "CHANNEL OFFSET DATA ?NDATA?");
return TCL_ERROR;
}
channel = Tcl_GetChannel(interp, Tcl_GetString(objv[1]), &notUsed);
- if( !channel
- || TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset)
- || iOffset<0
- ){
+ if( !channel || TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset) ){
return TCL_ERROR;
}
@@ -1605,6 +1602,9 @@ static int test_blob_write(
pBlob = *((sqlite3_blob **)instanceData);
zBuf = Tcl_GetByteArrayFromObj(objv[3], &nBuf);
+ if( objc==5 && Tcl_GetIntFromObj(interp, objv[4], &nBuf) ){
+ return TCL_ERROR;
+ }
rc = sqlite3_blob_write(pBlob, zBuf, nBuf, iOffset);
if( rc!=SQLITE_OK ){
Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
diff --git a/src/vdbeblob.c b/src/vdbeblob.c
index 746bfe4c3..9afeb11c0 100644
--- a/src/vdbeblob.c
+++ b/src/vdbeblob.c
@@ -12,7 +12,7 @@
**
** This file contains code used to implement incremental BLOB I/O.
**
-** $Id: vdbeblob.c,v 1.25 2008/07/28 19:34:54 drh Exp $
+** $Id: vdbeblob.c,v 1.26 2008/10/02 14:49:02 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -287,17 +287,17 @@ static int blobReadWrite(
Vdbe *v;
sqlite3 *db = p->db;
- /* Request is out of range. Return a transient error. */
- if( (iOffset+n)>p->nByte ){
- return SQLITE_ERROR;
- }
sqlite3_mutex_enter(db->mutex);
-
- /* If there is no statement handle, then the blob-handle has
- ** already been invalidated. Return SQLITE_ABORT in this case.
- */
v = (Vdbe*)p->pStmt;
- if( v==0 ){
+
+ if( n<0 || iOffset<0 || (iOffset+n)>p->nByte ){
+ /* Request is out of range. Return a transient error. */
+ rc = SQLITE_ERROR;
+ sqlite3Error(db, SQLITE_ERROR, 0);
+ } else if( v==0 ){
+ /* If there is no statement handle, then the blob-handle has
+ ** already been invalidated. Return SQLITE_ABORT in this case.
+ */
rc = SQLITE_ABORT;
}else{
/* Call either BtreeData() or BtreePutData(). If SQLITE_ABORT is
diff --git a/test/incrblob.test b/test/incrblob.test
index aa9582d92..2fb2be233 100644
--- a/test/incrblob.test
+++ b/test/incrblob.test
@@ -9,7 +9,7 @@
#
#***********************************************************************
#
-# $Id: incrblob.test,v 1.21 2008/09/11 11:28:00 danielk1977 Exp $
+# $Id: incrblob.test,v 1.22 2008/10/02 14:49:02 danielk1977 Exp $
#
set testdir [file dirname $argv0]
@@ -618,4 +618,36 @@ do_test incrblob-7.6 {
sqlite3_errmsg db
} {attempt to write a readonly database}
+# Test that if either the "offset" or "amount" arguments to
+# sqlite3_blob_write() are less than zero, SQLITE_ERROR is returned.
+#
+do_test incrblob-8.1 {
+ execsql { INSERT INTO t1 VALUES(314159, 'sqlite') }
+ set ::b [db incrblob t1 b 314159]
+ fconfigure $::b -translation binary
+ set rc [catch {sqlite3_blob_write $::b 10 HELLO -1} msg]
+ lappend rc $msg
+} {1 SQLITE_ERROR}
+do_test incrblob-8.2 {
+ sqlite3_errcode db
+} {SQLITE_ERROR}
+do_test incrblob-8.3 {
+ set rc [catch {sqlite3_blob_write $::b -1 HELLO 5} msg]
+ lappend rc $msg
+} {1 SQLITE_ERROR}
+do_test incrblob-8.4 {
+ sqlite3_errcode db
+} {SQLITE_ERROR}
+do_test incrblob-8.5 {
+ execsql {SELECT b FROM t1 WHERE a = 314159}
+} {sqlite}
+do_test incrblob-8.6 {
+ set rc [catch {sqlite3_blob_write $::b 0 etilqs 6} msg]
+ lappend rc $msg
+} {0 {}}
+do_test incrblob-8.7 {
+ execsql {SELECT b FROM t1 WHERE a = 314159}
+} {etilqs}
+
+
finish_test