1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-19 21:43:15 +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

@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** 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 <ctype.h>
@@ -1146,6 +1146,7 @@ static void test_auxdata(
for(i=0; i<nArg; i++){
char const *z = (char*)sqlite3_value_text(argv[i]);
if( z ){
int n;
char *zAux = sqlite3_get_auxdata(pCtx, i);
if( zAux ){
zRet[i*2] = '1';
@@ -1153,10 +1154,10 @@ static void test_auxdata(
}else {
zRet[i*2] = '0';
}
zAux = contextMalloc(pCtx, strlen(z)+1);
n = strlen(z) + 1;
zAux = contextMalloc(pCtx, n);
if( zAux ){
strcpy(zAux, z);
memcpy(zAux, z, n);
sqlite3_set_auxdata(pCtx, i, zAux, free_test_auxdata);
}
zRet[i*2+1] = ' ';

View File

@@ -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.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 "tcl.h"
@@ -487,7 +487,7 @@ static int test_snprintf_int(
const char *zFormat = argv[2];
int a1 = atoi(argv[3]);
if( n>sizeof(zStr) ) n = sizeof(zStr);
strcpy(zStr, "abcdefghijklmnopqrstuvwxyz");
sqlite3_snprintf(sizeof(zStr), zStr, "abcdefghijklmnopqrstuvwxyz");
sqlite3_snprintf(n, zStr, zFormat, a1);
Tcl_AppendResult(interp, zStr, 0);
return TCL_OK;