1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-24 09:53:10 +03:00

Remove instances of strcpy() from test code. Use memcpy() or

sqlite3_snprintf() instead. (CVS 4801)

FossilOrigin-Name: 7b50140dc0fb41a1b40c8709d96e214d98b06f81
This commit is contained in:
drh
2008-02-19 18:29:07 +00:00
parent 85e5f0d477
commit 7694574abd
4 changed files with 15 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
C Remove\san\sinstance\sof\ssprintf()\sfrom\sthe\sVM\simplementation.\s\sSQLite\sshould\nnot\suse\ssprintf()\sfrom\sthe\sC\slibrary\s-\sit\shas\sits\sown\simplementation.\s(CVS\s4800) C Remove\sinstances\sof\sstrcpy()\sfrom\stest\scode.\sUse\smemcpy()\sor\nsqlite3_snprintf()\sinstead.\s(CVS\s4801)
D 2008-02-19T18:28:14 D 2008-02-19T18:29:07
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in bc2b5df3e3d0d4b801b824b7ef6dec43812b049b F Makefile.in bc2b5df3e3d0d4b801b824b7ef6dec43812b049b
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -95,7 +95,7 @@ F src/delete.c fa13c296262e89c32d28949f15be275e52d7f524
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
F src/expr.c e6fb42c6e55fd9526174b1cb8296b69a60a6688a F src/expr.c e6fb42c6e55fd9526174b1cb8296b69a60a6688a
F src/fault.c 049b88b8ba0a1db3240aeaf9695cd08b9a3ba9e1 F src/fault.c 049b88b8ba0a1db3240aeaf9695cd08b9a3ba9e1
F src/func.c 8e3d0c59961dc403716767308ee764504179054b F src/func.c 194cd8a9549be77d7b2a93eeaeb8ede893277293
F src/hash.c 53655c312280211444bfe23af6490a460aec2980 F src/hash.c 53655c312280211444bfe23af6490a460aec2980
F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53 F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
F src/insert.c b313f5ecadf82dda15b1aa6780b0310eceb9e776 F src/insert.c b313f5ecadf82dda15b1aa6780b0310eceb9e776
@@ -143,7 +143,7 @@ F src/sqliteInt.h 073801285d2650b22033a20c2389241c5e0361d6
F src/sqliteLimit.h ee4430f88f69bf63527967bb35ca52af7b0ccb1e F src/sqliteLimit.h ee4430f88f69bf63527967bb35ca52af7b0ccb1e
F src/table.c 46ccf9b7892a86f57420ae7bac69ecd5e72d26b5 F src/table.c 46ccf9b7892a86f57420ae7bac69ecd5e72d26b5
F src/tclsqlite.c d95e0e74c7167b2807f9f4f73bf45f7c58096297 F src/tclsqlite.c d95e0e74c7167b2807f9f4f73bf45f7c58096297
F src/test1.c 785e737ff4dac36c384633501402a4437eb027a6 F src/test1.c c7763d9bf747c94d04254bd6cc18ecbb2c565ad2
F src/test2.c 355d5693ca3ee705548fa7f795592a37b2372b70 F src/test2.c 355d5693ca3ee705548fa7f795592a37b2372b70
F src/test3.c 4557ee13c6e5921eb28979ff77cdbd913bfde6be F src/test3.c 4557ee13c6e5921eb28979ff77cdbd913bfde6be
F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071 F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
@@ -621,7 +621,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 9db346dede59e7185afcd7f21b2f578c9a4f949e P 68f5ddddf0d1b5c8ed97dda0a32362a55637b5f2
R b23de96abb4d44d9a8e1d8fb87ef9128 R 95dcd7a2db6ff273a951495091bfa925
U drh U drh
Z e446824e18bb60941b9ff0ea385ca6ef Z 94dde115ea93b6ad849adc1b17145e45

View File

@@ -1 +1 @@
68f5ddddf0d1b5c8ed97dda0a32362a55637b5f2 7b50140dc0fb41a1b40c8709d96e214d98b06f81

View File

@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope. ** All other code has file scope.
** **
** $Id: func.c,v 1.183 2008/01/21 16:22:46 drh Exp $ ** $Id: func.c,v 1.184 2008/02/19 18:29:07 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -1146,6 +1146,7 @@ static void test_auxdata(
for(i=0; i<nArg; i++){ for(i=0; i<nArg; i++){
char const *z = (char*)sqlite3_value_text(argv[i]); char const *z = (char*)sqlite3_value_text(argv[i]);
if( z ){ if( z ){
int n;
char *zAux = sqlite3_get_auxdata(pCtx, i); char *zAux = sqlite3_get_auxdata(pCtx, i);
if( zAux ){ if( zAux ){
zRet[i*2] = '1'; zRet[i*2] = '1';
@@ -1153,10 +1154,10 @@ static void test_auxdata(
}else { }else {
zRet[i*2] = '0'; zRet[i*2] = '0';
} }
n = strlen(z) + 1;
zAux = contextMalloc(pCtx, strlen(z)+1); zAux = contextMalloc(pCtx, n);
if( zAux ){ if( zAux ){
strcpy(zAux, z); memcpy(zAux, z, n);
sqlite3_set_auxdata(pCtx, i, zAux, free_test_auxdata); sqlite3_set_auxdata(pCtx, i, zAux, free_test_auxdata);
} }
zRet[i*2+1] = ' '; zRet[i*2+1] = ' ';

View File

@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated ** is not included in the SQLite library. It is used for automated
** testing of the SQLite library. ** testing of the SQLite library.
** **
** $Id: test1.c,v 1.289 2008/02/18 22:24:58 drh Exp $ ** $Id: test1.c,v 1.290 2008/02/19 18:29:07 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@@ -487,7 +487,7 @@ static int test_snprintf_int(
const char *zFormat = argv[2]; const char *zFormat = argv[2];
int a1 = atoi(argv[3]); int a1 = atoi(argv[3]);
if( n>sizeof(zStr) ) n = sizeof(zStr); if( n>sizeof(zStr) ) n = sizeof(zStr);
strcpy(zStr, "abcdefghijklmnopqrstuvwxyz"); sqlite3_snprintf(sizeof(zStr), zStr, "abcdefghijklmnopqrstuvwxyz");
sqlite3_snprintf(n, zStr, zFormat, a1); sqlite3_snprintf(n, zStr, zFormat, a1);
Tcl_AppendResult(interp, zStr, 0); Tcl_AppendResult(interp, zStr, 0);
return TCL_OK; return TCL_OK;