1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-18 17:42:20 +03:00

Use memory safe snprintf() in Connect Engine

This commit replaces sprintf(buf, ...) with
snprintf(buf, sizeof(buf), ...),
specifically in the "easy" cases where buf is allocated with a size
known at compile time.

The changes make sure we are not write outside array/string bounds which
will lead to undefined behaviour. In case the code is trying to write
outside bounds - safe version of functions simply cut the string
messages so we process this gracefully.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the BSD-new
license.  I am contributing on behalf of my employer Amazon Web Services,
Inc.

bsonudf.cpp warnings cleanup by Daniel Black

Reviewer: Daniel Black
This commit is contained in:
Mikhail Chalov
2022-07-19 19:06:55 +00:00
committed by Daniel Black
parent 95eb5e5a12
commit 19af1890b5
61 changed files with 931 additions and 919 deletions

View File

@@ -89,7 +89,7 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
/*********************************************************************/ /*********************************************************************/
for (n = 0, parmp = pp; parmp; n++, parmp = parmp->Next) for (n = 0, parmp = pp; parmp; n++, parmp = parmp->Next)
if (parmp->Type != valtyp) { if (parmp->Type != valtyp) {
sprintf(g->Message, MSG(BAD_PARAM_TYPE), "MakeValueArray", parmp->Type); snprintf(g->Message, sizeof(g->Message), MSG(BAD_PARAM_TYPE), "MakeValueArray", parmp->Type);
return NULL; return NULL;
} else if (valtyp == TYPE_STRING) } else if (valtyp == TYPE_STRING)
len = MY_MAX(len, strlen((char*)parmp->Value)); len = MY_MAX(len, strlen((char*)parmp->Value));
@@ -176,7 +176,7 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec)
break; break;
#endif // 0 #endif // 0
default: // This is illegal an causes an ill formed array building default: // This is illegal an causes an ill formed array building
sprintf(g->Message, MSG(BAD_ARRAY_TYPE), type); snprintf(g->Message, sizeof(g->Message), MSG(BAD_ARRAY_TYPE), type);
Type = TYPE_ERROR; Type = TYPE_ERROR;
return; return;
} // endswitch type } // endswitch type
@@ -224,7 +224,7 @@ ARRAY::ARRAY(PGLOBAL g, PQUERY qryp) : CSORT(false)
// Value = qryp->GetColValue(0); // Value = qryp->GetColValue(0);
// break; // break;
default: // This is illegal an causes an ill formed array building default: // This is illegal an causes an ill formed array building
sprintf(g->Message, MSG(BAD_ARRAY_TYPE), Type); snprintf(g->Message, sizeof(g->Message), MSG(BAD_ARRAY_TYPE), Type);
Type = TYPE_ERROR; Type = TYPE_ERROR;
} // endswitch type } // endswitch type
@@ -285,7 +285,7 @@ void ARRAY::Empty(void)
bool ARRAY::AddValue(PGLOBAL g, PSZ strp) bool ARRAY::AddValue(PGLOBAL g, PSZ strp)
{ {
if (Type != TYPE_STRING) { if (Type != TYPE_STRING) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "CHAR"); snprintf(g->Message, sizeof(g->Message), MSG(ADD_BAD_TYPE), GetTypeName(Type), "CHAR");
return true; return true;
} // endif Type } // endif Type
@@ -300,7 +300,7 @@ bool ARRAY::AddValue(PGLOBAL g, PSZ strp)
bool ARRAY::AddValue(PGLOBAL g, void *p) bool ARRAY::AddValue(PGLOBAL g, void *p)
{ {
if (Type != TYPE_PCHAR) { if (Type != TYPE_PCHAR) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "PCHAR"); snprintf(g->Message, sizeof(g->Message), MSG(ADD_BAD_TYPE), GetTypeName(Type), "PCHAR");
return true; return true;
} // endif Type } // endif Type
@@ -315,7 +315,7 @@ bool ARRAY::AddValue(PGLOBAL g, void *p)
bool ARRAY::AddValue(PGLOBAL g, short n) bool ARRAY::AddValue(PGLOBAL g, short n)
{ {
if (Type != TYPE_SHORT) { if (Type != TYPE_SHORT) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "SHORT"); snprintf(g->Message, sizeof(g->Message), MSG(ADD_BAD_TYPE), GetTypeName(Type), "SHORT");
return true; return true;
} // endif Type } // endif Type
@@ -330,7 +330,7 @@ bool ARRAY::AddValue(PGLOBAL g, short n)
bool ARRAY::AddValue(PGLOBAL g, int n) bool ARRAY::AddValue(PGLOBAL g, int n)
{ {
if (Type != TYPE_INT) { if (Type != TYPE_INT) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "INTEGER"); snprintf(g->Message, sizeof(g->Message), MSG(ADD_BAD_TYPE), GetTypeName(Type), "INTEGER");
return true; return true;
} // endif Type } // endif Type
@@ -345,7 +345,7 @@ bool ARRAY::AddValue(PGLOBAL g, int n)
bool ARRAY::AddValue(PGLOBAL g, double d) bool ARRAY::AddValue(PGLOBAL g, double d)
{ {
if (Type != TYPE_DOUBLE) { if (Type != TYPE_DOUBLE) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "DOUBLE"); snprintf(g->Message, sizeof(g->Message), MSG(ADD_BAD_TYPE), GetTypeName(Type), "DOUBLE");
return true; return true;
} // endif Type } // endif Type
@@ -361,7 +361,7 @@ bool ARRAY::AddValue(PGLOBAL g, double d)
bool ARRAY::AddValue(PGLOBAL g, PXOB xp) bool ARRAY::AddValue(PGLOBAL g, PXOB xp)
{ {
if (Type != xp->GetResultType()) { if (Type != xp->GetResultType()) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), snprintf(g->Message, sizeof(g->Message), MSG(ADD_BAD_TYPE),
GetTypeName(xp->GetResultType()), GetTypeName(Type)); GetTypeName(xp->GetResultType()), GetTypeName(Type));
return true; return true;
} // endif Type } // endif Type
@@ -377,7 +377,7 @@ bool ARRAY::AddValue(PGLOBAL g, PXOB xp)
bool ARRAY::AddValue(PGLOBAL g, PVAL vp) bool ARRAY::AddValue(PGLOBAL g, PVAL vp)
{ {
if (Type != vp->GetType()) { if (Type != vp->GetType()) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), snprintf(g->Message, sizeof(g->Message), MSG(ADD_BAD_TYPE),
GetTypeName(vp->GetType()), GetTypeName(Type)); GetTypeName(vp->GetType()), GetTypeName(Type));
return true; return true;
} // endif Type } // endif Type
@@ -404,7 +404,7 @@ bool ARRAY::GetSubValue(PGLOBAL g, PVAL valp, int *kp)
PVBLK vblp; PVBLK vblp;
if (Type != TYPE_LIST) { if (Type != TYPE_LIST) {
sprintf(g->Message, MSG(NO_SUB_VAL), Type); snprintf(g->Message, sizeof(g->Message), MSG(NO_SUB_VAL), Type);
return true; return true;
} // endif Type } // endif Type
@@ -500,7 +500,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
vp = valp; vp = valp;
} else if (opc != OP_EXIST) { } else if (opc != OP_EXIST) {
sprintf(g->Message, MSG(MISSING_ARG), opc); snprintf(g->Message, sizeof(g->Message), MSG(MISSING_ARG), opc);
throw (int)TYPE_ARRAY; throw (int)TYPE_ARRAY;
} else // OP_EXIST } else // OP_EXIST
return Nval > 0; return Nval > 0;
@@ -581,7 +581,7 @@ int ARRAY::Convert(PGLOBAL g, int k, PVAL vp)
Len = 1; Len = 1;
break; break;
default: default:
sprintf(g->Message, MSG(BAD_CONV_TYPE), Type); snprintf(g->Message, sizeof(g->Message), MSG(BAD_CONV_TYPE), Type);
return TYPE_ERROR; return TYPE_ERROR;
} // endswitch k } // endswitch k

View File

@@ -594,7 +594,7 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
Type = Arap->GetResultType(); Type = Arap->GetResultType();
if (Colp->GetResultType() != Type) { if (Colp->GetResultType() != Type) {
sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH)); snprintf(g->Message, sizeof(g->Message), "BLKFILIN: %s", MSG(VALTYPE_NOMATCH));
throw g->Message; throw g->Message;
} else if (Colp->GetValue()->IsCi()) } else if (Colp->GetValue()->IsCi())
Arap->SetPrecision(g, 1); // Case insensitive Arap->SetPrecision(g, 1); // Case insensitive

View File

@@ -135,7 +135,7 @@ PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng)
break; break;
} // endif pretty } // endif pretty
sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty); snprintf(g->Message, sizeof(g->Message), "Unexpected ',' (pretty=%d)", pretty);
throw 3; throw 3;
case '(': case '(':
b = true; b = true;
@@ -159,7 +159,7 @@ PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng)
}; // endswitch s[i] }; // endswitch s[i]
if (bvp->Type == TYPE_UNKNOWN) if (bvp->Type == TYPE_UNKNOWN)
sprintf(g->Message, "Invalid Json string '%.*s'", MY_MIN((int)len, 50), s); snprintf(g->Message, sizeof(g->Message), "Invalid Json string '%.*s'", MY_MIN((int)len, 50), s);
else if (pretty == 3) { else if (pretty == 3) {
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (pty[i]) { if (pty[i]) {
@@ -606,7 +606,7 @@ PSZ BDOC::Serialize(PGLOBAL g, PBVAL bvp, char* fn, int pretty)
b = pretty == 1; b = pretty == 1;
} else { } else {
if (!(fs = fopen(fn, "wb"))) { if (!(fs = fopen(fn, "wb"))) {
sprintf(g->Message, MSG(OPEN_MODE_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR),
"w", (int)errno, fn); "w", (int)errno, fn);
strcat(strcat(g->Message, ": "), strerror(errno)); strcat(strcat(g->Message, ": "), strerror(errno));
throw 2; throw 2;

View File

@@ -238,7 +238,7 @@ my_bool BJNX::SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm)
jnp->Rank = atoi(p) - B; jnp->Rank = atoi(p) - B;
jnp->Op = OP_EQ; jnp->Op = OP_EQ;
} else if (Wr) { } else if (Wr) {
sprintf(g->Message, "Invalid specification %s in a write path", p); snprintf(g->Message, sizeof(g->Message), "Invalid specification %s in a write path", p);
return true; return true;
} else if (n == 1) { } else if (n == 1) {
// Set the Op value; // Set the Op value;
@@ -251,7 +251,7 @@ my_bool BJNX::SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm)
case '#': jnp->Op = OP_NUM; break; case '#': jnp->Op = OP_NUM; break;
case '*': jnp->Op = OP_EXP; break; case '*': jnp->Op = OP_EXP; break;
default: default:
sprintf(g->Message, "Invalid function specification %c", *p); snprintf(g->Message, sizeof(g->Message), "Invalid function specification %c", *p);
return true; return true;
} // endswitch *p } // endswitch *p
@@ -287,7 +287,7 @@ my_bool BJNX::ParseJpath(PGLOBAL g)
{ {
char* p, * p1 = NULL, * p2 = NULL, * pbuf = NULL; char* p, * p1 = NULL, * p2 = NULL, * pbuf = NULL;
int i; int i;
my_bool a, mul = false; my_bool a;
if (Parsed) if (Parsed)
return false; // Already done return false; // Already done
@@ -343,7 +343,7 @@ my_bool BJNX::ParseJpath(PGLOBAL g)
} else if (*p == '*') { } else if (*p == '*') {
if (Wr) { if (Wr) {
sprintf(g->Message, "Invalid specification %c in a write path", *p); snprintf(g->Message, sizeof(g->Message), "Invalid specification %c in a write path", *p);
return true; return true;
} else // Return JSON } else // Return JSON
Nodes[i].Op = OP_XX; Nodes[i].Op = OP_XX;
@@ -541,7 +541,6 @@ PVAL BJNX::GetColumnValue(PGLOBAL g, PBVAL row, int i)
/*********************************************************************************/ /*********************************************************************************/
PBVAL BJNX::GetRowValue(PGLOBAL g, PBVAL row, int i) PBVAL BJNX::GetRowValue(PGLOBAL g, PBVAL row, int i)
{ {
my_bool expd = false;
PBVAL bap; PBVAL bap;
PBVAL vlp = NULL; PBVAL vlp = NULL;
@@ -596,7 +595,7 @@ PBVAL BJNX::GetRowValue(PGLOBAL g, PBVAL row, int i)
vlp = row; vlp = row;
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->Type); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->Type);
vlp = NULL; vlp = NULL;
} // endswitch Type } // endswitch Type
@@ -841,7 +840,7 @@ PBVAL BJNX::GetRow(PGLOBAL g)
val = MVP(row->To_Val); val = MVP(row->To_Val);
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->Type); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->Type);
val = NULL; val = NULL;
} // endswitch Type } // endswitch Type
@@ -1033,7 +1032,7 @@ my_bool BJNX::CheckPath(PGLOBAL g)
val = row; val = row;
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->Type); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->Type);
} // endswitch Type } // endswitch Type
if (i < Nod-1) if (i < Nod-1)
@@ -1062,7 +1061,7 @@ my_bool BJNX::CheckPath(PGLOBAL g, UDF_ARGS *args, PBVAL jsp, PBVAL& jvp, int n)
return true; return true;
if (!(jvp = GetJson(g))) { if (!(jvp = GetJson(g))) {
sprintf(g->Message, "No sub-item at '%s'", path); snprintf(g->Message, sizeof(g->Message), "No sub-item at '%s'", path);
return true; return true;
} else } else
return false; return false;
@@ -1084,7 +1083,7 @@ my_bool BJNX::CheckPath(PGLOBAL g, UDF_ARGS *args, PBVAL jsp, PBVAL& jvp, int n)
PSZ BJNX::Locate(PGLOBAL g, PBVAL jsp, PBVAL jvp, int k) PSZ BJNX::Locate(PGLOBAL g, PBVAL jsp, PBVAL jvp, int k)
{ {
PSZ str = NULL; PSZ str = NULL;
my_bool b = false, err = true; my_bool err = true;
g->Message[0] = 0; g->Message[0] = 0;
@@ -1205,7 +1204,7 @@ my_bool BJNX::LocateValue(PGLOBAL g, PBVAL jvp)
PSZ BJNX::LocateAll(PGLOBAL g, PBVAL jsp, PBVAL bvp, int mx) PSZ BJNX::LocateAll(PGLOBAL g, PBVAL jsp, PBVAL bvp, int mx)
{ {
PSZ str = NULL; PSZ str = NULL;
my_bool b = false, err = true; my_bool err = true;
PJPN jnp; PJPN jnp;
if (!jsp) { if (!jsp) {
@@ -1630,7 +1629,7 @@ PBVAL BJNX::ParseJsonFile(PGLOBAL g, char *fn, int& pty, size_t& len)
DWORD rc = GetLastError(); DWORD rc = GetLastError();
if (!(*g->Message)) if (!(*g->Message))
sprintf(g->Message, MSG(OPEN_MODE_ERROR), "map", (int)rc, fn); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR), "map", (int)rc, fn);
return NULL; return NULL;
} // endif hFile } // endif hFile
@@ -1650,7 +1649,7 @@ PBVAL BJNX::ParseJsonFile(PGLOBAL g, char *fn, int& pty, size_t& len)
if (!memory) { if (!memory) {
CloseFileHandle(hFile); CloseFileHandle(hFile);
sprintf(g->Message, MSG(MAP_VIEW_ERROR), fn, GetLastError()); snprintf(g->Message, sizeof(g->Message), MSG(MAP_VIEW_ERROR), fn, GetLastError());
return NULL; return NULL;
} // endif Memory } // endif Memory
@@ -3045,7 +3044,7 @@ my_bool bson_test_init(UDF_INIT* initid, UDF_ARGS* args, char* message) {
char* bson_test(UDF_INIT* initid, UDF_ARGS* args, char* result, char* bson_test(UDF_INIT* initid, UDF_ARGS* args, char* result,
unsigned long* res_length, char* is_null, char* error) { unsigned long* res_length, char* is_null, char* error) {
char* str = NULL, * sap = NULL, * fn = NULL; char* str = NULL, *fn = NULL;
int pretty = 1; int pretty = 1;
PBVAL bvp; PBVAL bvp;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
@@ -4765,7 +4764,7 @@ char *bfile_bjson(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (!fgets(buf, lrecl, fin)) { if (!fgets(buf, lrecl, fin)) {
if (!feof(fin)) { if (!feof(fin)) {
sprintf(g->Message, "Error %d reading %zd bytes from %s", snprintf(g->Message, sizeof(g->Message), "Error %d reading %zu bytes from %s",
errno, lrecl, fn); errno, lrecl, fn);
str = strcpy(result, g->Message); str = strcpy(result, g->Message);
} else } else
@@ -4777,11 +4776,11 @@ char *bfile_bjson(UDF_INIT *initid, UDF_ARGS *args, char *result,
binszp = newloc - (size_t)jsp; binszp = newloc - (size_t)jsp;
if (fwrite(&binszp, sizeof(binszp), 1, fout) != 1) { if (fwrite(&binszp, sizeof(binszp), 1, fout) != 1) {
sprintf(g->Message, "Error %d writing %zd bytes to %s", snprintf(g->Message, sizeof(g->Message), "Error %d writing %zu bytes to %s",
errno, sizeof(binszp), ofn); errno, sizeof(binszp), ofn);
str = strcpy(result, g->Message); str = strcpy(result, g->Message);
} else if (fwrite(jsp, binszp, 1, fout) != 1) { } else if (fwrite(jsp, binszp, 1, fout) != 1) {
sprintf(g->Message, "Error %d writing %zd bytes to %s", snprintf(g->Message, sizeof(g->Message), "Error %d writing %zu bytes to %s",
errno, binszp, ofn); errno, binszp, ofn);
str = strcpy(result, g->Message); str = strcpy(result, g->Message);
} else } else
@@ -5043,7 +5042,7 @@ char* bbin_array_add_values(UDF_INIT* initid, UDF_ARGS* args, char* result,
if (!CheckMemory(g, initid, args, args->arg_count, true)) { if (!CheckMemory(g, initid, args, args->arg_count, true)) {
uint i = 0; uint i = 0;
BJNX bnx(g); BJNX bnx(g);
PBVAL arp, top, jvp = NULL; PBVAL arp, top;
PBVAL bvp = bnx.MakeValue(args, 0, true, &top); PBVAL bvp = bnx.MakeValue(args, 0, true, &top);
if (bvp->Type == TYPE_JAR) { if (bvp->Type == TYPE_JAR) {
@@ -5667,7 +5666,6 @@ char *bbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (g->Xchk) { if (g->Xchk) {
bsp = (PBSON)g->Xchk; bsp = (PBSON)g->Xchk;
} else if (!CheckMemory(g, initid, args, 1, true, true)) { } else if (!CheckMemory(g, initid, args, 1, true, true)) {
char *path = MakePSZ(g, args, 1);
BJNX bnx(g, NULL, TYPE_STRING, initid->max_length); BJNX bnx(g, NULL, TYPE_STRING, initid->max_length);
PBVAL top, jvp = NULL; PBVAL top, jvp = NULL;
PBVAL jsp = bnx.MakeValue(args, 0, true, &top); PBVAL jsp = bnx.MakeValue(args, 0, true, &top);

View File

@@ -175,7 +175,7 @@ bool CMgoConn::Connect(PGLOBAL g)
Uri = mongoc_uri_new_with_error(Pcg->Uristr, &Error); Uri = mongoc_uri_new_with_error(Pcg->Uristr, &Error);
if (!Uri) { if (!Uri) {
sprintf(g->Message, "Failed to parse URI: \"%s\" Msg: %s", snprintf(g->Message, sizeof(g->Message), "Failed to parse URI: \"%s\" Msg: %s",
Pcg->Uristr, Error.message); Pcg->Uristr, Error.message);
return true; return true;
} // endif Uri } // endif Uri
@@ -196,7 +196,7 @@ bool CMgoConn::Connect(PGLOBAL g)
Client = mongoc_client_new_from_uri (Uri); Client = mongoc_client_new_from_uri (Uri);
if (!Client) { if (!Client) {
sprintf(g->Message, "Failed to get Client"); snprintf(g->Message, sizeof(g->Message), "Failed to get Client");
return true; return true;
} // endif Client } // endif Client
@@ -212,7 +212,7 @@ bool CMgoConn::Connect(PGLOBAL g)
Collection = mongoc_client_get_collection(Client, Pcg->Db_name, Pcg->Coll_name); Collection = mongoc_client_get_collection(Client, Pcg->Db_name, Pcg->Coll_name);
if (!Collection) { if (!Collection) {
sprintf(g->Message, "Failed to get Collection %s.%s", snprintf(g->Message, sizeof(g->Message), "Failed to get Collection %s.%s",
Pcg->Db_name, Pcg->Coll_name); Pcg->Db_name, Pcg->Coll_name);
return true; return true;
} // endif Collection } // endif Collection
@@ -420,7 +420,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g)
Query = bson_new_from_json((const uint8_t *)p, -1, &Error); Query = bson_new_from_json((const uint8_t *)p, -1, &Error);
if (!Query) { if (!Query) {
sprintf(g->Message, "Wrong pipeline: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "Wrong pipeline: %s", Error.message);
return true; return true;
} // endif Query } // endif Query
@@ -428,7 +428,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g)
Query, NULL, NULL); Query, NULL, NULL);
if (mongoc_cursor_error(Cursor, &Error)) { if (mongoc_cursor_error(Cursor, &Error)) {
sprintf(g->Message, "Mongo aggregate Failure: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "Mongo aggregate Failure: %s", Error.message);
return true; return true;
} // endif error } // endif error
@@ -468,7 +468,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g)
Query = bson_new_from_json((const uint8_t *)s->GetStr(), -1, &Error); Query = bson_new_from_json((const uint8_t *)s->GetStr(), -1, &Error);
if (!Query) { if (!Query) {
sprintf(g->Message, "Wrong filter: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "Wrong filter: %s", Error.message);
return true; return true;
} // endif Query } // endif Query
@@ -503,7 +503,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g)
Opts = bson_new_from_json((const uint8_t *)p, -1, &Error); Opts = bson_new_from_json((const uint8_t *)p, -1, &Error);
if (!Opts) { if (!Opts) {
sprintf(g->Message, "Wrong options: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "Wrong options: %s", Error.message);
return true; return true;
} // endif Opts } // endif Opts
@@ -532,7 +532,7 @@ int CMgoConn::ReadNext(PGLOBAL g)
htrc("%s\n", GetDocument(g)); htrc("%s\n", GetDocument(g));
} else if (mongoc_cursor_error(Cursor, &Error)) { } else if (mongoc_cursor_error(Cursor, &Error)) {
sprintf(g->Message, "Mongo Cursor Failure: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "Mongo Cursor Failure: %s", Error.message);
rc = RC_FX; rc = RC_FX;
} else } else
rc = RC_EF; rc = RC_EF;
@@ -683,7 +683,7 @@ int CMgoConn::Write(PGLOBAL g)
if (!mongoc_collection_insert(Collection, MONGOC_INSERT_NONE, if (!mongoc_collection_insert(Collection, MONGOC_INSERT_NONE,
Fpc->Child, NULL, &Error)) { Fpc->Child, NULL, &Error)) {
sprintf(g->Message, "Mongo insert: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "Mongo insert: %s", Error.message);
rc = RC_FX; rc = RC_FX;
} // endif insert } // endif insert
@@ -698,11 +698,11 @@ int CMgoConn::Write(PGLOBAL g)
} // endif trace } // endif trace
if (!doc) { if (!doc) {
sprintf(g->Message, "bson_new_from_json: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "bson_new_from_json: %s", Error.message);
rc = RC_FX; rc = RC_FX;
} else if (!mongoc_collection_insert(Collection, } else if (!mongoc_collection_insert(Collection,
MONGOC_INSERT_NONE, doc, NULL, &Error)) { MONGOC_INSERT_NONE, doc, NULL, &Error)) {
sprintf(g->Message, "Mongo insert: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "Mongo insert: %s", Error.message);
bson_destroy(doc); bson_destroy(doc);
rc = RC_FX; rc = RC_FX;
} // endif insert } // endif insert
@@ -759,14 +759,14 @@ int CMgoConn::Write(PGLOBAL g)
if (rc == RC_OK) if (rc == RC_OK)
if (!mongoc_collection_update(Collection, MONGOC_UPDATE_NONE, if (!mongoc_collection_update(Collection, MONGOC_UPDATE_NONE,
query, update, NULL, &Error)) { query, update, NULL, &Error)) {
sprintf(g->Message, "Mongo update: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "Mongo update: %s", Error.message);
rc = RC_FX; rc = RC_FX;
} // endif update } // endif update
bson_destroy(update); bson_destroy(update);
} else if (!mongoc_collection_remove(Collection, } else if (!mongoc_collection_remove(Collection,
MONGOC_REMOVE_SINGLE_REMOVE, query, NULL, &Error)) { MONGOC_REMOVE_SINGLE_REMOVE, query, NULL, &Error)) {
sprintf(g->Message, "Mongo delete: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "Mongo delete: %s", Error.message);
rc = RC_FX; rc = RC_FX;
} // endif remove } // endif remove
@@ -790,7 +790,7 @@ bool CMgoConn::DocDelete(PGLOBAL g)
if (!mongoc_collection_remove(Collection, MONGOC_REMOVE_NONE, if (!mongoc_collection_remove(Collection, MONGOC_REMOVE_NONE,
Query, NULL, &Error)) { Query, NULL, &Error)) {
sprintf(g->Message, "Mongo remove all: %s", Error.message); snprintf(g->Message, sizeof(g->Message), "Mongo remove all: %s", Error.message);
return true; return true;
} // endif remove } // endif remove
@@ -843,7 +843,7 @@ char *CMgoConn::Mini(PGLOBAL g, PCOL colp, const bson_t *bson, bool b)
s = str = bson_as_json(bson, &len); s = str = bson_as_json(bson, &len);
if (len > (size_t)colp->GetLength()) { if (len > (size_t)colp->GetLength()) {
sprintf(g->Message, "Value too long for column %s", colp->GetName()); snprintf(g->Message, sizeof(g->Message), "Value too long for column %s", colp->GetName());
bson_free(str); bson_free(str);
throw (int)TYPE_AM_MGO; throw (int)TYPE_AM_MGO;
} // endif len } // endif len
@@ -1061,7 +1061,7 @@ bool CMgoConn::AddValue(PGLOBAL g, PCOL colp, bson_t *doc, char *key, bool upd)
rc = BSON_APPEND_DATE_TIME(doc, key, value->GetBigintValue() * 1000); rc = BSON_APPEND_DATE_TIME(doc, key, value->GetBigintValue() * 1000);
break; break;
default: default:
sprintf(g->Message, "Type %d not supported yet", colp->GetResultType()); snprintf(g->Message, sizeof(g->Message), "Type %d not supported yet", colp->GetResultType());
return true; return true;
} // endswitch Buf_Type } // endswitch Buf_Type

View File

@@ -178,7 +178,7 @@ bool COLBLK::InitValue(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
bool COLBLK::SetBuffer(PGLOBAL g, PVAL, bool, bool) bool COLBLK::SetBuffer(PGLOBAL g, PVAL, bool, bool)
{ {
sprintf(g->Message, MSG(UNDEFINED_AM), "SetBuffer"); snprintf(g->Message, sizeof(g->Message), MSG(UNDEFINED_AM), "SetBuffer");
return true; return true;
} // end of SetBuffer } // end of SetBuffer
@@ -197,7 +197,7 @@ int COLBLK::GetLengthEx(void)
/***********************************************************************/ /***********************************************************************/
void COLBLK::ReadColumn(PGLOBAL g) void COLBLK::ReadColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn"); snprintf(g->Message, sizeof(g->Message), MSG(UNDEFINED_AM), "ReadColumn");
throw (int)TYPE_COLBLK; throw (int)TYPE_COLBLK;
} // end of ReadColumn } // end of ReadColumn
@@ -208,7 +208,7 @@ void COLBLK::ReadColumn(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
void COLBLK::WriteColumn(PGLOBAL g) void COLBLK::WriteColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn"); snprintf(g->Message, sizeof(g->Message), MSG(UNDEFINED_AM), "WriteColumn");
throw (int)TYPE_COLBLK; throw (int)TYPE_COLBLK;
} // end of WriteColumn } // end of WriteColumn
@@ -262,7 +262,7 @@ SPCBLK::SPCBLK(PCOLUMN cp)
/***********************************************************************/ /***********************************************************************/
void SPCBLK::WriteColumn(PGLOBAL g) void SPCBLK::WriteColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(SPCOL_READONLY), Name); snprintf(g->Message, sizeof(g->Message), MSG(SPCOL_READONLY), Name);
throw (int)TYPE_COLBLK; throw (int)TYPE_COLBLK;
} // end of WriteColumn } // end of WriteColumn

View File

@@ -148,7 +148,7 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
/*********************************************************************/ /*********************************************************************/
/* All is correct. */ /* All is correct. */
/*********************************************************************/ /*********************************************************************/
sprintf(g->Message, MSG(DATABASE_LOADED), "???"); snprintf(g->Message, sizeof(g->Message), MSG(DATABASE_LOADED), "???");
if (trace(1)) if (trace(1))
printf("msg=%s\n", g->Message); printf("msg=%s\n", g->Message);
@@ -268,7 +268,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
if (!colp && !(mode == MODE_INSERT && tdbp->IsSpecial(p))) { if (!colp && !(mode == MODE_INSERT && tdbp->IsSpecial(p))) {
if (g->Message[0] == 0) if (g->Message[0] == 0)
sprintf(g->Message, MSG(COL_ISNOT_TABLE), p, tdbp->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(COL_ISNOT_TABLE), p, tdbp->GetName());
throw 1; throw 1;
} // endif colp } // endif colp
@@ -297,7 +297,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
PTDBASE utp; PTDBASE utp;
if (!(utp = (PTDBASE)tdbp->Duplicate(g))) { if (!(utp = (PTDBASE)tdbp->Duplicate(g))) {
sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(INV_UPDT_TABLE), tdbp->GetName());
throw 4; throw 4;
} // endif tp } // endif tp
@@ -626,7 +626,7 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
if (!ptdb) if (!ptdb)
return -1; return -1;
else if (!ptdb->GetDef()->Indexable()) { else if (!ptdb->GetDef()->Indexable()) {
sprintf(g->Message, MSG(TABLE_NO_INDEX), ptdb->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(TABLE_NO_INDEX), ptdb->GetName());
return 0; return 0;
} else if (ptdb->GetDef()->Indexable() == 3) { } else if (ptdb->GetDef()->Indexable() == 3) {
return 1; return 1;
@@ -657,7 +657,7 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
break; break;
if (!xdp) { if (!xdp) {
sprintf(g->Message, "Wrong index ID %d", id); snprintf(g->Message, sizeof(g->Message), "Wrong index ID %d", id);
return 0; return 0;
} // endif xdp } // endif xdp
@@ -716,7 +716,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
x= ptdb->GetDef()->Indexable(); x= ptdb->GetDef()->Indexable();
if (!x) { if (!x) {
sprintf(g->Message, MSG(TABLE_NO_INDEX), ptdb->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(TABLE_NO_INDEX), ptdb->GetName());
return RC_FX; return RC_FX;
} else if (x == 2) { } else if (x == 2) {
// Remote index. Only used in read mode // Remote index. Only used in read mode
@@ -739,13 +739,13 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
// Set reference values and index operator // Set reference values and index operator
if (!tdbp->GetLink() || !tdbp->GetKindex()) { if (!tdbp->GetLink() || !tdbp->GetKindex()) {
// if (!tdbp->To_Xdp) { // if (!tdbp->To_Xdp) {
sprintf(g->Message, "Index not initialized for table %s", tdbp->GetName()); snprintf(g->Message, sizeof(g->Message), "Index not initialized for table %s", tdbp->GetName());
return RC_FX; return RC_FX;
#if 0 #if 0
} // endif !To_Xdp } // endif !To_Xdp
// Now it's time to make the dynamic index // Now it's time to make the dynamic index
if (tdbp->InitialyzeIndex(g, NULL, false)) { if (tdbp->InitialyzeIndex(g, NULL, false)) {
sprintf(g->Message, "Fail to make dynamic index %s", snprintf(g->Message, sizeof(g->Message), "Fail to make dynamic index %s",
tdbp->To_Xdp->GetName()); tdbp->To_Xdp->GetName());
return RC_FX; return RC_FX;
} // endif MakeDynamicIndex } // endif MakeDynamicIndex
@@ -785,10 +785,10 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
if (rcb) { if (rcb) {
if (tdbp->RowNumber(g)) if (tdbp->RowNumber(g))
sprintf(g->Message, "Out of range value for column %s at row %d", snprintf(g->Message, sizeof(g->Message), "Out of range value for column %s at row %d",
colp->GetName(), tdbp->RowNumber(g)); colp->GetName(), tdbp->RowNumber(g));
else else
sprintf(g->Message, "Out of range value for column %s", snprintf(g->Message, sizeof(g->Message), "Out of range value for column %s",
colp->GetName()); colp->GetName());
PushWarning(g, tdbp); PushWarning(g, tdbp);
@@ -847,7 +847,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
x= ptdb->GetDef()->Indexable(); x= ptdb->GetDef()->Indexable();
if (!x) { if (!x) {
sprintf(g->Message, MSG(TABLE_NO_INDEX), ptdb->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(TABLE_NO_INDEX), ptdb->GetName());
DBUG_PRINT("Range", ("%s", g->Message)); DBUG_PRINT("Range", ("%s", g->Message));
return -1; return -1;
} else if (x == 2) { } else if (x == 2) {
@@ -867,7 +867,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
if (!tdbp->GetKindex() || !tdbp->GetLink()) { if (!tdbp->GetKindex() || !tdbp->GetLink()) {
if (!tdbp->GetXdp()) { if (!tdbp->GetXdp()) {
sprintf(g->Message, "Index not initialized for table %s", tdbp->GetName()); snprintf(g->Message, sizeof(g->Message), "Index not initialized for table %s", tdbp->GetName());
DBUG_PRINT("Range", ("%s", g->Message)); DBUG_PRINT("Range", ("%s", g->Message));
return -1; return -1;
} else // Dynamic index } else // Dynamic index
@@ -908,11 +908,11 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
if (rcb) { if (rcb) {
if (tdbp->RowNumber(g)) if (tdbp->RowNumber(g))
sprintf(g->Message, snprintf(g->Message, sizeof(g->Message),
"Out of range value for column %s at row %d", "Out of range value for column %s at row %d",
colp->GetName(), tdbp->RowNumber(g)); colp->GetName(), tdbp->RowNumber(g));
else else
sprintf(g->Message, "Out of range value for column %s", snprintf(g->Message, sizeof(g->Message), "Out of range value for column %s",
colp->GetName()); colp->GetName());
PushWarning(g, tdbp); PushWarning(g, tdbp);

View File

@@ -33,7 +33,7 @@ using namespace MSXML2;
inline bool TestHr(PGLOBAL g, HRESULT hr) inline bool TestHr(PGLOBAL g, HRESULT hr)
{ {
if FAILED(hr) { if FAILED(hr) {
sprintf(g->Message, "%s, hr=%d", MSG(COM_ERROR), hr); snprintf(g->Message, sizeof(g->Message), "%s, hr=%d", MSG(COM_ERROR), hr);
return true; return true;
} else } else
return false; return false;
@@ -65,7 +65,7 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all)
} catch(_com_error e) { } catch(_com_error e) {
char *p = _com_util::ConvertBSTRToString(e.Description()); char *p = _com_util::ConvertBSTRToString(e.Description());
sprintf(g->Message, "%s %s", MSG(COM_ERROR), p); snprintf(g->Message, sizeof(g->Message), "%s %s", MSG(COM_ERROR), p);
delete[] p; delete[] p;
} catch(...) {} } catch(...) {}
@@ -242,7 +242,7 @@ int DOMDOC::DumpDoc(PGLOBAL g, char *ofn)
try { try {
Docp->save(ofn); Docp->save(ofn);
} catch(_com_error e) { } catch(_com_error e) {
sprintf(g->Message, "%s: %s", MSG(COM_ERROR), snprintf(g->Message, sizeof(g->Message), "%s: %s", MSG(COM_ERROR),
_com_util::ConvertBSTRToString(e.Description())); _com_util::ConvertBSTRToString(e.Description()));
rc = -1; rc = -1;
} catch(...) {} } catch(...) {}
@@ -332,16 +332,16 @@ RCODE DOMNODE::GetContent(PGLOBAL g, char *buf, int len)
switch (lsr) { switch (lsr) {
case 0: case 0:
case ERROR_INSUFFICIENT_BUFFER: // 122L case ERROR_INSUFFICIENT_BUFFER: // 122L
sprintf(g->Message, "Truncated %s content", GetName(g)); snprintf(g->Message, sizeof(g->Message), "Truncated %s content", GetName(g));
rc = RC_INFO; rc = RC_INFO;
break; break;
case ERROR_NO_UNICODE_TRANSLATION: // 1113L case ERROR_NO_UNICODE_TRANSLATION: // 1113L
sprintf(g->Message, "Invalid character(s) in %s content", snprintf(g->Message, sizeof(g->Message), "Invalid character(s) in %s content",
GetName(g)); GetName(g));
rc = RC_INFO; rc = RC_INFO;
break; break;
default: default:
sprintf(g->Message, "System error getting %s content", snprintf(g->Message, sizeof(g->Message), "System error getting %s content",
GetName(g)); GetName(g));
rc = RC_FX; rc = RC_FX;
break; break;
@@ -370,7 +370,7 @@ bool DOMNODE::SetContent(PGLOBAL g, char *txtp, int len)
if (!MultiByteToWideChar(CP_UTF8, 0, txtp, strlen(txtp) + 1, if (!MultiByteToWideChar(CP_UTF8, 0, txtp, strlen(txtp) + 1,
Ws, Len + 1)) { Ws, Len + 1)) {
sprintf(g->Message, MSG(WS_CONV_ERR), txtp); snprintf(g->Message, sizeof(g->Message), MSG(WS_CONV_ERR), txtp);
return true; return true;
} // endif } // endif
@@ -451,7 +451,7 @@ PXNODE DOMNODE::SelectSingleNode(PGLOBAL g, char *xp, PXNODE np)
} // endif dnp } // endif dnp
} catch(_com_error e) { } catch(_com_error e) {
sprintf(g->Message, "%s: %s", MSG(COM_ERROR), snprintf(g->Message, sizeof(g->Message), "%s: %s", MSG(COM_ERROR),
_com_util::ConvertBSTRToString(e.Description())); _com_util::ConvertBSTRToString(e.Description()));
} catch(...) {} } catch(...) {}
@@ -710,16 +710,16 @@ RCODE DOMATTR::GetText(PGLOBAL g, char *buf, int len)
switch (lsr) { switch (lsr) {
case 0: case 0:
case ERROR_INSUFFICIENT_BUFFER: // 122L case ERROR_INSUFFICIENT_BUFFER: // 122L
sprintf(g->Message, "Truncated %s content", GetName(g)); snprintf(g->Message, sizeof(g->Message), "Truncated %s content", GetName(g));
rc = RC_INFO; rc = RC_INFO;
break; break;
case ERROR_NO_UNICODE_TRANSLATION: // 1113L case ERROR_NO_UNICODE_TRANSLATION: // 1113L
sprintf(g->Message, "Invalid character(s) in %s content", snprintf(g->Message, sizeof(g->Message), "Invalid character(s) in %s content",
GetName(g)); GetName(g));
rc = RC_INFO; rc = RC_INFO;
break; break;
default: default:
sprintf(g->Message, "System error getting %s content", snprintf(g->Message, sizeof(g->Message), "System error getting %s content",
GetName(g)); GetName(g));
rc = RC_FX; rc = RC_FX;
break; break;
@@ -745,7 +745,7 @@ bool DOMATTR::SetText(PGLOBAL g, char *txtp, int len)
if (!MultiByteToWideChar(CP_UTF8, 0, txtp, strlen(txtp) + 1, if (!MultiByteToWideChar(CP_UTF8, 0, txtp, strlen(txtp) + 1,
Ws, Len + 1)) { Ws, Len + 1)) {
sprintf(g->Message, MSG(WS_CONV_ERR), txtp); snprintf(g->Message, sizeof(g->Message), MSG(WS_CONV_ERR), txtp);
return true; return true;
} // endif } // endif

View File

@@ -163,7 +163,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
DWORD rc = GetLastError(); DWORD rc = GetLastError();
if (!(*g->Message)) if (!(*g->Message))
sprintf(g->Message, MSG(OPEN_MODE_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR),
"map", (int) rc, filename); "map", (int) rc, filename);
if (trace(1)) if (trace(1))
@@ -192,7 +192,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
if (!Memory) { if (!Memory) {
CloseFileHandle(hFile); CloseFileHandle(hFile);
sprintf(g->Message, MSG(MAP_VIEW_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(MAP_VIEW_ERROR),
filename, GetLastError()); filename, GetLastError());
return true; return true;
} // endif Memory } // endif Memory
@@ -472,7 +472,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
if (drc == 0xFFFFFFFF) { if (drc == 0xFFFFFFFF) {
sprintf(g->Message, MSG(FUNCTION_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(FUNCTION_ERROR),
"SetFilePointer", GetLastError()); "SetFilePointer", GetLastError());
CloseHandle(fp->Handle); CloseHandle(fp->Handle);
return RC_FX; return RC_FX;
@@ -482,7 +482,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc); htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
if (!SetEndOfFile(fp->Handle)) { if (!SetEndOfFile(fp->Handle)) {
sprintf(g->Message, MSG(FUNCTION_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(FUNCTION_ERROR),
"SetEndOfFile", GetLastError()); "SetEndOfFile", GetLastError());
CloseHandle(fp->Handle); CloseHandle(fp->Handle);
return RC_FX; return RC_FX;
@@ -490,7 +490,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
#else // UNIX #else // UNIX
if (ftruncate(fp->Handle, (off_t)n)) { if (ftruncate(fp->Handle, (off_t)n)) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(TRUNCATE_ERROR), strerror(errno));
close(fp->Handle); close(fp->Handle);
return RC_FX; return RC_FX;
} // endif } // endif

View File

@@ -157,7 +157,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PCSZ fn, DBFHEADER *buf)
// Check last byte(s) of header // Check last byte(s) of header
if (fseek(file, buf->Headlen() - dbc, SEEK_SET) != 0) { if (fseek(file, buf->Headlen() - dbc, SEEK_SET) != 0) {
sprintf(g->Message, MSG(BAD_HEADER), fn); snprintf(g->Message, sizeof(g->Message), MSG(BAD_HEADER), fn);
return RC_FX; return RC_FX;
} // endif fseek } // endif fseek
@@ -168,7 +168,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PCSZ fn, DBFHEADER *buf)
// Some files have just 1D others have 1D00 following fields // Some files have just 1D others have 1D00 following fields
if (endmark[0] != EOH && endmark[1] != EOH) { if (endmark[0] != EOH && endmark[1] != EOH) {
sprintf(g->Message, MSG(NO_0DH_HEAD), dbc); snprintf(g->Message, sizeof(g->Message), MSG(NO_0DH_HEAD), dbc);
if (rc == RC_OK) if (rc == RC_OK)
return RC_FX; return RC_FX;
@@ -214,7 +214,7 @@ static int dbfields(PGLOBAL g, DBFHEADER* hdrp)
// Some headers just have 1D others have 1D00 following fields // Some headers just have 1D others have 1D00 following fields
if (endmark[0] != EOH && endmark[1] != EOH) { if (endmark[0] != EOH && endmark[1] != EOH) {
sprintf(g->Message, MSG(NO_0DH_HEAD), dbc); snprintf(g->Message, sizeof(g->Message), MSG(NO_0DH_HEAD), dbc);
if (rc == RC_OK) if (rc == RC_OK)
return RC_FX; return RC_FX;
@@ -352,7 +352,7 @@ PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, PTOS topt, bool info)
if (topt->zipped) { if (topt->zipped) {
tfp = (DESCRIPTOR*)((char*)tfp + HEADLEN); tfp = (DESCRIPTOR*)((char*)tfp + HEADLEN);
} else if (fread(tfp, HEADLEN, 1, infile) != 1) { } else if (fread(tfp, HEADLEN, 1, infile) != 1) {
sprintf(g->Message, MSG(ERR_READING_REC), field+1, fn); snprintf(g->Message, sizeof(g->Message), MSG(ERR_READING_REC), field+1, fn);
goto err; goto err;
} // endif fread } // endif fread
@@ -393,7 +393,7 @@ PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, PTOS topt, bool info)
break; break;
default: default:
if (!info) { if (!info) {
sprintf(g->Message, MSG(BAD_DBF_TYPE), tfp->Type snprintf(g->Message, sizeof(g->Message), MSG(BAD_DBF_TYPE), tfp->Type
, tfp->Name); , tfp->Name);
goto err; goto err;
} // endif info } // endif info
@@ -542,7 +542,7 @@ int DBFFAM::Cardinality(PGLOBAL g)
if (rln && Lrecl != rln) { if (rln && Lrecl != rln) {
// This happens always on some Linux platforms // This happens always on some Linux platforms
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, (ushort)rln); snprintf(g->Message, sizeof(g->Message), MSG(BAD_LRECL), Lrecl, (ushort)rln);
if (Accept) { if (Accept) {
Lrecl = rln; Lrecl = rln;
@@ -609,7 +609,7 @@ bool DBFFAM::OpenTableFile(PGLOBAL g)
strcpy(opmode, "a+"); strcpy(opmode, "a+");
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
return true; return true;
} // endswitch Mode } // endswitch Mode
@@ -656,7 +656,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
/* translating 0A bytes (LF) into 0D0A (CRLF) by Windows in text mode. */ /* translating 0A bytes (LF) into 0D0A (CRLF) by Windows in text mode. */
/************************************************************************/ /************************************************************************/
if (_setmode(_fileno(Stream), _O_BINARY) == -1) { if (_setmode(_fileno(Stream), _O_BINARY) == -1) {
sprintf(g->Message, MSG(BIN_MODE_FAIL), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(BIN_MODE_FAIL), strerror(errno));
return true; return true;
} // endif setmode } // endif setmode
#endif // _WIN32 #endif // _WIN32
@@ -685,7 +685,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
} // endif Flags } // endif Flags
if (Lrecl != reclen) { if (Lrecl != reclen) {
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, reclen); snprintf(g->Message, sizeof(g->Message), MSG(BAD_LRECL), Lrecl, reclen);
if (Accept) { if (Accept) {
Lrecl = reclen; Lrecl = reclen;
@@ -727,7 +727,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
case 'D': // Date case 'D': // Date
break; break;
default: // Should never happen default: // Should never happen
sprintf(g->Message, MSG(BAD_DBF_TYPE), snprintf(g->Message, sizeof(g->Message), MSG(BAD_DBF_TYPE),
c, cdp->GetName()); c, cdp->GetName());
return true; return true;
} // endswitch c } // endswitch c
@@ -741,7 +741,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
// Now write the header // Now write the header
if (fwrite(header, 1, hlen, Stream) != (unsigned)hlen) { if (fwrite(header, 1, hlen, Stream) != (unsigned)hlen) {
sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FWRITE_ERROR), strerror(errno));
return true; return true;
} // endif fwrite } // endif fwrite
@@ -769,7 +769,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
if ((rc = dbfhead(g, Stream, Tdbp->GetFile(g), &header)) == RC_OK) { if ((rc = dbfhead(g, Stream, Tdbp->GetFile(g), &header)) == RC_OK) {
if (Lrecl != (int)header.Reclen()) { if (Lrecl != (int)header.Reclen()) {
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, header.Reclen()); snprintf(g->Message, sizeof(g->Message), MSG(BAD_LRECL), Lrecl, header.Reclen());
if (Accept) { if (Accept) {
Lrecl = header.Reclen(); Lrecl = header.Reclen();
@@ -799,7 +799,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
rc = fseek(Stream, Headlen, SEEK_SET); rc = fseek(Stream, Headlen, SEEK_SET);
if (rc) { if (rc) {
sprintf(g->Message, MSG(BAD_DBF_FILE), Tdbp->GetFile(g)); snprintf(g->Message, sizeof(g->Message), MSG(BAD_DBF_FILE), Tdbp->GetFile(g));
return true; return true;
} // endif fseek } // endif fseek
@@ -857,7 +857,7 @@ int DBFFAM::ReadBuffer(PGLOBAL g)
break; break;
default: default:
if (++Nerr >= Maxerr && !Accept) { if (++Nerr >= Maxerr && !Accept) {
sprintf(g->Message, MSG(BAD_DBF_REC), Tdbp->GetFile(g), GetRowID()); snprintf(g->Message, sizeof(g->Message), MSG(BAD_DBF_REC), Tdbp->GetFile(g), GetRowID());
rc = RC_FX; rc = RC_FX;
} else } else
rc = (Accept) ? RC_OK : RC_NF; rc = (Accept) ? RC_OK : RC_NF;
@@ -882,9 +882,9 @@ bool DBFFAM::CopyHeader(PGLOBAL g)
if (fseek(Stream, 0, SEEK_SET)) if (fseek(Stream, 0, SEEK_SET))
strcpy(g->Message, "Seek error in CopyHeader"); strcpy(g->Message, "Seek error in CopyHeader");
else if ((n = fread(hdr, 1, hlen, Stream)) != hlen) else if ((n = fread(hdr, 1, hlen, Stream)) != hlen)
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, To_File); snprintf(g->Message, sizeof(g->Message), MSG(BAD_READ_NUMBER), (int) n, To_File);
else if ((n = fwrite(hdr, 1, hlen, T_Stream)) != hlen) else if ((n = fwrite(hdr, 1, hlen, T_Stream)) != hlen)
sprintf(g->Message, MSG(WRITE_STRERROR), To_Fbt->Fname snprintf(g->Message, sizeof(g->Message), MSG(WRITE_STRERROR), To_Fbt->Fname
, strerror(errno)); , strerror(errno));
else if (fseek(Stream, pos, SEEK_SET)) else if (fseek(Stream, pos, SEEK_SET))
strcpy(g->Message, "Seek error in CopyHeader"); strcpy(g->Message, "Seek error in CopyHeader");
@@ -910,16 +910,16 @@ int DBFFAM::InitDelete(PGLOBAL g, int fpos, int spos)
if (Nrec != 1) if (Nrec != 1)
strcpy(g->Message, "Cannot delete in block mode"); strcpy(g->Message, "Cannot delete in block mode");
else if (fseek(Stream, Headlen + fpos * Lrecl, SEEK_SET)) else if (fseek(Stream, Headlen + fpos * Lrecl, SEEK_SET))
sprintf(g->Message, MSG(FSETPOS_ERROR), 0); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), 0);
else if (fread(To_Buf, 1, lrecl, Stream) != lrecl) else if (fread(To_Buf, 1, lrecl, Stream) != lrecl)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, strerror(errno));
else else
*To_Buf = '*'; *To_Buf = '*';
if (fseek(Stream, Headlen + fpos * Lrecl, SEEK_SET)) if (fseek(Stream, Headlen + fpos * Lrecl, SEEK_SET))
sprintf(g->Message, MSG(FSETPOS_ERROR), 0); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), 0);
else if (fwrite(To_Buf, 1, lrecl, Stream) != lrecl) else if (fwrite(To_Buf, 1, lrecl, Stream) != lrecl)
sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FWRITE_ERROR), strerror(errno));
else else
rc = RC_NF; // Ok, Nothing else to do rc = RC_NF; // Ok, Nothing else to do
@@ -1062,7 +1062,7 @@ int DBMFAM::Cardinality(PGLOBAL g)
if (rln && Lrecl != rln) { if (rln && Lrecl != rln) {
// This happens always on some Linux platforms // This happens always on some Linux platforms
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, (ushort)rln); snprintf(g->Message, sizeof(g->Message), MSG(BAD_LRECL), Lrecl, (ushort)rln);
if (Accept) { if (Accept) {
Lrecl = rln; Lrecl = rln;
@@ -1115,7 +1115,7 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
DBFHEADER *hp = (DBFHEADER*)Memory; DBFHEADER *hp = (DBFHEADER*)Memory;
if (Lrecl != (int)hp->Reclen()) { if (Lrecl != (int)hp->Reclen()) {
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, hp->Reclen()); snprintf(g->Message, sizeof(g->Message), MSG(BAD_LRECL), Lrecl, hp->Reclen());
if (Accept) { if (Accept) {
Lrecl = hp->Reclen(); Lrecl = hp->Reclen();
@@ -1168,7 +1168,7 @@ int DBMFAM::ReadBuffer(PGLOBAL g)
break; break;
default: default:
if (++Nerr >= Maxerr && !Accept) { if (++Nerr >= Maxerr && !Accept) {
sprintf(g->Message, MSG(BAD_DBF_REC), Tdbp->GetFile(g), GetRowID()); snprintf(g->Message, sizeof(g->Message), MSG(BAD_DBF_REC), Tdbp->GetFile(g), GetRowID());
rc = RC_FX; rc = RC_FX;
} else } else
rc = (Accept) ? RC_OK : RC_NF; rc = (Accept) ? RC_OK : RC_NF;

View File

@@ -238,10 +238,10 @@ int FIXFAM::WriteModifiedBlock(PGLOBAL g)
// Fpos is last position, Headlen is DBF file header length // Fpos is last position, Headlen is DBF file header length
else if (!moved && fseek(Stream, Headlen + Fpos * Lrecl, SEEK_SET)) { else if (!moved && fseek(Stream, Headlen + Fpos * Lrecl, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), 0); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), 0);
rc = RC_FX; rc = RC_FX;
} else if (fwrite(To_Buf, Lrecl, Rbuf, T_Stream) != (size_t)Rbuf) { } else if (fwrite(To_Buf, Lrecl, Rbuf, T_Stream) != (size_t)Rbuf) {
sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FWRITE_ERROR), strerror(errno));
rc = RC_FX; rc = RC_FX;
} else } else
Spos = Fpos + Nrec; // + Rbuf ??? Spos = Fpos + Nrec; // + Rbuf ???
@@ -318,7 +318,7 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
if (CurBlk != OldBlk + 1) if (CurBlk != OldBlk + 1)
// Note: Headlen is for DBF tables // Note: Headlen is for DBF tables
if (fseek(Stream, Headlen + Fpos * Lrecl, SEEK_SET)) { if (fseek(Stream, Headlen + Fpos * Lrecl, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), Fpos); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), Fpos);
return RC_FX; return RC_FX;
} // endif fseek } // endif fseek
@@ -339,9 +339,9 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
rc = RC_EF; rc = RC_EF;
} else { } else {
#if defined(_WIN32) #if defined(_WIN32)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, _strerror(NULL));
#else #else
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, strerror(errno));
#endif #endif
if (trace(1)) if (trace(1))
@@ -379,7 +379,7 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
// Now start the writing process. // Now start the writing process.
if (fwrite(To_Buf, Lrecl, Rbuf, Stream) != (size_t)Rbuf) { if (fwrite(To_Buf, Lrecl, Rbuf, Stream) != (size_t)Rbuf) {
sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FWRITE_ERROR), strerror(errno));
Closing = true; // To tell CloseDB about a Write error Closing = true; // To tell CloseDB about a Write error
return RC_FX; return RC_FX;
} // endif size } // endif size
@@ -484,7 +484,7 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
if (moved) { if (moved) {
if (fseek(Stream, Spos * Lrecl, SEEK_SET)) { if (fseek(Stream, Spos * Lrecl, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), 0); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), 0);
return RC_FX; return RC_FX;
} // endif fseek } // endif fseek
@@ -526,13 +526,13 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/ /*****************************************************************/
#if defined(UNIX) #if defined(UNIX)
if (ftruncate(h, (off_t)(Tpos * Lrecl))) { if (ftruncate(h, (off_t)(Tpos * Lrecl))) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(TRUNCATE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
#else #else
if (chsize(h, Tpos * Lrecl)) { if (chsize(h, Tpos * Lrecl)) {
sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(CHSIZE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -565,7 +565,7 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
/*******************************************************************/ /*******************************************************************/
if (!UseTemp || !*b) if (!UseTemp || !*b)
if (fseek(Stream, Headlen + Spos * Lrecl, SEEK_SET)) { if (fseek(Stream, Headlen + Spos * Lrecl, SEEK_SET)) {
sprintf(g->Message, MSG(READ_SEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_SEEK_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -576,18 +576,18 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
htrc("after read req=%d len=%d\n", req, len); htrc("after read req=%d len=%d\n", req, len);
if (len != req) { if (len != req) {
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len); snprintf(g->Message, sizeof(g->Message), MSG(DEL_READ_ERROR), (int) req, (int) len);
return true; return true;
} // endif len } // endif len
if (!UseTemp) // Delete mode, cannot be a DBF file if (!UseTemp) // Delete mode, cannot be a DBF file
if (fseek(T_Stream, Tpos * Lrecl, SEEK_SET)) { if (fseek(T_Stream, Tpos * Lrecl, SEEK_SET)) {
sprintf(g->Message, MSG(WRITE_SEEK_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_SEEK_ERR), strerror(errno));
return true; return true;
} // endif } // endif
if ((len = fwrite(DelBuf, Lrecl, req, T_Stream)) != req) { if ((len = fwrite(DelBuf, Lrecl, req, T_Stream)) != req) {
sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(DEL_WRITE_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -691,13 +691,12 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
sprintf(g->Message, MSG(SFP_ERROR), buf); snprintf(g->Message, sizeof(g->Message), MSG(SFP_ERROR), buf);
return true; return true;
} // endif } // endif
#else // !_WIN32 #else // !_WIN32
if (lseek64(h, pos, org) < 0) { if (lseek64(h, pos, org) < 0) {
// sprintf(g->Message, MSG(ERROR_IN_LSK), errno); snprintf(g->Message, sizeof(g->Message), "lseek64: %s", strerror(errno));
sprintf(g->Message, "lseek64: %s", strerror(errno));
printf("%s\n", g->Message); printf("%s\n", g->Message);
return true; return true;
} // endif } // endif
@@ -728,7 +727,7 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)),
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
sprintf(g->Message, MSG(READ_ERROR), To_File, buf); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, buf);
if (trace(2)) if (trace(2))
htrc("BIGREAD: %s\n", g->Message); htrc("BIGREAD: %s\n", g->Message);
@@ -773,7 +772,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
} // endelse brc } // endelse brc
sprintf(g->Message, MSG(WRITE_STRERROR), fn, buf); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_STRERROR), fn, buf);
if (trace(2)) if (trace(2))
htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n", htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
@@ -788,7 +787,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
if (nbw != (ssize_t)len) { if (nbw != (ssize_t)len) {
const char *fn = (h == Hfile) ? To_File : "Tempfile"; const char *fn = (h == Hfile) ? To_File : "Tempfile";
sprintf(g->Message, MSG(WRITE_STRERROR), fn, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_STRERROR), fn, strerror(errno));
if (trace(2)) if (trace(2))
htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n", htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
@@ -822,7 +821,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
PDBUSER dbuserp = PlgGetUser(g); PDBUSER dbuserp = PlgGetUser(g);
if ((To_Fb && To_Fb->Count) || Hfile != INVALID_HANDLE_VALUE) { if ((To_Fb && To_Fb->Count) || Hfile != INVALID_HANDLE_VALUE) {
sprintf(g->Message, MSG(FILE_OPEN_YET), To_File); snprintf(g->Message, sizeof(g->Message), MSG(FILE_OPEN_YET), To_File);
return true; return true;
} // endif } // endif
@@ -871,7 +870,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
creation = OPEN_ALWAYS; creation = OPEN_ALWAYS;
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
return true; return true;
} // endswitch } // endswitch
@@ -880,7 +879,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
if (Hfile == INVALID_HANDLE_VALUE) { if (Hfile == INVALID_HANDLE_VALUE) {
rc = GetLastError(); rc = GetLastError();
sprintf(g->Message, MSG(OPEN_ERROR), rc, mode, filename); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_ERROR), rc, mode, filename);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)filename, sizeof(filename), NULL); (LPTSTR)filename, sizeof(filename), NULL);
@@ -931,7 +930,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
// tmode = S_IREAD | S_IWRITE; // tmode = S_IREAD | S_IWRITE;
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
return true; return true;
} // endswitch } // endswitch
@@ -1001,7 +1000,7 @@ int BGXFAM::Cardinality(PGLOBAL g)
if (h == INVALID_HANDLE_VALUE) if (h == INVALID_HANDLE_VALUE)
if ((rc = GetLastError()) != ERROR_FILE_NOT_FOUND) { if ((rc = GetLastError()) != ERROR_FILE_NOT_FOUND) {
sprintf(g->Message, MSG(OPEN_ERROR), rc, 10, filename); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_ERROR), rc, 10, filename);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)filename, sizeof(filename), NULL); (LPTSTR)filename, sizeof(filename), NULL);
@@ -1017,7 +1016,7 @@ int BGXFAM::Cardinality(PGLOBAL g)
len.LowPart = GetFileSize(Hfile, (LPDWORD)&len.HighPart); len.LowPart = GetFileSize(Hfile, (LPDWORD)&len.HighPart);
if (len.LowPart == 0xFFFFFFFF && (rc = GetLastError()) != NO_ERROR) { if (len.LowPart == 0xFFFFFFFF && (rc = GetLastError()) != NO_ERROR) {
sprintf(g->Message, MSG(FILELEN_ERROR), "GetFileSize", filename); snprintf(g->Message, sizeof(g->Message), MSG(FILELEN_ERROR), "GetFileSize", filename);
return -2; return -2;
} else } else
fsize = len.QuadPart; fsize = len.QuadPart;
@@ -1034,7 +1033,7 @@ int BGXFAM::Cardinality(PGLOBAL g)
htrc(" errno=%d ENOENT=%d\n", errno, ENOENT); htrc(" errno=%d ENOENT=%d\n", errno, ENOENT);
if (errno != ENOENT) { if (errno != ENOENT) {
sprintf(g->Message, MSG(OPEN_ERROR_IS), snprintf(g->Message, sizeof(g->Message), MSG(OPEN_ERROR_IS),
filename, strerror(errno)); filename, strerror(errno));
return -1; return -1;
} else } else
@@ -1053,7 +1052,7 @@ int BGXFAM::Cardinality(PGLOBAL g)
} // endif Hfile } // endif Hfile
if (fsize < 0) { if (fsize < 0) {
sprintf(g->Message, MSG(FILELEN_ERROR), "lseek64", filename); snprintf(g->Message, sizeof(g->Message), MSG(FILELEN_ERROR), "lseek64", filename);
return -2; return -2;
} // endif fsize } // endif fsize
@@ -1062,14 +1061,14 @@ int BGXFAM::Cardinality(PGLOBAL g)
// Check the real size of the file // Check the real size of the file
if (Padded && Blksize) { if (Padded && Blksize) {
if (fsize % (BIGINT)Blksize) { if (fsize % (BIGINT)Blksize) {
sprintf(g->Message, MSG(NOT_FIXED_LEN), snprintf(g->Message, sizeof(g->Message), MSG(NOT_FIXED_LEN),
filename, (int)fsize, Lrecl); filename, (int)fsize, Lrecl);
return -3; return -3;
} else } else
card = (int)(fsize / (BIGINT)Blksize) * Nrec; card = (int)(fsize / (BIGINT)Blksize) * Nrec;
} else if (fsize % (BIGINT)Lrecl) { } else if (fsize % (BIGINT)Lrecl) {
sprintf(g->Message, MSG(NOT_FIXED_LEN), filename, (int)fsize, Lrecl); snprintf(g->Message, sizeof(g->Message), MSG(NOT_FIXED_LEN), filename, (int)fsize, Lrecl);
return -3; return -3;
} else } else
card = (int)(fsize / (BIGINT)Lrecl); // Fixed length file card = (int)(fsize / (BIGINT)Lrecl); // Fixed length file
@@ -1355,12 +1354,12 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
if (!SetEndOfFile(Hfile)) { if (!SetEndOfFile(Hfile)) {
DWORD drc = GetLastError(); DWORD drc = GetLastError();
sprintf(g->Message, MSG(SETEOF_ERROR), drc); snprintf(g->Message, sizeof(g->Message), MSG(SETEOF_ERROR), drc);
return RC_FX; return RC_FX;
} // endif error } // endif error
#else // !_WIN32 #else // !_WIN32
if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) { if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(TRUNCATE_ERROR), strerror(errno));
return RC_FX; return RC_FX;
} // endif } // endif
#endif // !_WIN32 #endif // !_WIN32
@@ -1394,7 +1393,7 @@ bool BGXFAM::OpenTempFile(PGLOBAL g)
if (Tfile == INVALID_HANDLE_VALUE) { if (Tfile == INVALID_HANDLE_VALUE) {
DWORD rc = GetLastError(); DWORD rc = GetLastError();
sprintf(g->Message, MSG(OPEN_ERROR), rc, MODE_INSERT, tempname); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_ERROR), rc, MODE_INSERT, tempname);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)tempname, _MAX_PATH, NULL); (LPTSTR)tempname, _MAX_PATH, NULL);
@@ -1406,7 +1405,7 @@ bool BGXFAM::OpenTempFile(PGLOBAL g)
if (Tfile == INVALID_HANDLE_VALUE) { if (Tfile == INVALID_HANDLE_VALUE) {
int rc = errno; int rc = errno;
sprintf(g->Message, MSG(OPEN_ERROR), rc, MODE_INSERT, tempname); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_ERROR), rc, MODE_INSERT, tempname);
strcat(g->Message, strerror(errno)); strcat(g->Message, strerror(errno));
return true; return true;
} //endif Tfile } //endif Tfile
@@ -1444,7 +1443,7 @@ bool BGXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
req = MY_MIN(n, Dbflen) * Lrecl; req = MY_MIN(n, Dbflen) * Lrecl;
if ((nbr = BigRead(g, Hfile, DelBuf, req)) != req) { if ((nbr = BigRead(g, Hfile, DelBuf, req)) != req) {
sprintf(g->Message, MSG(DEL_READ_ERROR), req, nbr); snprintf(g->Message, sizeof(g->Message), MSG(DEL_READ_ERROR), req, nbr);
return true; return true;
} // endif nbr } // endif nbr

View File

@@ -90,9 +90,9 @@ int GZFAM::Zerror(PGLOBAL g)
if (errnum == Z_ERRNO) if (errnum == Z_ERRNO)
#if defined(_WIN32) #if defined(_WIN32)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(NULL)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, strerror(NULL));
#else // !_WIN32 #else // !_WIN32
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, strerror(errno));
#endif // !_WIN32 #endif // !_WIN32
return (errnum == Z_STREAM_END) ? RC_EF : RC_FX; return (errnum == Z_STREAM_END) ? RC_EF : RC_FX;
@@ -152,7 +152,7 @@ bool GZFAM::OpenTableFile(PGLOBAL g)
// Last = Nrec; // For ZBKFAM // Last = Nrec; // For ZBKFAM
Tdbp->ResetSize(); Tdbp->ResetSize();
} else { } else {
sprintf(g->Message, MSG(NO_PART_DEL), "GZ"); snprintf(g->Message, sizeof(g->Message), MSG(NO_PART_DEL), "GZ");
return true; return true;
} // endif filter } // endif filter
@@ -161,7 +161,7 @@ bool GZFAM::OpenTableFile(PGLOBAL g)
strcpy(opmode, "a+"); strcpy(opmode, "a+");
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
return true; return true;
} // endswitch Mode } // endswitch Mode
@@ -174,7 +174,7 @@ bool GZFAM::OpenTableFile(PGLOBAL g)
Zfile = gzopen(PlugSetPath(filename, To_File, Tdbp->GetPath()), opmode); Zfile = gzopen(PlugSetPath(filename, To_File, Tdbp->GetPath()), opmode);
if (Zfile == NULL) { if (Zfile == NULL) {
sprintf(g->Message, MSG(GZOPEN_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(GZOPEN_ERROR),
opmode, (int)errno, filename); opmode, (int)errno, filename);
strcat(strcat(g->Message, ": "), strerror(errno)); strcat(strcat(g->Message, ": "), strerror(errno));
return (mode == MODE_READ && errno == ENOENT) return (mode == MODE_READ && errno == ENOENT)
@@ -249,13 +249,13 @@ int GZFAM::GetNextPos(void)
/***********************************************************************/ /***********************************************************************/
bool GZFAM::SetPos(PGLOBAL g, int pos __attribute__((unused))) bool GZFAM::SetPos(PGLOBAL g, int pos __attribute__((unused)))
{ {
sprintf(g->Message, MSG(NO_SETPOS_YET), "GZ"); snprintf(g->Message, sizeof(g->Message), MSG(NO_SETPOS_YET), "GZ");
return true; return true;
#if 0 #if 0
Fpos = pos; Fpos = pos;
if (fseek(Stream, Fpos, SEEK_SET)) { if (fseek(Stream, Fpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), Fpos); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), Fpos);
return true; return true;
} // endif } // endif
@@ -655,7 +655,7 @@ int ZBKFAM::DeleteRecords(PGLOBAL g, int irc)
if (!defp->SetIntCatInfo("Blocks", 0) || if (!defp->SetIntCatInfo("Blocks", 0) ||
!defp->SetIntCatInfo("Last", 0)) { !defp->SetIntCatInfo("Last", 0)) {
sprintf(g->Message, MSG(UPDATE_ERROR), "Header"); snprintf(g->Message, sizeof(g->Message), MSG(UPDATE_ERROR), "Header");
return RC_FX; return RC_FX;
} else } else
return RC_OK; return RC_OK;
@@ -932,7 +932,7 @@ bool ZLBFAM::AllocateBuffer(PGLOBAL g)
#if defined(NOLIB) #if defined(NOLIB)
if (!zlib && LoadZlib()) { if (!zlib && LoadZlib()) {
sprintf(g->Message, MSG(DLL_LOAD_ERROR), GetLastError(), "zlib.dll"); snprintf(g->Message, sizeof(g->Message), MSG(DLL_LOAD_ERROR), GetLastError(), "zlib.dll");
return TRUE; return TRUE;
} // endif zlib } // endif zlib
#endif #endif
@@ -964,9 +964,9 @@ bool ZLBFAM::AllocateBuffer(PGLOBAL g)
if (zrc != Z_OK) { if (zrc != Z_OK) {
if (Zstream->msg) if (Zstream->msg)
sprintf(g->Message, "%s error: %s", msg, Zstream->msg); snprintf(g->Message, sizeof(g->Message), "%s error: %s", msg, Zstream->msg);
else else
sprintf(g->Message, "%s error: %d", msg, zrc); snprintf(g->Message, sizeof(g->Message), "%s error: %d", msg, zrc);
return TRUE; return TRUE;
} // endif zrc } // endif zrc
@@ -1017,9 +1017,9 @@ bool ZLBFAM::AllocateBuffer(PGLOBAL g)
return FALSE; return FALSE;
case RC_FX: case RC_FX:
#if defined(UNIX) #if defined(UNIX)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, strerror(errno));
#else #else
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, _strerror(NULL));
#endif #endif
case RC_NF: case RC_NF:
return TRUE; return TRUE;
@@ -1027,7 +1027,7 @@ bool ZLBFAM::AllocateBuffer(PGLOBAL g)
// Some old tables can have PlugDB in their header // Some old tables can have PlugDB in their header
if (strcmp(To_Buf, "PlugDB")) { if (strcmp(To_Buf, "PlugDB")) {
sprintf(g->Message, MSG(BAD_HEADER), Tdbp->GetFile(g)); snprintf(g->Message, sizeof(g->Message), MSG(BAD_HEADER), Tdbp->GetFile(g));
return TRUE; return TRUE;
} // endif strcmp } // endif strcmp
@@ -1062,7 +1062,7 @@ int ZLBFAM::GetNextPos(void)
/***********************************************************************/ /***********************************************************************/
bool ZLBFAM::SetPos(PGLOBAL g, int pos __attribute__((unused))) bool ZLBFAM::SetPos(PGLOBAL g, int pos __attribute__((unused)))
{ {
sprintf(g->Message, MSG(NO_SETPOS_YET), "GZ"); snprintf(g->Message, sizeof(g->Message), MSG(NO_SETPOS_YET), "GZ");
return true; return true;
#if 0 // All this must be checked #if 0 // All this must be checked
if (pos < 0) { if (pos < 0) {
@@ -1145,7 +1145,7 @@ int ZLBFAM::ReadBuffer(PGLOBAL g)
// fseek is required only in non sequential reading // fseek is required only in non sequential reading
if (CurBlk != OldBlk + 1) if (CurBlk != OldBlk + 1)
if (fseek(Stream, Fpos, SEEK_SET)) { if (fseek(Stream, Fpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), Fpos); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), Fpos);
return RC_FX; return RC_FX;
} // endif fseek } // endif fseek
@@ -1207,9 +1207,9 @@ int ZLBFAM::ReadBuffer(PGLOBAL g)
err: err:
#if defined(UNIX) #if defined(UNIX)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, strerror(errno));
#else #else
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, _strerror(NULL));
#endif #endif
return RC_FX; return RC_FX;
} // end of ReadBuffer } // end of ReadBuffer
@@ -1225,7 +1225,7 @@ int ZLBFAM::ReadCompressedBuffer(PGLOBAL g, void *rdbuf)
num_read++; num_read++;
if (Optimized && BlkLen != signed(*Zlenp + sizeof(int))) { if (Optimized && BlkLen != signed(*Zlenp + sizeof(int))) {
sprintf(g->Message, MSG(BAD_BLK_SIZE), CurBlk + 1); snprintf(g->Message, sizeof(g->Message), MSG(BAD_BLK_SIZE), CurBlk + 1);
return RC_NF; return RC_NF;
} // endif BlkLen } // endif BlkLen
@@ -1238,9 +1238,9 @@ int ZLBFAM::ReadCompressedBuffer(PGLOBAL g, void *rdbuf)
if (zrc != Z_OK) { if (zrc != Z_OK) {
if (Zstream->msg) if (Zstream->msg)
sprintf(g->Message, MSG(FUNC_ERR_S), "inflate", Zstream->msg); snprintf(g->Message, sizeof(g->Message), MSG(FUNC_ERR_S), "inflate", Zstream->msg);
else else
sprintf(g->Message, MSG(FUNCTION_ERROR), "inflate", (int)zrc); snprintf(g->Message, sizeof(g->Message), MSG(FUNCTION_ERROR), "inflate", (int)zrc);
return RC_NF; return RC_NF;
} // endif zrc } // endif zrc
@@ -1328,9 +1328,9 @@ bool ZLBFAM::WriteCompressedBuffer(PGLOBAL g)
if (zrc != Z_OK) { if (zrc != Z_OK) {
if (Zstream->msg) if (Zstream->msg)
sprintf(g->Message, MSG(FUNC_ERR_S), "deflate", Zstream->msg); snprintf(g->Message, sizeof(g->Message), MSG(FUNC_ERR_S), "deflate", Zstream->msg);
else else
sprintf(g->Message, MSG(FUNCTION_ERROR), "deflate", (int)zrc); snprintf(g->Message, sizeof(g->Message), MSG(FUNCTION_ERROR), "deflate", (int)zrc);
return TRUE; return TRUE;
} else } else
@@ -1340,7 +1340,7 @@ bool ZLBFAM::WriteCompressedBuffer(PGLOBAL g)
BlkLen = *Zlenp + sizeof(int); BlkLen = *Zlenp + sizeof(int);
if (fwrite(Zlenp, 1, BlkLen, Stream) != (size_t)BlkLen) { if (fwrite(Zlenp, 1, BlkLen, Stream) != (size_t)BlkLen) {
sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FWRITE_ERROR), strerror(errno));
return TRUE; return TRUE;
} // endif size } // endif size

View File

@@ -211,7 +211,7 @@ int TXTFAM::GetFileLength(PGLOBAL g)
} else { } else {
if ((len = _filelength(h)) < 0) if ((len = _filelength(h)) < 0)
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", filename); snprintf(g->Message, sizeof(g->Message), MSG(FILELEN_ERROR), "_filelength", filename);
if (Eof && len) if (Eof && len)
len--; // Do not count the EOF character len--; // Do not count the EOF character
@@ -240,13 +240,13 @@ int TXTFAM::Cardinality(PGLOBAL g)
if (!(len % Blksize)) if (!(len % Blksize))
card = (len / Blksize) * Nrec; card = (len / Blksize) * Nrec;
else else
sprintf(g->Message, MSG(NOT_FIXED_LEN), To_File, len, Lrecl); snprintf(g->Message, sizeof(g->Message), MSG(NOT_FIXED_LEN), To_File, len, Lrecl);
} else { } else {
if (!(len % Lrecl)) if (!(len % Lrecl))
card = len / (int)Lrecl; // Fixed length file card = len / (int)Lrecl; // Fixed length file
else else
sprintf(g->Message, MSG(NOT_FIXED_LEN), To_File, len, Lrecl); snprintf(g->Message, sizeof(g->Message), MSG(NOT_FIXED_LEN), To_File, len, Lrecl);
} // endif Padded } // endif Padded
@@ -511,7 +511,7 @@ int DOSFAM::GetFileLength(PGLOBAL g)
len = TXTFAM::GetFileLength(g); len = TXTFAM::GetFileLength(g);
else else
if ((len = _filelength(_fileno(Stream))) < 0) if ((len = _filelength(_fileno(Stream))) < 0)
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", To_File); snprintf(g->Message, sizeof(g->Message), MSG(FILELEN_ERROR), "_filelength", To_File);
if (trace(1)) if (trace(1))
htrc("File length=%d\n", len); htrc("File length=%d\n", len);
@@ -588,7 +588,7 @@ bool DOSFAM::OpenTableFile(PGLOBAL g)
strcpy(opmode, "a+"); strcpy(opmode, "a+");
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
return true; return true;
} // endswitch Mode } // endswitch Mode
@@ -682,7 +682,7 @@ bool DOSFAM::SetPos(PGLOBAL g, int pos)
Fpos = pos; Fpos = pos;
if (fseek(Stream, Fpos, SEEK_SET)) { if (fseek(Stream, Fpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), Fpos); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), Fpos);
return true; return true;
} // endif } // endif
@@ -696,7 +696,7 @@ bool DOSFAM::SetPos(PGLOBAL g, int pos)
bool DOSFAM::RecordPos(PGLOBAL g) bool DOSFAM::RecordPos(PGLOBAL g)
{ {
if ((Fpos = ftell(Stream)) < 0) { if ((Fpos = ftell(Stream)) < 0) {
sprintf(g->Message, MSG(FTELL_ERROR), 0, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FTELL_ERROR), 0, strerror(errno));
// strcat(g->Message, " (possible wrong ENDING option value)"); // strcat(g->Message, " (possible wrong ENDING option value)");
return true; return true;
} // endif Fpos } // endif Fpos
@@ -712,7 +712,7 @@ int DOSFAM::InitDelete(PGLOBAL g, int fpos, int spos)
Fpos = fpos; Fpos = fpos;
if (fseek(Stream, spos, SEEK_SET)) { if (fseek(Stream, spos, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), Fpos); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), Fpos);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -732,9 +732,9 @@ int DOSFAM::SkipRecord(PGLOBAL g, bool header)
return RC_EF; return RC_EF;
#if defined(_WIN32) #if defined(_WIN32)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, _strerror(NULL));
#else #else
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, strerror(0));
#endif #endif
return RC_FX; return RC_FX;
} // endif fgets } // endif fgets
@@ -849,9 +849,9 @@ int DOSFAM::ReadBuffer(PGLOBAL g)
rc = RC_EF; rc = RC_EF;
} else { } else {
#if defined(_WIN32) #if defined(_WIN32)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, _strerror(NULL));
#else #else
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, strerror(0));
#endif #endif
if (trace(1)) if (trace(1))
@@ -913,7 +913,7 @@ int DOSFAM::WriteBuffer(PGLOBAL g)
// Update is directly written back into the file, // Update is directly written back into the file,
// with this (fast) method, record size cannot change. // with this (fast) method, record size cannot change.
if (fseek(Stream, Fpos, SEEK_SET)) { if (fseek(Stream, Fpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), 0); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), 0);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -928,13 +928,13 @@ int DOSFAM::WriteBuffer(PGLOBAL g)
/* Now start the writing process. */ /* Now start the writing process. */
/*********************************************************************/ /*********************************************************************/
if ((fputs(To_Buf, T_Stream)) == EOF) { if ((fputs(To_Buf, T_Stream)) == EOF) {
sprintf(g->Message, MSG(FPUTS_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FPUTS_ERROR), strerror(errno));
return RC_FX; return RC_FX;
} // endif EOF } // endif EOF
if (Tdbp->Mode == MODE_UPDATE && moved) if (Tdbp->Mode == MODE_UPDATE && moved)
if (fseek(Stream, curpos, SEEK_SET)) { if (fseek(Stream, curpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FSEEK_ERROR), strerror(errno));
return RC_FX; return RC_FX;
} // endif } // endif
@@ -1010,7 +1010,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
/*******************************************************************/ /*******************************************************************/
if (!UseTemp || moved) if (!UseTemp || moved)
if (fseek(Stream, curpos, SEEK_SET)) { if (fseek(Stream, curpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), 0); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), 0);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -1045,13 +1045,13 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/ /*****************************************************************/
#if defined(_WIN32) #if defined(_WIN32)
if (chsize(h, Tpos)) { if (chsize(h, Tpos)) {
sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(CHSIZE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
#else #else
if (ftruncate(h, (off_t)Tpos)) { if (ftruncate(h, (off_t)Tpos)) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(TRUNCATE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -1106,7 +1106,7 @@ bool DOSFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
for (*b = false, n = Fpos - Spos; n > 0; n -= req) { for (*b = false, n = Fpos - Spos; n > 0; n -= req) {
if (!UseTemp || !*b) if (!UseTemp || !*b)
if (fseek(Stream, Spos, SEEK_SET)) { if (fseek(Stream, Spos, SEEK_SET)) {
sprintf(g->Message, MSG(READ_SEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_SEEK_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -1117,18 +1117,18 @@ bool DOSFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
htrc("after read req=%d len=%d\n", req, len); htrc("after read req=%d len=%d\n", req, len);
if (len != req) { if (len != req) {
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len); snprintf(g->Message, sizeof(g->Message), MSG(DEL_READ_ERROR), (int) req, (int) len);
return true; return true;
} // endif len } // endif len
if (!UseTemp) if (!UseTemp)
if (fseek(T_Stream, Tpos, SEEK_SET)) { if (fseek(T_Stream, Tpos, SEEK_SET)) {
sprintf(g->Message, MSG(WRITE_SEEK_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_SEEK_ERR), strerror(errno));
return true; return true;
} // endif } // endif
if ((len = fwrite(DelBuf, 1, req, T_Stream)) != req) { if ((len = fwrite(DelBuf, 1, req, T_Stream)) != req) {
sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(DEL_WRITE_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -1174,16 +1174,16 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
remove(filetemp); // May still be there from previous error remove(filetemp); // May still be there from previous error
if (rename(filename, filetemp)) { // Save file for security if (rename(filename, filetemp)) { // Save file for security
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(RENAME_ERROR),
filename, filetemp, strerror(errno)); filename, filetemp, strerror(errno));
throw 51; throw 51;
} else if (rename(tempname, filename)) { } else if (rename(tempname, filename)) {
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(RENAME_ERROR),
tempname, filename, strerror(errno)); tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file rc = rename(filetemp, filename); // Restore saved file
throw 52; throw 52;
} else if (remove(filetemp)) { } else if (remove(filetemp)) {
sprintf(g->Message, MSG(REMOVE_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(REMOVE_ERROR),
filetemp, strerror(errno)); filetemp, strerror(errno));
rc = RC_INFO; // Acceptable rc = RC_INFO; // Acceptable
} // endif's } // endif's
@@ -1447,7 +1447,7 @@ int BLKFAM::ReadBuffer(PGLOBAL g)
// fseek is required only in non sequential reading // fseek is required only in non sequential reading
if (CurBlk != OldBlk + 1) if (CurBlk != OldBlk + 1)
if (fseek(Stream, BlkPos[CurBlk], SEEK_SET)) { if (fseek(Stream, BlkPos[CurBlk], SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), BlkPos[CurBlk]); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), BlkPos[CurBlk]);
return RC_FX; return RC_FX;
} // endif fseek } // endif fseek
@@ -1483,9 +1483,9 @@ int BLKFAM::ReadBuffer(PGLOBAL g)
rc = RC_EF; rc = RC_EF;
} else { } else {
#if defined(_WIN32) #if defined(_WIN32)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, _strerror(NULL));
#else #else
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, strerror(errno));
#endif #endif
if (trace(1)) if (trace(1))
@@ -1529,7 +1529,7 @@ int BLKFAM::WriteBuffer(PGLOBAL g)
BlkLen = (int)(NxtLine - To_Buf); BlkLen = (int)(NxtLine - To_Buf);
if (fwrite(To_Buf, 1, BlkLen, Stream) != (size_t)BlkLen) { if (fwrite(To_Buf, 1, BlkLen, Stream) != (size_t)BlkLen) {
sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FWRITE_ERROR), strerror(errno));
Closing = true; // To tell CloseDB about a Write error Closing = true; // To tell CloseDB about a Write error
return RC_FX; return RC_FX;
} // endif size } // endif size
@@ -1576,7 +1576,7 @@ int BLKFAM::WriteBuffer(PGLOBAL g)
len = strlen(OutBuf); len = strlen(OutBuf);
} else { } else {
if (fseek(Stream, Fpos, SEEK_SET)) { // Fpos is last position if (fseek(Stream, Fpos, SEEK_SET)) { // Fpos is last position
sprintf(g->Message, MSG(FSETPOS_ERROR), 0); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), 0);
return RC_FX; return RC_FX;
} // endif fseek } // endif fseek
@@ -1587,13 +1587,13 @@ int BLKFAM::WriteBuffer(PGLOBAL g)
} // endif UseTemp } // endif UseTemp
if (fwrite(OutBuf, 1, len, T_Stream) != (size_t)len) { if (fwrite(OutBuf, 1, len, T_Stream) != (size_t)len) {
sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FWRITE_ERROR), strerror(errno));
return RC_FX; return RC_FX;
} // endif fwrite } // endif fwrite
if (moved) if (moved)
if (fseek(Stream, curpos, SEEK_SET)) { if (fseek(Stream, curpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FSEEK_ERROR), strerror(errno));
return RC_FX; return RC_FX;
} // endif } // endif
@@ -1677,7 +1677,7 @@ int BINFAM::GetFileLength(PGLOBAL g)
len = TXTFAM::GetFileLength(g); len = TXTFAM::GetFileLength(g);
else else
if ((len = _filelength(_fileno(Stream))) < 0) if ((len = _filelength(_fileno(Stream))) < 0)
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", To_File); snprintf(g->Message, sizeof(g->Message), MSG(FILELEN_ERROR), "_filelength", To_File);
xtrc(1, "File length=%d\n", len); xtrc(1, "File length=%d\n", len);
return len; return len;
@@ -1709,7 +1709,7 @@ bool BINFAM::OpenTableFile(PGLOBAL g) {
strcpy(opmode, "wb"); strcpy(opmode, "wb");
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
return true; return true;
} // endswitch Mode } // endswitch Mode
@@ -1801,7 +1801,7 @@ bool BINFAM::SetPos(PGLOBAL g, int pos) {
Fpos = pos; Fpos = pos;
if (fseek(Stream, Fpos, SEEK_SET)) { if (fseek(Stream, Fpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), Fpos); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), Fpos);
return true; return true;
} // endif } // endif
@@ -1814,7 +1814,7 @@ bool BINFAM::SetPos(PGLOBAL g, int pos) {
/***********************************************************************/ /***********************************************************************/
bool BINFAM::RecordPos(PGLOBAL g) { bool BINFAM::RecordPos(PGLOBAL g) {
if ((Fpos = ftell(Stream)) < 0) { if ((Fpos = ftell(Stream)) < 0) {
sprintf(g->Message, MSG(FTELL_ERROR), 0, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FTELL_ERROR), 0, strerror(errno));
// strcat(g->Message, " (possible wrong ENDING option value)"); // strcat(g->Message, " (possible wrong ENDING option value)");
return true; return true;
} // endif Fpos } // endif Fpos
@@ -1860,7 +1860,7 @@ int BINFAM::ReadBuffer(PGLOBAL g)
return RC_EF; return RC_EF;
} else if (Recsize > (unsigned)Buflen) { } else if (Recsize > (unsigned)Buflen) {
sprintf(g->Message, "Record too big (Recsize=%zd Buflen=%d)\n", Recsize, Buflen); snprintf(g->Message, sizeof(g->Message), "Record too big (Recsize=%zd Buflen=%d)\n", Recsize, Buflen);
return RC_FX; return RC_FX;
} // endif Recsize } // endif Recsize
@@ -1872,9 +1872,9 @@ int BINFAM::ReadBuffer(PGLOBAL g)
rc = RC_EF; rc = RC_EF;
} else { } else {
#if defined(_WIN32) #if defined(_WIN32)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, _strerror(NULL));
#else #else
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, strerror(0));
#endif #endif
xtrc(2, "%s\n", g->Message); xtrc(2, "%s\n", g->Message);
rc = RC_FX; rc = RC_FX;
@@ -1931,7 +1931,7 @@ int BINFAM::WriteBuffer(PGLOBAL g)
// Update is directly written back into the file, // Update is directly written back into the file,
// with this (fast) method, record size cannot change. // with this (fast) method, record size cannot change.
if (fseek(Stream, Fpos, SEEK_SET)) { if (fseek(Stream, Fpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), 0); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), 0);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -1946,18 +1946,18 @@ int BINFAM::WriteBuffer(PGLOBAL g)
/* Now start the writing process. */ /* Now start the writing process. */
/*********************************************************************/ /*********************************************************************/
if (fwrite(&Recsize, sizeof(size_t), 1, T_Stream) != 1) { if (fwrite(&Recsize, sizeof(size_t), 1, T_Stream) != 1) {
sprintf(g->Message, "Error %d writing prefix to %s", snprintf(g->Message, sizeof(g->Message), "Error %d writing prefix to %s",
errno, To_File); errno, To_File);
return RC_FX; return RC_FX;
} else if (fwrite(To_Buf, Recsize, 1, T_Stream) != 1) { } else if (fwrite(To_Buf, Recsize, 1, T_Stream) != 1) {
sprintf(g->Message, "Error %d writing %zd bytes to %s", snprintf(g->Message, sizeof(g->Message), "Error %d writing %zd bytes to %s",
errno, Recsize, To_File); errno, Recsize, To_File);
return RC_FX; return RC_FX;
} // endif fwrite } // endif fwrite
if (Tdbp->GetMode() == MODE_UPDATE && moved) if (Tdbp->GetMode() == MODE_UPDATE && moved)
if (fseek(Stream, curpos, SEEK_SET)) { if (fseek(Stream, curpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FSEEK_ERROR), strerror(errno));
return RC_FX; return RC_FX;
} // endif } // endif
@@ -2032,7 +2032,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
/*******************************************************************/ /*******************************************************************/
if (!UseTemp || moved) if (!UseTemp || moved)
if (fseek(Stream, curpos, SEEK_SET)) { if (fseek(Stream, curpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), 0); snprintf(g->Message, sizeof(g->Message), MSG(FSETPOS_ERROR), 0);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -2067,13 +2067,13 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/ /*****************************************************************/
#if defined(_WIN32) #if defined(_WIN32)
if (chsize(h, Tpos)) { if (chsize(h, Tpos)) {
sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(CHSIZE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
#else #else
if (ftruncate(h, (off_t)Tpos)) { if (ftruncate(h, (off_t)Tpos)) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(TRUNCATE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif

View File

@@ -152,7 +152,7 @@ int VCTFAM::GetFileLength(PGLOBAL g)
To_File = filename; To_File = filename;
for (i = 0; i < Ncol; i++) { for (i = 0; i < Ncol; i++) {
sprintf(filename, Colfn, i+1); snprintf(filename, _MAX_PATH, Colfn, i+1);
len += TXTFAM::GetFileLength(g); len += TXTFAM::GetFileLength(g);
} // endfor i } // endfor i
@@ -184,7 +184,7 @@ int VCTFAM::GetBlockInfo(PGLOBAL g)
VECHEADER vh; VECHEADER vh;
if (Header < 1 || Header > 3 || !MaxBlk) { if (Header < 1 || Header > 3 || !MaxBlk) {
sprintf(g->Message, "Invalid header value %d", Header); snprintf(g->Message, sizeof(g->Message), "Invalid header value %d", Header);
return -1; return -1;
} else } else
n = (Header == 1) ? (int)sizeof(VECHEADER) : 0; n = (Header == 1) ? (int)sizeof(VECHEADER) : 0;
@@ -192,7 +192,10 @@ int VCTFAM::GetBlockInfo(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath()); PlugSetPath(filename, To_File, Tdbp->GetPath());
if (Header == 2) if (Header == 2)
strcat(PlugRemoveType(filename, filename), ".blk"); {
PlugRemoveType(filename, filename);
strncat(filename, ".blk", _MAX_PATH - strlen(filename));
}
if ((h = global_open(g, MSGID_CANNOT_OPEN, filename, O_RDONLY)) == -1 if ((h = global_open(g, MSGID_CANNOT_OPEN, filename, O_RDONLY)) == -1
|| !_filelength(h)) { || !_filelength(h)) {
@@ -208,10 +211,10 @@ int VCTFAM::GetBlockInfo(PGLOBAL g)
k = lseek(h, -(int)sizeof(VECHEADER), SEEK_END); k = lseek(h, -(int)sizeof(VECHEADER), SEEK_END);
if ((k = read(h, &vh, sizeof(vh))) != sizeof(vh)) { if ((k = read(h, &vh, sizeof(vh))) != sizeof(vh)) {
sprintf(g->Message, "Error reading header file %s", filename); snprintf(g->Message, sizeof(g->Message), "Error reading header file %s", filename);
n = -1; n = -1;
} else if (MaxBlk * Nrec != vh.MaxRec) { } else if (MaxBlk * Nrec != vh.MaxRec) {
sprintf(g->Message, "MaxRec=%d doesn't match MaxBlk=%d Nrec=%d", snprintf(g->Message, sizeof(g->Message), "MaxRec=%d doesn't match MaxBlk=%d Nrec=%d",
vh.MaxRec, MaxBlk, Nrec); vh.MaxRec, MaxBlk, Nrec);
n = -1; n = -1;
} else { } else {
@@ -247,12 +250,13 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g)
s= global_fopen(g, MSGID_CANNOT_OPEN, filename, "r+b"); s= global_fopen(g, MSGID_CANNOT_OPEN, filename, "r+b");
} else { // Header == 2 } else { // Header == 2
strcat(PlugRemoveType(filename, filename), ".blk"); PlugRemoveType(filename, filename);
strncat(filename, ".blk", _MAX_PATH - strlen(filename));
s= global_fopen(g, MSGID_CANNOT_OPEN, filename, "wb"); s= global_fopen(g, MSGID_CANNOT_OPEN, filename, "wb");
} // endif Header } // endif Header
if (!s) { if (!s) {
sprintf(g->Message, "Error opening header file %s", filename); snprintf(g->Message, sizeof(g->Message), "Error opening header file %s", filename);
return true; return true;
} else if (Header == 3) } else if (Header == 3)
/*k =*/ fseek(s, -(int)sizeof(VECHEADER), SEEK_END); /*k =*/ fseek(s, -(int)sizeof(VECHEADER), SEEK_END);
@@ -261,7 +265,7 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g)
vh.NumRec = (Block - 1) * Nrec + Last; vh.NumRec = (Block - 1) * Nrec + Last;
if ((n = fwrite(&vh, sizeof(vh), 1, s)) != 1) { if ((n = fwrite(&vh, sizeof(vh), 1, s)) != 1) {
sprintf(g->Message, "Error writing header file %s", filename); snprintf(g->Message, sizeof(g->Message), "Error writing header file %s", filename);
rc = true; rc = true;
} // endif fread } // endif fread
@@ -320,7 +324,7 @@ int VCTFAM::Cardinality(PGLOBAL g)
// Use the first column file to calculate the cardinality // Use the first column file to calculate the cardinality
clen = cdp->GetClen(); clen = cdp->GetClen();
sprintf(filename, Colfn, 1); snprintf(filename, _MAX_PATH, Colfn, 1);
To_File = filename; To_File = filename;
len = TXTFAM::GetFileLength(g); len = TXTFAM::GetFileLength(g);
To_File = savfn; To_File = savfn;
@@ -329,7 +333,7 @@ int VCTFAM::Cardinality(PGLOBAL g)
if (!(len % clen)) if (!(len % clen))
card = len / clen; // Fixed length file card = len / clen; // Fixed length file
else else
sprintf(g->Message, MSG(NOT_FIXED_LEN), To_File, len, clen); snprintf(g->Message, sizeof(g->Message), MSG(NOT_FIXED_LEN), To_File, len, clen);
if (trace(1)) if (trace(1))
htrc(" Computed max_K=%d Filen=%d Clen=%d\n", card, len, clen); htrc(" Computed max_K=%d Filen=%d Clen=%d\n", card, len, clen);
@@ -393,7 +397,7 @@ bool VCTFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
return false; return false;
err: err:
sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(MAKE_EMPTY_FILE), To_File, strerror(errno));
close(h); close(h);
return true; return true;
} // end of MakeEmptyFile } // end of MakeEmptyFile
@@ -454,7 +458,7 @@ bool VCTFAM::OpenTableFile(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
return true; return true;
} // endswitch Mode } // endswitch Mode
@@ -582,7 +586,7 @@ bool VCTFAM::InitInsert(PGLOBAL g)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
rc = true; rc = true;
} catch (const char *msg) { } catch (const char *msg) {
strcpy(g->Message, msg); strncpy(g->Message, msg, sizeof(g->Message));
rc = true; rc = true;
} // end catch } // end catch
@@ -687,7 +691,7 @@ int VCTFAM::WriteBuffer(PGLOBAL g)
} else { } else {
// Mode Insert // Mode Insert
if (MaxBlk && CurBlk == MaxBlk) { if (MaxBlk && CurBlk == MaxBlk) {
strcpy(g->Message, MSG(TRUNC_BY_ESTIM)); strncpy(g->Message, MSG(TRUNC_BY_ESTIM), sizeof(g->Message));
return RC_EF; // Too many lines for vector formatted table return RC_EF; // Too many lines for vector formatted table
} // endif MaxBlk } // endif MaxBlk
@@ -726,7 +730,7 @@ int VCTFAM::WriteBuffer(PGLOBAL g)
if ((size_t)Nrec != if ((size_t)Nrec !=
fwrite(NewBlock, (size_t)Lrecl, (size_t)Nrec, Stream)) { fwrite(NewBlock, (size_t)Lrecl, (size_t)Nrec, Stream)) {
sprintf(g->Message, MSG(WRITE_STRERROR), To_File, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_STRERROR), To_File, strerror(errno));
return RC_FX; return RC_FX;
} // endif } // endif
@@ -839,13 +843,13 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc)
/***************************************************************/ /***************************************************************/
#if defined(UNIX) #if defined(UNIX)
if (ftruncate(h, (off_t)(Headlen + Block * Blksize))) { if (ftruncate(h, (off_t)(Headlen + Block * Blksize))) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(TRUNCATE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
#else #else
if (chsize(h, Headlen + Block * Blksize)) { if (chsize(h, Headlen + Block * Blksize)) {
sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(CHSIZE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -885,7 +889,8 @@ bool VCTFAM::OpenTempFile(PGLOBAL g)
/* Open the temporary file, Spos is at the beginning of file. */ /* Open the temporary file, Spos is at the beginning of file. */
/*********************************************************************/ /*********************************************************************/
PlugSetPath(tempname, To_File, Tdbp->GetPath()); PlugSetPath(tempname, To_File, Tdbp->GetPath());
strcat(PlugRemoveType(tempname, tempname), ".t"); PlugRemoveType(tempname, tempname);
strncat(tempname, ".t", _MAX_PATH - strlen(tempname));
if (MaxBlk) { if (MaxBlk) {
if (MakeEmptyFile(g, tempname)) if (MakeEmptyFile(g, tempname))
@@ -938,7 +943,7 @@ bool VCTFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
} // endif MaxBlk } // endif MaxBlk
if (fseek(Stream, dep + off, SEEK_SET)) { if (fseek(Stream, dep + off, SEEK_SET)) {
sprintf(g->Message, MSG(READ_SEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_SEEK_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -948,7 +953,7 @@ bool VCTFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
htrc("after read req=%d len=%d\n", req, len); htrc("after read req=%d len=%d\n", req, len);
if (len != req) { if (len != req) {
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len); snprintf(g->Message, sizeof(g->Message), MSG(DEL_READ_ERROR), (int) req, (int) len);
return true; return true;
} // endif len } // endif len
@@ -962,12 +967,12 @@ bool VCTFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
} // endif MaxBlk } // endif MaxBlk
if (fseek(T_Stream, dep + off, SEEK_SET)) { if (fseek(T_Stream, dep + off, SEEK_SET)) {
sprintf(g->Message, MSG(WRITE_SEEK_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_SEEK_ERR), strerror(errno));
return true; return true;
} // endif } // endif
if ((len = fwrite(To_Buf, Clens[i], req, T_Stream)) != req) { if ((len = fwrite(To_Buf, Clens[i], req, T_Stream)) != req) {
sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(DEL_WRITE_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -995,7 +1000,7 @@ bool VCTFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
len = (size_t)Blksize; len = (size_t)Blksize;
if (fwrite(NewBlock, 1, len, T_Stream) != len) { if (fwrite(NewBlock, 1, len, T_Stream) != len) {
sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(DEL_WRITE_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -1037,12 +1042,12 @@ bool VCTFAM::CleanUnusedSpace(PGLOBAL g)
memset(To_Buf, (Isnum[i]) ? 0 : ' ', n * Clens[i]); memset(To_Buf, (Isnum[i]) ? 0 : ' ', n * Clens[i]);
if (fseek(Stream, dep + Deplac[i] + Last * Clens[i], SEEK_SET)) { if (fseek(Stream, dep + Deplac[i] + Last * Clens[i], SEEK_SET)) {
sprintf(g->Message, MSG(WRITE_SEEK_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_SEEK_ERR), strerror(errno));
return true; return true;
} // endif } // endif
if ((len = fwrite(To_Buf, Clens[i], req, Stream)) != req) { if ((len = fwrite(To_Buf, Clens[i], req, Stream)) != req) {
sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(DEL_WRITE_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -1059,12 +1064,12 @@ bool VCTFAM::CleanUnusedSpace(PGLOBAL g)
for (i = 0; i < Ncol; i++) { for (i = 0; i < Ncol; i++) {
if (fseek(T_Stream, Deplac[i] + Tpos * Clens[i], SEEK_SET)) { if (fseek(T_Stream, Deplac[i] + Tpos * Clens[i], SEEK_SET)) {
sprintf(g->Message, MSG(WRITE_SEEK_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_SEEK_ERR), strerror(errno));
return true; return true;
} // endif } // endif
if ((len = fwrite(To_Buf, Clens[i], req, T_Stream)) != req) { if ((len = fwrite(To_Buf, Clens[i], req, T_Stream)) != req) {
sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(DEL_WRITE_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -1170,7 +1175,7 @@ bool VCTFAM::ResetTableSize(PGLOBAL g, int block, int last)
if (!defp->SetIntCatInfo("Blocks", Block) || if (!defp->SetIntCatInfo("Blocks", Block) ||
!defp->SetIntCatInfo("Last", Last)) { !defp->SetIntCatInfo("Last", Last)) {
sprintf(g->Message, MSG(UPDATE_ERROR), "Header"); snprintf(g->Message, sizeof(g->Message), MSG(UPDATE_ERROR), "Header");
rc = true; rc = true;
} // endif } // endif
@@ -1219,7 +1224,7 @@ bool VCTFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
len, Nrec, colp->Deplac, Lrecl, CurBlk, MaxBlk); len, Nrec, colp->Deplac, Lrecl, CurBlk, MaxBlk);
if (fseek(Stream, len, SEEK_SET)) { if (fseek(Stream, len, SEEK_SET)) {
sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FSEEK_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -1228,9 +1233,9 @@ bool VCTFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
if (n != (size_t)Nrec) { if (n != (size_t)Nrec) {
if (errno == NO_ERROR) if (errno == NO_ERROR)
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, To_File); snprintf(g->Message, sizeof(g->Message), MSG(BAD_READ_NUMBER), (int) n, To_File);
else else
sprintf(g->Message, MSG(READ_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR),
To_File, strerror(errno)); To_File, strerror(errno));
if (trace(1)) if (trace(1))
@@ -1270,7 +1275,7 @@ bool VCTFAM::WriteBlock(PGLOBAL g, PVCTCOL colp)
Modif, len, Nrec, colp->Deplac, Lrecl, colp->ColBlk); Modif, len, Nrec, colp->Deplac, Lrecl, colp->ColBlk);
if (fseek(T_Stream, len, SEEK_SET)) { if (fseek(T_Stream, len, SEEK_SET)) {
sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FSEEK_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -1281,7 +1286,7 @@ bool VCTFAM::WriteBlock(PGLOBAL g, PVCTCOL colp)
if (n != fwrite(colp->Blk->GetValPointer(), if (n != fwrite(colp->Blk->GetValPointer(),
(size_t)colp->Clen, n, T_Stream)) { (size_t)colp->Clen, n, T_Stream)) {
sprintf(g->Message, MSG(WRITE_STRERROR), snprintf(g->Message, sizeof(g->Message), MSG(WRITE_STRERROR),
(UseTemp) ? To_Fbt->Fname : To_File, strerror(errno)); (UseTemp) ? To_Fbt->Fname : To_File, strerror(errno));
if (trace(1)) if (trace(1))
@@ -1386,7 +1391,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g)
// Inserting will be like updating the file // Inserting will be like updating the file
mapmode = MODE_UPDATE; mapmode = MODE_UPDATE;
} else { } else {
strcpy(g->Message, "MAP Insert is for VEC Estimate tables only"); strncpy(g->Message, "MAP Insert is for VEC Estimate tables only", sizeof(g->Message));
return true; return true;
} // endif MaxBlk } // endif MaxBlk
@@ -1410,7 +1415,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g)
DWORD rc = GetLastError(); DWORD rc = GetLastError();
if (!(*g->Message)) if (!(*g->Message))
sprintf(g->Message, MSG(OPEN_MODE_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR),
"map", (int) rc, filename); "map", (int) rc, filename);
if (trace(1)) if (trace(1))
@@ -1438,7 +1443,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g)
if (!Memory) { if (!Memory) {
CloseFileHandle(hFile); CloseFileHandle(hFile);
sprintf(g->Message, MSG(MAP_VIEW_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(MAP_VIEW_ERROR),
filename, GetLastError()); filename, GetLastError());
return true; return true;
} // endif Memory } // endif Memory
@@ -1557,7 +1562,7 @@ bool VCMFAM::InitInsert(PGLOBAL g)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
rc = true; rc = true;
} catch (const char *msg) { } catch (const char *msg) {
strcpy(g->Message, msg); strncpy(g->Message, msg, sizeof(g->Message));
rc = true; rc = true;
} // end catch } // end catch
@@ -1576,7 +1581,7 @@ int VCMFAM::WriteBuffer(PGLOBAL g)
// Mode Update being done in ReadDB we process here Insert mode only. // Mode Update being done in ReadDB we process here Insert mode only.
if (Tdbp->GetMode() == MODE_INSERT) { if (Tdbp->GetMode() == MODE_INSERT) {
if (CurBlk == MaxBlk) { if (CurBlk == MaxBlk) {
strcpy(g->Message, MSG(TRUNC_BY_ESTIM)); strncpy(g->Message, MSG(TRUNC_BY_ESTIM), sizeof(g->Message));
return RC_EF; // Too many lines for vector formatted table return RC_EF; // Too many lines for vector formatted table
} // endif MaxBlk } // endif MaxBlk
@@ -1676,7 +1681,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc)
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
if (drc == 0xFFFFFFFF) { if (drc == 0xFFFFFFFF) {
sprintf(g->Message, MSG(FUNCTION_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(FUNCTION_ERROR),
"SetFilePointer", GetLastError()); "SetFilePointer", GetLastError());
CloseHandle(fp->Handle); CloseHandle(fp->Handle);
return RC_FX; return RC_FX;
@@ -1686,7 +1691,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc)
htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc); htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
if (!SetEndOfFile(fp->Handle)) { if (!SetEndOfFile(fp->Handle)) {
sprintf(g->Message, MSG(FUNCTION_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(FUNCTION_ERROR),
"SetEndOfFile", GetLastError()); "SetEndOfFile", GetLastError());
CloseHandle(fp->Handle); CloseHandle(fp->Handle);
return RC_FX; return RC_FX;
@@ -1695,7 +1700,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc)
CloseHandle(fp->Handle); CloseHandle(fp->Handle);
#else // UNIX #else // UNIX
if (ftruncate(fp->Handle, (off_t)n)) { if (ftruncate(fp->Handle, (off_t)n)) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(TRUNCATE_ERROR), strerror(errno));
close(fp->Handle); close(fp->Handle);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -1930,7 +1935,7 @@ bool VECFAM::OpenTableFile(PGLOBAL g)
strcpy(opmode, "ab"); strcpy(opmode, "ab");
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
return true; return true;
} // endswitch Mode } // endswitch Mode
@@ -2007,7 +2012,7 @@ bool VECFAM::OpenColumnFile(PGLOBAL g, PCSZ opmode, int i)
char filename[_MAX_PATH]; char filename[_MAX_PATH];
PDBUSER dup = PlgGetUser(g); PDBUSER dup = PlgGetUser(g);
sprintf(filename, Colfn, i+1); snprintf(filename, _MAX_PATH, Colfn, i+1);
if (!(Streams[i] = PlugOpenFile(g, filename, opmode))) { if (!(Streams[i] = PlugOpenFile(g, filename, opmode))) {
if (trace(1)) if (trace(1))
@@ -2079,7 +2084,8 @@ bool VECFAM::AllocateBuffer(PGLOBAL g)
Tempat = (char*)PlugSubAlloc(g, NULL, _MAX_PATH); Tempat = (char*)PlugSubAlloc(g, NULL, _MAX_PATH);
strcpy(Tempat, Colfn); strcpy(Tempat, Colfn);
PlugSetPath(Tempat, Tempat, Tdbp->GetPath()); PlugSetPath(Tempat, Tempat, Tdbp->GetPath());
strcat(PlugRemoveType(Tempat, Tempat), ".t"); PlugRemoveType(Tempat, Tempat);
strncat(Tempat, ".t", _MAX_PATH - strlen(Tempat));
T_Fbs = (PFBLOCK *)PlugSubAlloc(g, NULL, Ncol * sizeof(PFBLOCK)); T_Fbs = (PFBLOCK *)PlugSubAlloc(g, NULL, Ncol * sizeof(PFBLOCK));
} // endif UseTemp } // endif UseTemp
@@ -2178,7 +2184,7 @@ int VECFAM::WriteBuffer(PGLOBAL g)
for (i = 0; i < Ncol; i++) for (i = 0; i < Ncol; i++)
if (n != fwrite(To_Bufs[i], (size_t)Clens[i], n, Streams[i])) { if (n != fwrite(To_Bufs[i], (size_t)Clens[i], n, Streams[i])) {
sprintf(g->Message, MSG(WRITE_STRERROR), To_File, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_STRERROR), To_File, strerror(errno));
return RC_FX; return RC_FX;
} // endif } // endif
@@ -2272,7 +2278,7 @@ int VECFAM::DeleteRecords(PGLOBAL g, int irc)
int h; // File handle, return code int h; // File handle, return code
for (int i = 0; i < Ncol; i++) { for (int i = 0; i < Ncol; i++) {
sprintf(filename, Colfn, i + 1); snprintf(filename, _MAX_PATH, Colfn, i + 1);
/*rc =*/ PlugCloseFile(g, To_Fbs[i]); /*rc =*/ PlugCloseFile(g, To_Fbs[i]);
if ((h= global_open(g, MSGID_OPEN_STRERROR, filename, O_WRONLY)) <= 0) if ((h= global_open(g, MSGID_OPEN_STRERROR, filename, O_WRONLY)) <= 0)
@@ -2283,13 +2289,13 @@ int VECFAM::DeleteRecords(PGLOBAL g, int irc)
/***************************************************************/ /***************************************************************/
#if defined(UNIX) #if defined(UNIX)
if (ftruncate(h, (off_t)(Tpos * Clens[i]))) { if (ftruncate(h, (off_t)(Tpos * Clens[i]))) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(TRUNCATE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
#else #else
if (chsize(h, Tpos * Clens[i])) { if (chsize(h, Tpos * Clens[i])) {
sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(CHSIZE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -2332,7 +2338,7 @@ bool VECFAM::OpenTempFile(PGLOBAL g)
/*****************************************************************/ /*****************************************************************/
/* Open the temporary file, Spos is at the beginning of file. */ /* Open the temporary file, Spos is at the beginning of file. */
/*****************************************************************/ /*****************************************************************/
sprintf(tempname, Tempat, i+1); snprintf(tempname, _MAX_PATH, Tempat, i+1);
if (!(T_Streams[i] = PlugOpenFile(g, tempname, "wb"))) { if (!(T_Streams[i] = PlugOpenFile(g, tempname, "wb"))) {
if (trace(1)) if (trace(1))
@@ -2388,7 +2394,7 @@ bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *)
if (!UseTemp || !b) if (!UseTemp || !b)
if (fseek(Streams[i], Spos * Clens[i], SEEK_SET)) { if (fseek(Streams[i], Spos * Clens[i], SEEK_SET)) {
sprintf(g->Message, MSG(READ_SEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_SEEK_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -2398,18 +2404,18 @@ bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *)
htrc("after read req=%d len=%d\n", req, len); htrc("after read req=%d len=%d\n", req, len);
if (len != req) { if (len != req) {
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len); snprintf(g->Message, sizeof(g->Message), MSG(DEL_READ_ERROR), (int) req, (int) len);
return true; return true;
} // endif len } // endif len
if (!UseTemp) if (!UseTemp)
if (fseek(T_Streams[i], Tpos * Clens[i], SEEK_SET)) { if (fseek(T_Streams[i], Tpos * Clens[i], SEEK_SET)) {
sprintf(g->Message, MSG(WRITE_SEEK_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_SEEK_ERR), strerror(errno));
return true; return true;
} // endif } // endif
if ((len = fwrite(To_Buf, Clens[i], req, T_Streams[i])) != req) { if ((len = fwrite(To_Buf, Clens[i], req, T_Streams[i])) != req) {
sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(DEL_WRITE_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -2451,22 +2457,23 @@ int VECFAM::RenameTempFile(PGLOBAL g)
tempname = (char*)T_Fbs[i]->Fname; tempname = (char*)T_Fbs[i]->Fname;
if (!Abort) { if (!Abort) {
sprintf(filename, Colfn, i+1); snprintf(filename, _MAX_PATH, Colfn, i+1);
PlugSetPath(filename, filename, Tdbp->GetPath()); PlugSetPath(filename, filename, Tdbp->GetPath());
strcat(PlugRemoveType(filetemp, filename), ".ttt"); PlugRemoveType(filetemp, filename);
strncat(filetemp, ".ttt", _MAX_PATH - strlen(filetemp));
remove(filetemp); // May still be there from previous error remove(filetemp); // May still be there from previous error
if (rename(filename, filetemp)) { // Save file for security if (rename(filename, filetemp)) { // Save file for security
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(RENAME_ERROR),
filename, filetemp, strerror(errno)); filename, filetemp, strerror(errno));
rc = RC_FX; rc = RC_FX;
} else if (rename(tempname, filename)) { } else if (rename(tempname, filename)) {
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(RENAME_ERROR),
tempname, filename, strerror(errno)); tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file rc = rename(filetemp, filename); // Restore saved file
rc = RC_FX; rc = RC_FX;
} else if (remove(filetemp)) { } else if (remove(filetemp)) {
sprintf(g->Message, MSG(REMOVE_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(REMOVE_ERROR),
filetemp, strerror(errno)); filetemp, strerror(errno));
rc = RC_INFO; // Acceptable rc = RC_INFO; // Acceptable
} // endif's } // endif's
@@ -2568,7 +2575,7 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
len, i, Nrec, colp->Deplac, Lrecl, CurBlk); len, i, Nrec, colp->Deplac, Lrecl, CurBlk);
if (fseek(Streams[i], len, SEEK_SET)) { if (fseek(Streams[i], len, SEEK_SET)) {
sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FSEEK_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -2578,15 +2585,15 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
if (n != (size_t)Nrec && (CurBlk+1 != Block || n != (size_t)Last)) { if (n != (size_t)Nrec && (CurBlk+1 != Block || n != (size_t)Last)) {
char fn[_MAX_PATH]; char fn[_MAX_PATH];
sprintf(fn, Colfn, colp->Index); snprintf(fn, _MAX_PATH, Colfn, colp->Index);
#if defined(_WIN32) #if defined(_WIN32)
if (feof(Streams[i])) if (feof(Streams[i]))
#else // !_WIN32 #else // !_WIN32
if (errno == NO_ERROR) if (errno == NO_ERROR)
#endif // !_WIN32 #endif // !_WIN32
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn); snprintf(g->Message, sizeof(g->Message), MSG(BAD_READ_NUMBER), (int) n, fn);
else else
sprintf(g->Message, MSG(READ_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR),
fn, strerror(errno)); fn, strerror(errno));
if (trace(1)) if (trace(1))
@@ -2624,7 +2631,7 @@ bool VECFAM::WriteBlock(PGLOBAL g, PVCTCOL colp)
if (Tdbp->GetMode() == MODE_UPDATE && !UseTemp) if (Tdbp->GetMode() == MODE_UPDATE && !UseTemp)
if (fseek(T_Streams[i], len, SEEK_SET)) { if (fseek(T_Streams[i], len, SEEK_SET)) {
sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FSEEK_ERROR), strerror(errno));
return true; return true;
} // endif } // endif
@@ -2638,8 +2645,8 @@ bool VECFAM::WriteBlock(PGLOBAL g, PVCTCOL colp)
(size_t)colp->Clen, n, T_Streams[i])) { (size_t)colp->Clen, n, T_Streams[i])) {
char fn[_MAX_PATH]; char fn[_MAX_PATH];
sprintf(fn, (UseTemp) ? Tempat : Colfn, colp->Index); snprintf(fn, _MAX_PATH, (UseTemp) ? Tempat : Colfn, colp->Index);
sprintf(g->Message, MSG(WRITE_STRERROR), fn, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_STRERROR), fn, strerror(errno));
if (trace(1)) if (trace(1))
htrc("Write error: %s\n", strerror(errno)); htrc("Write error: %s\n", strerror(errno));
@@ -2772,7 +2779,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i)
PFBLOCK fp; PFBLOCK fp;
PDBUSER dup = PlgGetUser(g); PDBUSER dup = PlgGetUser(g);
sprintf(filename, Colfn, i+1); snprintf(filename, _MAX_PATH, Colfn, i+1);
/*********************************************************************/ /*********************************************************************/
/* The whole file will be mapped so we can use it as */ /* The whole file will be mapped so we can use it as */
@@ -2808,7 +2815,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i)
DWORD rc = GetLastError(); DWORD rc = GetLastError();
if (!(*g->Message)) if (!(*g->Message))
sprintf(g->Message, MSG(OPEN_MODE_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR),
"map", (int) rc, filename); "map", (int) rc, filename);
if (trace(1)) if (trace(1))
htrc("%s\n", g->Message); htrc("%s\n", g->Message);
@@ -2835,7 +2842,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i)
if (!Memcol[i]) { if (!Memcol[i]) {
CloseFileHandle(hFile); CloseFileHandle(hFile);
sprintf(g->Message, MSG(MAP_VIEW_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(MAP_VIEW_ERROR),
filename, GetLastError()); filename, GetLastError());
return true; return true;
} // endif Memory } // endif Memory
@@ -2983,7 +2990,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc)
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
if (drc == 0xFFFFFFFF) { if (drc == 0xFFFFFFFF) {
sprintf(g->Message, MSG(FUNCTION_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(FUNCTION_ERROR),
"SetFilePointer", GetLastError()); "SetFilePointer", GetLastError());
CloseHandle(fp->Handle); CloseHandle(fp->Handle);
return RC_FX; return RC_FX;
@@ -2993,7 +3000,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc)
htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc); htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
if (!SetEndOfFile(fp->Handle)) { if (!SetEndOfFile(fp->Handle)) {
sprintf(g->Message, MSG(FUNCTION_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(FUNCTION_ERROR),
"SetEndOfFile", GetLastError()); "SetEndOfFile", GetLastError());
CloseHandle(fp->Handle); CloseHandle(fp->Handle);
return RC_FX; return RC_FX;
@@ -3002,7 +3009,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc)
CloseHandle(fp->Handle); CloseHandle(fp->Handle);
#else // UNIX #else // UNIX
if (ftruncate(fp->Handle, (off_t)n)) { if (ftruncate(fp->Handle, (off_t)n)) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(TRUNCATE_ERROR), strerror(errno));
close(fp->Handle); close(fp->Handle);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -3072,12 +3079,12 @@ bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
sprintf(g->Message, MSG(SFP_ERROR), buf); snprintf(g->Message, sizeof(g->Message), MSG(SFP_ERROR), buf);
return true; return true;
} // endif } // endif
#else // !_WIN32 #else // !_WIN32
if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) { if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) {
sprintf(g->Message, MSG(ERROR_IN_LSK), errno); snprintf(g->Message, sizeof(g->Message), MSG(ERROR_IN_LSK), errno);
return true; return true;
} // endif } // endif
#endif // !_WIN32 #endif // !_WIN32
@@ -3103,7 +3110,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
char buf[256]; // , *fn = (h == Hfile) ? To_File : "Tempfile"; char buf[256]; // , *fn = (h == Hfile) ? To_File : "Tempfile";
if (brc) if (brc)
strcpy(buf, MSG(BAD_BYTE_READ)); strncpy(buf, MSG(BAD_BYTE_READ), 256);
else { else {
drc = GetLastError(); drc = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
@@ -3111,7 +3118,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
} // endelse brc } // endelse brc
sprintf(g->Message, MSG(READ_ERROR), To_File, buf); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), To_File, buf);
if (trace(1)) if (trace(1))
htrc("BIGREAD: %s\n", g->Message); htrc("BIGREAD: %s\n", g->Message);
@@ -3125,7 +3132,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
if (nbr != (ssize_t)len) { if (nbr != (ssize_t)len) {
const char *fn = (h == Hfile) ? To_File : "Tempfile"; const char *fn = (h == Hfile) ? To_File : "Tempfile";
sprintf(g->Message, MSG(READ_ERROR), fn, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), fn, strerror(errno));
if (trace(1)) if (trace(1))
htrc("BIGREAD: nbr=%d len=%d errno=%d %s\n", htrc("BIGREAD: nbr=%d len=%d errno=%d %s\n",
@@ -3157,7 +3164,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
PCSZ fn = (h == Hfile) ? To_File : "Tempfile"; PCSZ fn = (h == Hfile) ? To_File : "Tempfile";
if (brc) if (brc)
strcpy(buf, MSG(BAD_BYTE_NUM)); strncpy(buf, MSG(BAD_BYTE_NUM), 256);
else { else {
drc = GetLastError(); drc = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
@@ -3165,7 +3172,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
} // endelse brc } // endelse brc
sprintf(g->Message, MSG(WRITE_STRERROR), fn, buf); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_STRERROR), fn, buf);
if (trace(1)) if (trace(1))
htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n", htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
@@ -3180,7 +3187,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
if (nbw != (ssize_t)len) { if (nbw != (ssize_t)len) {
const char *fn = (h == Hfile) ? To_File : "Tempfile"; const char *fn = (h == Hfile) ? To_File : "Tempfile";
sprintf(g->Message, MSG(WRITE_STRERROR), fn, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(WRITE_STRERROR), fn, strerror(errno));
if (trace(1)) if (trace(1))
htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n", htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
@@ -3204,7 +3211,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g)
HANDLE h; HANDLE h;
if (Header < 1 || Header > 3 || !MaxBlk) { if (Header < 1 || Header > 3 || !MaxBlk) {
sprintf(g->Message, "Invalid header value %d", Header); snprintf(g->Message, sizeof(g->Message), "Invalid header value %d", Header);
return -1; return -1;
} else } else
n = (Header == 1) ? (int)sizeof(VECHEADER) : 0; n = (Header == 1) ? (int)sizeof(VECHEADER) : 0;
@@ -3212,7 +3219,10 @@ int BGVFAM::GetBlockInfo(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath()); PlugSetPath(filename, To_File, Tdbp->GetPath());
if (Header == 2) if (Header == 2)
strcat(PlugRemoveType(filename, filename), ".blk"); {
PlugRemoveType(filename, filename);
strncat(filename, ".blk", _MAX_PATH - strlen(filename));
}
#if defined(_WIN32) #if defined(_WIN32)
LARGE_INTEGER len; LARGE_INTEGER len;
@@ -3246,10 +3256,10 @@ int BGVFAM::GetBlockInfo(PGLOBAL g)
/*b = */ BigSeek(g, h, -(BIGINT)sizeof(vh), true); /*b = */ BigSeek(g, h, -(BIGINT)sizeof(vh), true);
if (BigRead(g, h, &vh, sizeof(vh))) { if (BigRead(g, h, &vh, sizeof(vh))) {
sprintf(g->Message, "Error reading header file %s", filename); snprintf(g->Message, sizeof(g->Message), "Error reading header file %s", filename);
n = -1; n = -1;
} else if (MaxBlk * Nrec != vh.MaxRec) { } else if (MaxBlk * Nrec != vh.MaxRec) {
sprintf(g->Message, "MaxRec=%d doesn't match MaxBlk=%d Nrec=%d", snprintf(g->Message, sizeof(g->Message), "MaxRec=%d doesn't match MaxBlk=%d Nrec=%d",
vh.MaxRec, MaxBlk, Nrec); vh.MaxRec, MaxBlk, Nrec);
n = -1; n = -1;
} else { } else {
@@ -3288,7 +3298,10 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
b = true; b = true;
} else // Header == 2 } else // Header == 2
strcat(PlugRemoveType(filename, filename), ".blk"); {
PlugRemoveType(filename, filename);
strncat(filename, ".blk", _MAX_PATH - strlen(filename));
}
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
#if defined(_WIN32) #if defined(_WIN32)
@@ -3304,7 +3317,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
#endif // !_WIN32 #endif // !_WIN32
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
sprintf(g->Message, "Error opening header file %s", filename); snprintf(g->Message, sizeof(g->Message), "Error opening header file %s", filename);
return true; return true;
} // endif h } // endif h
@@ -3317,7 +3330,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
vh.NumRec = (Block - 1) * Nrec + Last; vh.NumRec = (Block - 1) * Nrec + Last;
if (BigWrite(g, h, &vh, sizeof(vh))) { if (BigWrite(g, h, &vh, sizeof(vh))) {
sprintf(g->Message, "Error writing header file %s", filename); snprintf(g->Message, sizeof(g->Message), "Error writing header file %s", filename);
rc = true; rc = true;
} // endif fread } // endif fread
@@ -3381,11 +3394,11 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
err: err:
rc = GetLastError(); rc = GetLastError();
sprintf(g->Message, MSG(EMPTY_FILE), p, filename); snprintf(g->Message, sizeof(g->Message), MSG(EMPTY_FILE), p, filename);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)filename, sizeof(filename), NULL); (LPTSTR)filename, sizeof(filename), NULL);
strcat(g->Message, filename); strncat(g->Message, filename, sizeof(g->Message) - strlen(g->Message));
if (h != INVALID_HANDLE_VALUE) if (h != INVALID_HANDLE_VALUE)
CloseHandle(h); CloseHandle(h);
@@ -3417,7 +3430,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
return false; return false;
err: err:
sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(MAKE_EMPTY_FILE), To_File, strerror(errno));
close(h); close(h);
return true; return true;
#endif // !_WIN32 #endif // !_WIN32
@@ -3434,7 +3447,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g)
PDBUSER dbuserp = PlgGetUser(g); PDBUSER dbuserp = PlgGetUser(g);
if ((To_Fb && To_Fb->Count) || Hfile != INVALID_HANDLE_VALUE) { if ((To_Fb && To_Fb->Count) || Hfile != INVALID_HANDLE_VALUE) {
sprintf(g->Message, MSG(FILE_OPEN_YET), To_File); snprintf(g->Message, sizeof(g->Message), MSG(FILE_OPEN_YET), To_File);
return true; return true;
} // endif } // endif
@@ -3505,7 +3518,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g)
creation = OPEN_EXISTING; creation = OPEN_EXISTING;
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
return true; return true;
} // endswitch } // endswitch
@@ -3517,11 +3530,11 @@ bool BGVFAM::OpenTableFile(PGLOBAL g)
if (Hfile == INVALID_HANDLE_VALUE) { if (Hfile == INVALID_HANDLE_VALUE) {
rc = GetLastError(); rc = GetLastError();
sprintf(g->Message, MSG(OPEN_ERROR), rc, mode, filename); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_ERROR), rc, mode, filename);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)filename, sizeof(filename), NULL); (LPTSTR)filename, sizeof(filename), NULL);
strcat(g->Message, filename); strncat(g->Message, filename, sizeof(g->Message) - strlen(g->Message));
} // endif Hfile } // endif Hfile
if (trace(1)) if (trace(1))
@@ -3540,7 +3553,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g)
if (of.LowPart == INVALID_SET_FILE_POINTER && if (of.LowPart == INVALID_SET_FILE_POINTER &&
(rc = GetLastError()) != NO_ERROR) { (rc = GetLastError()) != NO_ERROR) {
sprintf(g->Message, MSG(ERROR_IN_SFP), rc); snprintf(g->Message, sizeof(g->Message), MSG(ERROR_IN_SFP), rc);
CloseHandle(Hfile); CloseHandle(Hfile);
Hfile = INVALID_HANDLE_VALUE; Hfile = INVALID_HANDLE_VALUE;
} // endif } // endif
@@ -3590,7 +3603,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g)
// This will delete the whole file and provoque ReadDB to // This will delete the whole file and provoque ReadDB to
// return immediately. // return immediately.
oflag = O_RDWR | O_TRUNC; oflag = O_RDWR | O_TRUNC;
strcpy(g->Message, MSG(NO_VCT_DELETE)); strncpy(g->Message, MSG(NO_VCT_DELETE), sizeof(g->Message));
break; break;
} // endif } // endif
@@ -3601,7 +3614,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g)
oflag = (UseTemp) ? O_RDONLY : O_RDWR; oflag = (UseTemp) ? O_RDONLY : O_RDWR;
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
return true; return true;
} // endswitch } // endswitch
@@ -3609,8 +3622,8 @@ bool BGVFAM::OpenTableFile(PGLOBAL g)
if (Hfile == INVALID_HANDLE_VALUE) { if (Hfile == INVALID_HANDLE_VALUE) {
rc = errno; rc = errno;
sprintf(g->Message, MSG(OPEN_ERROR), rc, mode, filename); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_ERROR), rc, mode, filename);
strcat(g->Message, strerror(errno)); strncat(g->Message, strerror(errno), sizeof(g->Message) - strlen(g->Message));
} // endif Hfile } // endif Hfile
if (trace(1)) if (trace(1))
@@ -3765,7 +3778,7 @@ int BGVFAM::WriteBuffer(PGLOBAL g)
} else { } else {
// Mode Insert // Mode Insert
if (MaxBlk && CurBlk == MaxBlk) { if (MaxBlk && CurBlk == MaxBlk) {
strcpy(g->Message, MSG(TRUNC_BY_ESTIM)); strncpy(g->Message, MSG(TRUNC_BY_ESTIM), sizeof(g->Message));
return RC_EF; // Too many lines for a Vector formatted table return RC_EF; // Too many lines for a Vector formatted table
} // endif MaxBlk } // endif MaxBlk
@@ -3915,12 +3928,12 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc)
if (!SetEndOfFile(Hfile)) { if (!SetEndOfFile(Hfile)) {
DWORD drc = GetLastError(); DWORD drc = GetLastError();
sprintf(g->Message, MSG(SETEOF_ERROR), drc); snprintf(g->Message, sizeof(g->Message), MSG(SETEOF_ERROR), drc);
return RC_FX; return RC_FX;
} // endif error } // endif error
#else // !_WIN32 #else // !_WIN32
if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) { if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(TRUNCATE_ERROR), strerror(errno));
return RC_FX; return RC_FX;
} // endif } // endif
#endif // !_WIN32 #endif // !_WIN32
@@ -3953,7 +3966,8 @@ bool BGVFAM::OpenTempFile(PGLOBAL g)
/*********************************************************************/ /*********************************************************************/
tempname = (char*)PlugSubAlloc(g, NULL, _MAX_PATH); tempname = (char*)PlugSubAlloc(g, NULL, _MAX_PATH);
PlugSetPath(tempname, To_File, Tdbp->GetPath()); PlugSetPath(tempname, To_File, Tdbp->GetPath());
strcat(PlugRemoveType(tempname, tempname), ".t"); PlugRemoveType(tempname, tempname);
strncat(tempname, ".t", _MAX_PATH - strlen(tempname));
if (!MaxBlk) if (!MaxBlk)
remove(tempname); // Be sure it does not exist yet remove(tempname); // Be sure it does not exist yet
@@ -3968,11 +3982,11 @@ bool BGVFAM::OpenTempFile(PGLOBAL g)
if (Tfile == INVALID_HANDLE_VALUE) { if (Tfile == INVALID_HANDLE_VALUE) {
DWORD rc = GetLastError(); DWORD rc = GetLastError();
sprintf(g->Message, MSG(OPEN_ERROR), rc, MODE_DELETE, tempname); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_ERROR), rc, MODE_DELETE, tempname);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)tempname, _MAX_PATH, NULL); (LPTSTR)tempname, _MAX_PATH, NULL);
strcat(g->Message, tempname); strncat(g->Message, tempname, sizeof(g->Message) - strlen(g->Message));
return true; return true;
} // endif Tfile } // endif Tfile
#else // UNIX #else // UNIX
@@ -3982,8 +3996,8 @@ bool BGVFAM::OpenTempFile(PGLOBAL g)
if (Tfile == INVALID_HANDLE_VALUE) { if (Tfile == INVALID_HANDLE_VALUE) {
int rc = errno; int rc = errno;
sprintf(g->Message, MSG(OPEN_ERROR), rc, MODE_INSERT, tempname); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_ERROR), rc, MODE_INSERT, tempname);
strcat(g->Message, strerror(errno)); strncat(g->Message, strerror(errno), sizeof(g->Message) - strlen(g->Message));
return true; return true;
} //endif Tfile } //endif Tfile
#endif // UNIX #endif // UNIX

View File

@@ -114,7 +114,7 @@ static bool ZipFile(PGLOBAL g, ZIPUTIL *zutp, PCSZ fn, PCSZ entry, char *buf)
if (zutp->addEntry(g, entry)) if (zutp->addEntry(g, entry))
return true; return true;
else if (!(fin = fopen(fn, "rb"))) { else if (!(fin = fopen(fn, "rb"))) {
sprintf(g->Message, "error in opening %s for reading", fn); snprintf(g->Message, sizeof(g->Message), "error in opening %s for reading", fn);
return true; return true;
} // endif fin } // endif fin
@@ -122,7 +122,7 @@ static bool ZipFile(PGLOBAL g, ZIPUTIL *zutp, PCSZ fn, PCSZ entry, char *buf)
size_read = (int)fread(buf, 1, size_buf, fin); size_read = (int)fread(buf, 1, size_buf, fin);
if (size_read < size_buf && feof(fin) == 0) { if (size_read < size_buf && feof(fin) == 0) {
sprintf(g->Message, "error in reading %s", fn); snprintf(g->Message, sizeof(g->Message), "error in reading %s", fn);
rc = RC_FX; rc = RC_FX;
} // endif size_read } // endif size_read
@@ -130,7 +130,7 @@ static bool ZipFile(PGLOBAL g, ZIPUTIL *zutp, PCSZ fn, PCSZ entry, char *buf)
rc = zutp->writeEntry(g, buf, size_read); rc = zutp->writeEntry(g, buf, size_read);
if (rc == RC_FX) if (rc == RC_FX)
sprintf(g->Message, "error in writing %s in the zipfile", fn); snprintf(g->Message, sizeof(g->Message), "error in writing %s in the zipfile", fn);
} // endif size_read } // endif size_read
@@ -170,7 +170,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf)
if (rc != ERROR_FILE_NOT_FOUND) { if (rc != ERROR_FILE_NOT_FOUND) {
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), 0, (LPTSTR)&filename, sizeof(filename), NULL); NULL, GetLastError(), 0, (LPTSTR)&filename, sizeof(filename), NULL);
sprintf(g->Message, MSG(BAD_FILE_HANDLE), filename); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FILE_HANDLE), filename);
return true; return true;
} else { } else {
strcpy(g->Message, "Cannot find any file to load"); strcpy(g->Message, "Cannot find any file to load");
@@ -194,7 +194,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf)
rc = GetLastError(); rc = GetLastError();
if (rc != ERROR_NO_MORE_FILES) { if (rc != ERROR_NO_MORE_FILES) {
sprintf(g->Message, MSG(NEXT_FILE_ERROR), rc); snprintf(g->Message, sizeof(g->Message), MSG(NEXT_FILE_ERROR), rc);
FindClose(hSearch); FindClose(hSearch);
return true; return true;
} // endif rc } // endif rc
@@ -221,7 +221,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf)
// Start searching files in the target directory. // Start searching files in the target directory.
if (!(dir = opendir(direc))) { if (!(dir = opendir(direc))) {
sprintf(g->Message, MSG(BAD_DIRECTORY), direc, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(BAD_DIRECTORY), direc, strerror(errno));
return true; return true;
} // endif dir } // endif dir
@@ -229,7 +229,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf)
strcat(strcpy(fn, direc), entry->d_name); strcat(strcpy(fn, direc), entry->d_name);
if (lstat(fn, &fileinfo) < 0) { if (lstat(fn, &fileinfo) < 0) {
sprintf(g->Message, "%s: %s", fn, strerror(errno)); snprintf(g->Message, sizeof(g->Message), "%s: %s", fn, strerror(errno));
return true; return true;
} else if (!S_ISREG(fileinfo.st_mode)) } else if (!S_ISREG(fileinfo.st_mode))
continue; // Not a regular file (should test for links) continue; // Not a regular file (should test for links)
@@ -343,7 +343,7 @@ bool ZIPUTIL::open(PGLOBAL g, PCSZ filename, bool append)
if (!zipfile && !(zipfile = zipOpen64(filename, if (!zipfile && !(zipfile = zipOpen64(filename,
append ? APPEND_STATUS_ADDINZIP append ? APPEND_STATUS_ADDINZIP
: APPEND_STATUS_CREATE))) : APPEND_STATUS_CREATE)))
sprintf(g->Message, "Zipfile open error on %s", filename); snprintf(g->Message, sizeof(g->Message), "Zipfile open error on %s", filename);
return (zipfile == NULL); return (zipfile == NULL);
} // end of open } // end of open
@@ -430,7 +430,7 @@ bool ZIPUTIL::addEntry(PGLOBAL g, PCSZ entry)
int ZIPUTIL::writeEntry(PGLOBAL g, char *buf, int len) int ZIPUTIL::writeEntry(PGLOBAL g, char *buf, int len)
{ {
if (zipWriteInFileInZip(zipfile, buf, len) < 0) { if (zipWriteInFileInZip(zipfile, buf, len) < 0) {
sprintf(g->Message, "Error writing %s in the zipfile", target); snprintf(g->Message, sizeof(g->Message), "Error writing %s in the zipfile", target);
return RC_FX; return RC_FX;
} // endif zipWriteInFileInZip } // endif zipWriteInFileInZip
@@ -549,7 +549,7 @@ starCheck:
bool UNZIPUTL::open(PGLOBAL g, PCSZ filename) bool UNZIPUTL::open(PGLOBAL g, PCSZ filename)
{ {
if (!zipfile && !(zipfile = unzOpen64(filename))) if (!zipfile && !(zipfile = unzOpen64(filename)))
sprintf(g->Message, "Zipfile open error on %s", filename); snprintf(g->Message, sizeof(g->Message), "Zipfile open error on %s", filename);
return (zipfile == NULL); return (zipfile == NULL);
} // end of open } // end of open
@@ -584,7 +584,7 @@ int UNZIPUTL::findEntry(PGLOBAL g, bool next)
if (rc == UNZ_END_OF_LIST_OF_FILE) if (rc == UNZ_END_OF_LIST_OF_FILE)
return RC_EF; return RC_EF;
else if (rc != UNZ_OK) { else if (rc != UNZ_OK) {
sprintf(g->Message, "unzGoToNextFile rc = %d", rc); snprintf(g->Message, sizeof(g->Message), "unzGoToNextFile rc = %d", rc);
return RC_FX; return RC_FX;
} // endif rc } // endif rc
@@ -598,7 +598,7 @@ int UNZIPUTL::findEntry(PGLOBAL g, bool next)
return RC_OK; return RC_OK;
} else { } else {
sprintf(g->Message, "GetCurrentFileInfo rc = %d", rc); snprintf(g->Message, sizeof(g->Message), "GetCurrentFileInfo rc = %d", rc);
return RC_FX; return RC_FX;
} // endif rc } // endif rc
@@ -655,10 +655,10 @@ bool UNZIPUTL::OpenTable(PGLOBAL g, MODE mode, PCSZ fn)
rc = unzLocateFile(zipfile, target, 0); rc = unzLocateFile(zipfile, target, 0);
if (rc == UNZ_END_OF_LIST_OF_FILE) { if (rc == UNZ_END_OF_LIST_OF_FILE) {
sprintf(g->Message, "Target file %s not in %s", target, fn); snprintf(g->Message, sizeof(g->Message), "Target file %s not in %s", target, fn);
return true; return true;
} else if (rc != UNZ_OK) { } else if (rc != UNZ_OK) {
sprintf(g->Message, "unzLocateFile rc=%d", rc); snprintf(g->Message, sizeof(g->Message), "unzLocateFile rc=%d", rc);
return true; return true;
} // endif's rc } // endif's rc
@@ -666,7 +666,7 @@ bool UNZIPUTL::OpenTable(PGLOBAL g, MODE mode, PCSZ fn)
if ((rc = findEntry(g, false)) == RC_FX) if ((rc = findEntry(g, false)) == RC_FX)
return true; return true;
else if (rc == RC_EF) { else if (rc == RC_EF) {
sprintf(g->Message, "No match of %s in %s", target, fn); snprintf(g->Message, sizeof(g->Message), "No match of %s in %s", target, fn);
return true; return true;
} // endif rc } // endif rc
@@ -741,10 +741,10 @@ bool UNZIPUTL::openEntry(PGLOBAL g)
NULL, 0, NULL, 0); NULL, 0, NULL, 0);
if (rc != UNZ_OK) { if (rc != UNZ_OK) {
sprintf(g->Message, "unzGetCurrentFileInfo64 rc=%d", rc); snprintf(g->Message, sizeof(g->Message), "unzGetCurrentFileInfo64 rc=%d", rc);
return true; return true;
} else if ((rc = unzOpenCurrentFilePassword(zipfile, pwd)) != UNZ_OK) { } else if ((rc = unzOpenCurrentFilePassword(zipfile, pwd)) != UNZ_OK) {
sprintf(g->Message, "unzOpen fn=%s rc=%d", fn, rc); snprintf(g->Message, sizeof(g->Message), "unzOpen fn=%s rc=%d", fn, rc);
return true; return true;
} // endif rc } // endif rc
@@ -758,7 +758,7 @@ bool UNZIPUTL::openEntry(PGLOBAL g)
} // end try/catch } // end try/catch
if ((rc = unzReadCurrentFile(zipfile, memory, size)) < 0) { if ((rc = unzReadCurrentFile(zipfile, memory, size)) < 0) {
sprintf(g->Message, "unzReadCurrentFile rc = %d", rc); snprintf(g->Message, sizeof(g->Message), "unzReadCurrentFile rc = %d", rc);
unzCloseCurrentFile(zipfile); unzCloseCurrentFile(zipfile);
delete[] memory; delete[] memory;
memory = NULL; memory = NULL;
@@ -1020,7 +1020,7 @@ int UZXFAM::Cardinality(PGLOBAL g)
if (!(len % Lrecl)) if (!(len % Lrecl))
card = len / (int)Lrecl; // Fixed length file card = len / (int)Lrecl; // Fixed length file
else else
sprintf(g->Message, MSG(NOT_FIXED_LEN), zutp->fn, len, Lrecl); snprintf(g->Message, sizeof(g->Message), MSG(NOT_FIXED_LEN), zutp->fn, len, Lrecl);
// Set number of blocks for later use // Set number of blocks for later use
Block = (card > 0) ? (card + Nrec - 1) / Nrec : 0; Block = (card > 0) ? (card + Nrec - 1) / Nrec : 0;
@@ -1074,7 +1074,7 @@ int UZXFAM::GetNext(PGLOBAL g)
int len = zutp->size; int len = zutp->size;
if (len % Lrecl) { if (len % Lrecl) {
sprintf(g->Message, MSG(NOT_FIXED_LEN), zutp->fn, len, Lrecl); snprintf(g->Message, sizeof(g->Message), MSG(NOT_FIXED_LEN), zutp->fn, len, Lrecl);
return RC_FX; return RC_FX;
} // endif size } // endif size
@@ -1144,7 +1144,7 @@ int UZDFAM::dbfhead(PGLOBAL g, void* buf)
// Some headers just have 1D others have 1D00 following fields // Some headers just have 1D others have 1D00 following fields
if (endmark[0] != EOH && endmark[1] != EOH) { if (endmark[0] != EOH && endmark[1] != EOH) {
sprintf(g->Message, MSG(NO_0DH_HEAD), dbc); snprintf(g->Message, sizeof(g->Message), MSG(NO_0DH_HEAD), dbc);
if (rc == RC_OK) if (rc == RC_OK)
return RC_FX; return RC_FX;
@@ -1264,7 +1264,7 @@ int UZDFAM::GetNext(PGLOBAL g)
#if 0 #if 0
if (len % Lrecl) { if (len % Lrecl) {
sprintf(g->Message, MSG(NOT_FIXED_LEN), zutp->fn, len, Lrecl); snprintf(g->Message, sizeof(g->Message), MSG(NOT_FIXED_LEN), zutp->fn, len, Lrecl);
return RC_FX; return RC_FX;
} // endif size } // endif size
#endif // 0 #endif // 0

View File

@@ -83,7 +83,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
case OP_LE: bt = 0x04; break; case OP_LE: bt = 0x04; break;
case OP_EXIST: bt = 0x00; break; case OP_EXIST: bt = 0x00; break;
default: default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FILTER_OP), opc);
throw (int)TYPE_FILTER; throw (int)TYPE_FILTER;
} // endswitch opc } // endswitch opc
@@ -1021,7 +1021,7 @@ bool FILTER::Convert(PGLOBAL g, bool having)
// Special case of the LIKE operator. // Special case of the LIKE operator.
if (Opc == OP_LIKE) { if (Opc == OP_LIKE) {
if (!IsTypeChar((int)Test[i].B_T)) { if (!IsTypeChar((int)Test[i].B_T)) {
sprintf(g->Message, MSG(BAD_TYPE_LIKE), i, Test[i].B_T); snprintf(g->Message, sizeof(g->Message), MSG(BAD_TYPE_LIKE), i, Test[i].B_T);
return TRUE; return TRUE;
} // endif } // endif
@@ -1129,11 +1129,11 @@ bool FILTER::Convert(PGLOBAL g, bool having)
// Last check to be sure all is correct. // Last check to be sure all is correct.
if (Test[0].B_T != Test[1].B_T) { if (Test[0].B_T != Test[1].B_T) {
sprintf(g->Message, MSG(BAD_FILTER_CONV), Test[0].B_T, Test[1].B_T); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FILTER_CONV), Test[0].B_T, Test[1].B_T);
return TRUE; return TRUE;
//} else if (Test[0].B_T == TYPE_LIST && //} else if (Test[0].B_T == TYPE_LIST &&
// ((LSTVAL*)Val(0))->GetN() != ((LSTVAL*)Val(1))->GetN()) { // ((LSTVAL*)Val(0))->GetN() != ((LSTVAL*)Val(1))->GetN()) {
// sprintf(g->Message, MSG(ROW_ARGNB_ERR), // snprintf(g->Message, sizeof(g->Message), MSG(ROW_ARGNB_ERR),
// ((LSTVAL*)Val(0))->GetN(), ((LSTVAL*)Val(1))->GetN()); // ((LSTVAL*)Val(0))->GetN(), ((LSTVAL*)Val(1))->GetN());
// return TRUE; // return TRUE;
} // endif's B_T } // endif's B_T
@@ -1367,7 +1367,7 @@ bool FILTER::Eval(PGLOBAL g)
return FALSE; return FALSE;
FilterError: FilterError:
sprintf(g->Message, MSG(BAD_FILTER), snprintf(g->Message, sizeof(g->Message), MSG(BAD_FILTER),
Opc, Test[0].B_T, Test[1].B_T, GetArgType(0), GetArgType(1)); Opc, Test[0].B_T, Test[1].B_T, GetArgType(0), GetArgType(1));
return TRUE; return TRUE;
} // end of Eval } // end of Eval

View File

@@ -1403,7 +1403,8 @@ char *ha_connect::GetRealString(PCSZ s)
if (IsPartitioned() && s && *partname) { if (IsPartitioned() && s && *partname) {
sv= (char*)PlugSubAlloc(xp->g, NULL, 0); sv= (char*)PlugSubAlloc(xp->g, NULL, 0);
sprintf(sv, s, partname); PPOOLHEADER pph = (PPOOLHEADER)xp->g->Sarea;
snprintf(sv, xp->g->Sarea_Size - pph->To_Free, s, partname);
PlugSubAlloc(xp->g, NULL, strlen(sv) + 1); PlugSubAlloc(xp->g, NULL, strlen(sv) + 1);
} else } else
sv= (char*)s; sv= (char*)s;
@@ -2082,7 +2083,7 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
// Trying to update a column used for partitioning // Trying to update a column used for partitioning
// This cannot be currently done because it may require // This cannot be currently done because it may require
// a row to be moved in another partition. // a row to be moved in another partition.
sprintf(g->Message, snprintf(g->Message, sizeof(g->Message),
"Cannot update column %s because it is used for partitioning", "Cannot update column %s because it is used for partitioning",
p); p);
return HA_ERR_INTERNAL_ERROR; return HA_ERR_INTERNAL_ERROR;
@@ -2135,7 +2136,7 @@ bool ha_connect::CheckColumnList(PGLOBAL g)
for (field= table->field; fp= *field; field++) for (field= table->field; fp= *field; field++)
if (bitmap_is_set(map, fp->field_index)) { if (bitmap_is_set(map, fp->field_index)) {
if (!(colp= tdbp->ColDB(g, (PSZ)fp->field_name.str, 0))) { if (!(colp= tdbp->ColDB(g, (PSZ)fp->field_name.str, 0))) {
sprintf(g->Message, "Column %s not found in %s", snprintf(g->Message, sizeof(g->Message), "Column %s not found in %s",
fp->field_name.str, tdbp->GetName()); fp->field_name.str, tdbp->GetName());
throw 1; throw 1;
} // endif colp } // endif colp
@@ -2295,7 +2296,7 @@ int ha_connect::MakeRecord(char *buf)
char buf[256]; char buf[256];
THD *thd= ha_thd(); THD *thd= ha_thd();
sprintf(buf, "Out of range value %.140s for column '%s' at row %ld", snprintf(buf, sizeof(buf), "Out of range value %.140s for column '%s' at row %ld",
value->GetCharString(val), value->GetCharString(val),
fp->field_name.str, fp->field_name.str,
thd->get_stmt_da()->current_row_for_warning()); thd->get_stmt_da()->current_row_for_warning());
@@ -2577,7 +2578,7 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
op= OP_LE; op= OP_LE;
break; break;
default: default:
sprintf(g->Message, "cannot handle flag %d", ranges[i]->flag); snprintf(g->Message, sizeof(g->Message), "cannot handle flag %d", ranges[i]->flag);
goto err; goto err;
} // endswitch flag } // endswitch flag
@@ -4897,7 +4898,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
&& sqlcom != SQLCOM_FLUSH && sqlcom != SQLCOM_FLUSH
&& sqlcom != SQLCOM_BEGIN && sqlcom != SQLCOM_BEGIN
&& sqlcom != SQLCOM_DROP_TABLE) { && sqlcom != SQLCOM_DROP_TABLE) {
sprintf(g->Message, "external_lock: unexpected command %d", sqlcom); snprintf(g->Message, sizeof(g->Message), "external_lock: unexpected command %d", sqlcom);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
DBUG_RETURN(0); DBUG_RETURN(0);
} else if (g->Xchk) { } else if (g->Xchk) {
@@ -4907,7 +4908,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
DBUG_RETURN(0); DBUG_RETURN(0);
} else if (!tdbp->GetDef()->Indexable()) { } else if (!tdbp->GetDef()->Indexable()) {
sprintf(g->Message, "external_lock: Table %s is not indexable", tdbp->GetName()); snprintf(g->Message, sizeof(g->Message), "external_lock: Table %s is not indexable", tdbp->GetName());
// DBUG_RETURN(HA_ERR_INTERNAL_ERROR); causes assert error // DBUG_RETURN(HA_ERR_INTERNAL_ERROR); causes assert error
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
DBUG_RETURN(0); DBUG_RETURN(0);
@@ -5803,7 +5804,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#endif // PROMPT_OK #endif // PROMPT_OK
} else if (!dsn) { } else if (!dsn) {
sprintf(g->Message, "Missing %s connection string", topt->type); snprintf(g->Message, sizeof(g->Message), "Missing %s connection string", topt->type);
} else { } else {
// Store ODBC additional parameters // Store ODBC additional parameters
sop= (POPARM)PlugSubAlloc(g, NULL, sizeof(ODBCPARM)); sop= (POPARM)PlugSubAlloc(g, NULL, sizeof(ODBCPARM));
@@ -5858,9 +5859,9 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
// fall through // fall through
case TAB_CSV: case TAB_CSV:
if (!fn && fnc != FNC_NO) if (!fn && fnc != FNC_NO)
sprintf(g->Message, "Missing %s file name", topt->type); snprintf(g->Message, sizeof(g->Message), "Missing %s file name", topt->type);
else if (sep && strlen(sep) > 1) else if (sep && strlen(sep) > 1)
sprintf(g->Message, "Invalid separator %s", sep); snprintf(g->Message, sizeof(g->Message), "Invalid separator %s", sep);
else else
ok= true; ok= true;
@@ -5917,7 +5918,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
case TAB_OCCUR: case TAB_OCCUR:
if (!src && !stricmp(tab, create_info->alias.str) && if (!src && !stricmp(tab, create_info->alias.str) &&
(!db || !stricmp(db, table_s->db.str))) (!db || !stricmp(db, table_s->db.str)))
sprintf(g->Message, "A %s table cannot refer to itself", topt->type); snprintf(g->Message, sizeof(g->Message), "A %s table cannot refer to itself", topt->type);
else else
ok= true; ok= true;
@@ -5939,7 +5940,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
dsn= strz(g, create_info->connect_string); dsn= strz(g, create_info->connect_string);
if (!fn && !zfn && !mul && !dsn) if (!fn && !zfn && !mul && !dsn)
sprintf(g->Message, "Missing %s file name", topt->type); snprintf(g->Message, sizeof(g->Message), "Missing %s file name", topt->type);
else if (dsn && !topt->tabname) else if (dsn && !topt->tabname)
topt->tabname= tab; topt->tabname= tab;
@@ -5966,13 +5967,13 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
ok= true; ok= true;
break; break;
default: default:
sprintf(g->Message, "Cannot get column info for table type %s", topt->type); snprintf(g->Message, sizeof(g->Message), "Cannot get column info for table type %s", topt->type);
break; break;
} // endif ttp } // endif ttp
// Check for supported catalog function // Check for supported catalog function
if (ok && !(supfnc & fnc)) { if (ok && !(supfnc & fnc)) {
sprintf(g->Message, "Unsupported catalog function %s for table type %s", snprintf(g->Message, sizeof(g->Message), "Unsupported catalog function %s for table type %s",
fncn, topt->type); fncn, topt->type);
ok= false; ok= false;
} // endif supfnc } // endif supfnc
@@ -6028,7 +6029,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
qrp= ODBCDrivers(g, mxr, true); qrp= ODBCDrivers(g, mxr, true);
break; break;
default: default:
sprintf(g->Message, "invalid catfunc %s", fncn); snprintf(g->Message, sizeof(g->Message), "invalid catfunc %s", fncn);
break; break;
} // endswitch info } // endswitch info
@@ -6059,7 +6060,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
qrp= JDBCDrivers(g, mxr, true); qrp= JDBCDrivers(g, mxr, true);
break; break;
default: default:
sprintf(g->Message, "invalid catfunc %s", fncn); snprintf(g->Message, sizeof(g->Message), "invalid catfunc %s", fncn);
break; break;
} // endswitch info } // endswitch info
@@ -6166,9 +6167,9 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
// Not a catalog table // Not a catalog table
if (!qrp->Nblin) { if (!qrp->Nblin) {
if (tab) if (tab)
sprintf(g->Message, "Cannot get columns from %s", tab); snprintf(g->Message, sizeof(g->Message), "Cannot get columns from %s", tab);
else else
strcpy(g->Message, "Fail to retrieve columns"); strncpy(g->Message, "Fail to retrieve columns", sizeof(g->Message));
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
goto err; goto err;
@@ -6255,7 +6256,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#if defined(ODBC_SUPPORT) || defined(JAVA_SUPPORT) #if defined(ODBC_SUPPORT) || defined(JAVA_SUPPORT)
if ((ttp == TAB_ODBC || ttp == TAB_JDBC) && crp->Kdata) { if ((ttp == TAB_ODBC || ttp == TAB_JDBC) && crp->Kdata) {
if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) { if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) {
sprintf(g->Message, snprintf(g->Message, sizeof(g->Message),
"Several %s tables found, specify DBNAME", tab); "Several %s tables found, specify DBNAME", tab);
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
goto err; goto err;
@@ -6277,12 +6278,12 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) { if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) {
if (GetTypeConv() == TPC_SKIP) { if (GetTypeConv() == TPC_SKIP) {
// Skip this column // Skip this column
sprintf(g->Message, "Column %s skipped (unsupported type %d)", snprintf(g->Message, sizeof(g->Message), "Column %s skipped (unsupported type %d)",
cnm, typ); cnm, typ);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
continue; continue;
} else { } else {
sprintf(g->Message, "Unsupported SQL type %d", typ); snprintf(g->Message, sizeof(g->Message), "Unsupported SQL type %d", typ);
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
goto err; goto err;
} // endif type_conv } // endif type_conv
@@ -6293,7 +6294,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
switch (typ) { switch (typ) {
case TYPE_STRING: case TYPE_STRING:
if (w) { if (w) {
sprintf(g->Message, "Column %s is wide characters", cnm); snprintf(g->Message, sizeof(g->Message), "Column %s is wide characters", cnm);
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
} // endif w } // endif w
@@ -6319,12 +6320,12 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
if (!(plgtyp= TranslateJDBCType(typ, tn, dec, prec, v))) { if (!(plgtyp= TranslateJDBCType(typ, tn, dec, prec, v))) {
if (GetTypeConv() == TPC_SKIP) { if (GetTypeConv() == TPC_SKIP) {
// Skip this column // Skip this column
sprintf(g->Message, "Column %s skipped (unsupported type %d)", snprintf(g->Message, sizeof(g->Message), "Column %s skipped (unsupported type %d)",
cnm, typ); cnm, typ);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
continue; continue;
} else { } else {
sprintf(g->Message, "Unsupported SQL type %d", typ); snprintf(g->Message, sizeof(g->Message), "Unsupported SQL type %d", typ);
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
goto err; goto err;
} // endif type_conv } // endif type_conv
@@ -6482,13 +6483,13 @@ int ha_connect::create(const char *name, TABLE *table_arg,
#endif // REST_SUPPORT #endif // REST_SUPPORT
(options->tabname) ? "PROXY" : "DOS"; (options->tabname) ? "PROXY" : "DOS";
type= GetTypeID(options->type); type= GetTypeID(options->type);
sprintf(g->Message, "No table_type. Will be set to %s", options->type); snprintf(g->Message, sizeof(g->Message), "No table_type. Will be set to %s", options->type);
if (sqlcom == SQLCOM_CREATE_TABLE) if (sqlcom == SQLCOM_CREATE_TABLE)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
} else if (type == TAB_NIY) { } else if (type == TAB_NIY) {
sprintf(g->Message, "Unsupported table type %s", options->type); snprintf(g->Message, sizeof(g->Message), "Unsupported table type %s", options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} // endif ttp } // endif ttp
@@ -6538,7 +6539,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (!stricmp(options->tabname, create_info->alias.str) && if (!stricmp(options->tabname, create_info->alias.str) &&
(!options->dbname || (!options->dbname ||
!stricmp(options->dbname, table_arg->s->db.str))) { !stricmp(options->dbname, table_arg->s->db.str))) {
sprintf(g->Message, "A %s table cannot refer to itself", snprintf(g->Message, sizeof(g->Message), "A %s table cannot refer to itself",
options->type); options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
@@ -6647,7 +6648,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
int pretty= atoi(GetListOption(g, "Pretty", options->oplist, "2")); int pretty= atoi(GetListOption(g, "Pretty", options->oplist, "2"));
if (!options->lrecl && pretty != 2) { if (!options->lrecl && pretty != 2) {
sprintf(g->Message, "LRECL must be specified for pretty=%d", pretty); snprintf(g->Message, sizeof(g->Message), "LRECL must be specified for pretty=%d", pretty);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
DBUG_RETURN(rc); DBUG_RETURN(rc);
@@ -6659,7 +6660,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
const char *sep= options->separator; const char *sep= options->separator;
if (sep && strlen(sep) > 1) { if (sep && strlen(sep) > 1) {
sprintf(g->Message, "Invalid separator %s", sep); snprintf(g->Message, sizeof(g->Message), "Invalid separator %s", sep);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
DBUG_RETURN(rc); DBUG_RETURN(rc);
@@ -6682,7 +6683,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} // endif flags } // endif flags
if (fp->flags & (BLOB_FLAG | ENUM_FLAG | SET_FLAG)) { if (fp->flags & (BLOB_FLAG | ENUM_FLAG | SET_FLAG)) {
sprintf(g->Message, "Unsupported type for column %s", snprintf(g->Message, sizeof(g->Message), "Unsupported type for column %s",
fp->field_name.str); fp->field_name.str);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
@@ -6719,7 +6720,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
#if 0 #if 0
if (!fp->field_length) { if (!fp->field_length) {
sprintf(g->Message, "Unsupported 0 length for column %s", snprintf(g->Message, sizeof(g->Message), "Unsupported 0 length for column %s",
fp->field_name.str); fp->field_name.str);
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
my_printf_error(ER_UNKNOWN_ERROR, my_printf_error(ER_UNKNOWN_ERROR,
@@ -6740,7 +6741,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
case MYSQL_TYPE_GEOMETRY: case MYSQL_TYPE_GEOMETRY:
default: default:
// fprintf(stderr, "Unsupported type column %s\n", fp->field_name.str); // fprintf(stderr, "Unsupported type column %s\n", fp->field_name.str);
sprintf(g->Message, "Unsupported type for column %s", snprintf(g->Message, sizeof(g->Message), "Unsupported type for column %s",
fp->field_name.str); fp->field_name.str);
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
my_printf_error(ER_UNKNOWN_ERROR, "Unsupported type for column %s", my_printf_error(ER_UNKNOWN_ERROR, "Unsupported type for column %s",
@@ -6760,10 +6761,10 @@ int ha_connect::create(const char *name, TABLE *table_arg,
bool b= false; bool b= false;
if ((b= fp->field_name.length > 10)) if ((b= fp->field_name.length > 10))
sprintf(g->Message, "DBF: Column name '%s' is too long (max=10)", snprintf(g->Message, sizeof(g->Message), "DBF: Column name '%s' is too long (max=10)",
fp->field_name.str); fp->field_name.str);
else if ((b= fp->field_length > 255)) else if ((b= fp->field_length > 255))
sprintf(g->Message, "DBF: Column length too big for '%s' (max=255)", snprintf(g->Message, sizeof(g->Message), "DBF: Column length too big for '%s' (max=255)",
fp->field_name.str); fp->field_name.str);
if (b) { if (b) {
@@ -6826,7 +6827,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
*p= 0; *p= 0;
} else { } else {
strcat(strcat(strcpy(buf, GetTableName()), "."), lwt); strcat(strcat(strcpy(buf, GetTableName()), "."), lwt);
sprintf(g->Message, "No file name. Table will use %s", buf); snprintf(g->Message, sizeof(g->Message), "No file name. Table will use %s", buf);
if (sqlcom == SQLCOM_CREATE_TABLE) if (sqlcom == SQLCOM_CREATE_TABLE)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
@@ -6838,9 +6839,9 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if ((h= ::open(fn, O_CREAT | O_EXCL, 0666)) == -1) { if ((h= ::open(fn, O_CREAT | O_EXCL, 0666)) == -1) {
if (errno == EEXIST) if (errno == EEXIST)
sprintf(g->Message, "Default file %s already exists", fn); snprintf(g->Message, sizeof(g->Message), "Default file %s already exists", fn);
else else
sprintf(g->Message, "Error %d creating file %s", errno, fn); snprintf(g->Message, sizeof(g->Message), "Error %d creating file %s", errno, fn);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
} else } else
@@ -6903,7 +6904,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (g->Alchecked == 0 && if (g->Alchecked == 0 &&
(!IsFileType(type) || FileExists(options->filename, false))) { (!IsFileType(type) || FileExists(options->filename, false))) {
if (part_info) { if (part_info) {
sprintf(g->Message, "Data repartition in %s is unchecked", partname); snprintf(g->Message, sizeof(g->Message), "Data repartition in %s is unchecked", partname);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
} else if (sqlcom == SQLCOM_ALTER_TABLE) { } else if (sqlcom == SQLCOM_ALTER_TABLE) {
// This is an ALTER to CONNECT from another engine. // This is an ALTER to CONNECT from another engine.
@@ -6955,7 +6956,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} // endif Check } // endif Check
} else if (!GetIndexType(type)) { } else if (!GetIndexType(type)) {
sprintf(g->Message, "Table type %s is not indexable", options->type); snprintf(g->Message, sizeof(g->Message), "Table type %s is not indexable", options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_UNSUPPORTED; rc= HA_ERR_UNSUPPORTED;
} // endif index type } // endif index type
@@ -6988,8 +6989,8 @@ bool ha_connect::FileExists(const char *fn, bool bf)
if (table) { if (table) {
const char *s; const char *s;
char tfn[_MAX_PATH], filename[_MAX_PATH], path[_MAX_PATH]; char tfn[_MAX_PATH], filename[_MAX_PATH], path[_MAX_PATH];
bool b= false; bool b= false;
int n; int n;
struct stat info; struct stat info;
@@ -6999,7 +7000,7 @@ bool ha_connect::FileExists(const char *fn, bool bf)
s= "/"; s= "/";
#endif // !_WIN32 #endif // !_WIN32
if (IsPartitioned()) { if (IsPartitioned()) {
sprintf(tfn, fn, GetPartName()); snprintf(tfn, sizeof(tfn), fn, GetPartName());
// This is to avoid an initialization error raised by the // This is to avoid an initialization error raised by the
// test on check_table_flags made in ha_partition::open // test on check_table_flags made in ha_partition::open
@@ -7016,7 +7017,7 @@ bool ha_connect::FileExists(const char *fn, bool bf)
if (errno != ENOENT) { if (errno != ENOENT) {
char buf[_MAX_PATH + 20]; char buf[_MAX_PATH + 20];
sprintf(buf, "Error %d for file %s", errno, filename); snprintf(buf, sizeof(buf), "Error %d for file %s", errno, filename);
push_warning(table->in_use, Sql_condition::WARN_LEVEL_WARN, 0, buf); push_warning(table->in_use, Sql_condition::WARN_LEVEL_WARN, 0, buf);
return true; return true;
} else } else
@@ -7243,7 +7244,7 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
} // endif Check } // endif Check
} else if (!GetIndexType(type)) { } else if (!GetIndexType(type)) {
sprintf(g->Message, "Table type %s is not indexable", oldopt->type); snprintf(g->Message, sizeof(g->Message), "Table type %s is not indexable", oldopt->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
DBUG_RETURN(HA_ALTER_ERROR); DBUG_RETURN(HA_ALTER_ERROR);
} // endif index type } // endif index type

View File

@@ -272,25 +272,25 @@ bool JAVAConn::GetJVM(PGLOBAL g)
char buf[256]; char buf[256];
DWORD rc = GetLastError(); DWORD rc = GetLastError();
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, soname); snprintf(g->Message, sizeof(g->Message), MSG(DLL_LOAD_ERROR), rc, soname);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
strcat(strcat(g->Message, ": "), buf); strcat(strcat(g->Message, ": "), buf);
} else if (!(CreateJavaVM = (CRTJVM)GetProcAddress((HINSTANCE)LibJvm, } else if (!(CreateJavaVM = (CRTJVM)GetProcAddress((HINSTANCE)LibJvm,
"JNI_CreateJavaVM"))) { "JNI_CreateJavaVM"))) {
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), "JNI_CreateJavaVM"); snprintf(g->Message, sizeof(g->Message), MSG(PROCADD_ERROR), GetLastError(), "JNI_CreateJavaVM");
FreeLibrary((HMODULE)LibJvm); FreeLibrary((HMODULE)LibJvm);
LibJvm = NULL; LibJvm = NULL;
} else if (!(GetCreatedJavaVMs = (GETJVM)GetProcAddress((HINSTANCE)LibJvm, } else if (!(GetCreatedJavaVMs = (GETJVM)GetProcAddress((HINSTANCE)LibJvm,
"JNI_GetCreatedJavaVMs"))) { "JNI_GetCreatedJavaVMs"))) {
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), "JNI_GetCreatedJavaVMs"); snprintf(g->Message, sizeof(g->Message), MSG(PROCADD_ERROR), GetLastError(), "JNI_GetCreatedJavaVMs");
FreeLibrary((HMODULE)LibJvm); FreeLibrary((HMODULE)LibJvm);
LibJvm = NULL; LibJvm = NULL;
#if defined(_DEBUG) #if defined(_DEBUG)
} else if (!(GetDefaultJavaVMInitArgs = (GETDEF)GetProcAddress((HINSTANCE)LibJvm, } else if (!(GetDefaultJavaVMInitArgs = (GETDEF)GetProcAddress((HINSTANCE)LibJvm,
"JNI_GetDefaultJavaVMInitArgs"))) { "JNI_GetDefaultJavaVMInitArgs"))) {
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), snprintf(g->Message, sizeof(g->Message), MSG(PROCADD_ERROR), GetLastError(),
"JNI_GetDefaultJavaVMInitArgs"); "JNI_GetDefaultJavaVMInitArgs");
FreeLibrary((HMODULE)LibJvm); FreeLibrary((HMODULE)LibJvm);
LibJvm = NULL; LibJvm = NULL;
@@ -317,22 +317,22 @@ bool JAVAConn::GetJVM(PGLOBAL g)
// Load the desired shared library // Load the desired shared library
if (!LibJvm) { if (!LibJvm) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); snprintf(g->Message, sizeof(g->Message), MSG(SHARED_LIB_ERR), soname, SVP(error));
} else if (!(CreateJavaVM = (CRTJVM)dlsym(LibJvm, "JNI_CreateJavaVM"))) { } else if (!(CreateJavaVM = (CRTJVM)dlsym(LibJvm, "JNI_CreateJavaVM"))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), "JNI_CreateJavaVM", SVP(error)); snprintf(g->Message, sizeof(g->Message), MSG(GET_FUNC_ERR), "JNI_CreateJavaVM", SVP(error));
dlclose(LibJvm); dlclose(LibJvm);
LibJvm = NULL; LibJvm = NULL;
} else if (!(GetCreatedJavaVMs = (GETJVM)dlsym(LibJvm, "JNI_GetCreatedJavaVMs"))) { } else if (!(GetCreatedJavaVMs = (GETJVM)dlsym(LibJvm, "JNI_GetCreatedJavaVMs"))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), "JNI_GetCreatedJavaVMs", SVP(error)); snprintf(g->Message, sizeof(g->Message), MSG(GET_FUNC_ERR), "JNI_GetCreatedJavaVMs", SVP(error));
dlclose(LibJvm); dlclose(LibJvm);
LibJvm = NULL; LibJvm = NULL;
#if defined(_DEBUG) #if defined(_DEBUG)
} else if (!(GetDefaultJavaVMInitArgs = (GETDEF)dlsym(LibJvm, } else if (!(GetDefaultJavaVMInitArgs = (GETDEF)dlsym(LibJvm,
"JNI_GetDefaultJavaVMInitArgs"))) { "JNI_GetDefaultJavaVMInitArgs"))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), "JNI_GetDefaultJavaVMInitArgs", SVP(error)); snprintf(g->Message, sizeof(g->Message), MSG(GET_FUNC_ERR), "JNI_GetDefaultJavaVMInitArgs", SVP(error));
dlclose(LibJvm); dlclose(LibJvm);
LibJvm = NULL; LibJvm = NULL;
#endif // _DEBUG #endif // _DEBUG
@@ -473,7 +473,7 @@ bool JAVAConn::Open(PGLOBAL g)
strcpy(g->Message, "Invalid arguments"); strcpy(g->Message, "Invalid arguments");
break; break;
default: default:
sprintf(g->Message, "Unknown return code %d", (int)rc); snprintf(g->Message, sizeof(g->Message), "Unknown return code %d", (int)rc);
break; break;
} // endswitch rc } // endswitch rc
@@ -492,7 +492,7 @@ bool JAVAConn::Open(PGLOBAL g)
jdi = env->FindClass(m_Wrap); jdi = env->FindClass(m_Wrap);
if (jdi == nullptr) { if (jdi == nullptr) {
sprintf(g->Message, "ERROR: class %s not found!", m_Wrap); snprintf(g->Message, sizeof(g->Message), "ERROR: class %s not found!", m_Wrap);
return true; return true;
} // endif jdi } // endif jdi
@@ -538,13 +538,13 @@ bool JAVAConn::Open(PGLOBAL g)
jmethodID ctor = env->GetMethodID(jdi, "<init>", "(Z)V"); jmethodID ctor = env->GetMethodID(jdi, "<init>", "(Z)V");
if (ctor == nullptr) { if (ctor == nullptr) {
sprintf(g->Message, "ERROR: %s constructor not found!", m_Wrap); snprintf(g->Message, sizeof(g->Message), "ERROR: %s constructor not found!", m_Wrap);
return true; return true;
} else } else
job = env->NewObject(jdi, ctor, jt); job = env->NewObject(jdi, ctor, jt);
if (job == nullptr) { if (job == nullptr) {
sprintf(g->Message, "%s class object not constructed!", m_Wrap); snprintf(g->Message, sizeof(g->Message), "%s class object not constructed!", m_Wrap);
return true; return true;
} // endif job } // endif job

View File

@@ -689,17 +689,17 @@ bool JDBConn::SetUUID(PGLOBAL g, PTDBJDBC tjp)
ncol = env->CallIntMethod(job, catid, parms); ncol = env->CallIntMethod(job, catid, parms);
if (Check(ncol)) { if (Check(ncol)) {
sprintf(g->Message, "%s: %s", fnc, Msg); snprintf(g->Message, sizeof(g->Message), "%s: %s", fnc, Msg);
goto err; goto err;
} // endif Check } // endif Check
rc = env->CallBooleanMethod(job, readid); rc = env->CallBooleanMethod(job, readid);
if (Check(rc)) { if (Check(rc)) {
sprintf(g->Message, "ReadNext: %s", Msg); snprintf(g->Message, sizeof(g->Message), "ReadNext: %s", Msg);
goto err; goto err;
} else if (rc == 0) { } else if (rc == 0) {
sprintf(g->Message, "table %s does not exist", tjp->TableName); snprintf(g->Message, sizeof(g->Message), "table %s does not exist", tjp->TableName);
goto err; goto err;
} // endif rc } // endif rc
@@ -707,7 +707,7 @@ bool JDBConn::SetUUID(PGLOBAL g, PTDBJDBC tjp)
ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr); ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr);
//if (Check((ctyp == 666) ? -1 : 1)) { //if (Check((ctyp == 666) ? -1 : 1)) {
// sprintf(g->Message, "Getting ctyp: %s", Msg); // snprintf(g->Message, sizeof(g->Message), "Getting ctyp: %s", Msg);
// goto err; // goto err;
//} // endif ctyp //} // endif ctyp
@@ -815,7 +815,7 @@ bool JDBConn::Connect(PJPARM sop)
env->DeleteLocalRef(parms); // Not used anymore env->DeleteLocalRef(parms); // Not used anymore
if (err) { if (err) {
sprintf(g->Message, "Connecting: %s rc=%d", Msg, (int)rc); snprintf(g->Message, sizeof(g->Message), "Connecting: %s rc=%d", Msg, (int)rc);
return true; return true;
} // endif Msg } // endif Msg
@@ -863,14 +863,14 @@ int JDBConn::ExecuteCommand(PCSZ sql)
env->DeleteLocalRef(qry); env->DeleteLocalRef(qry);
if (Check(n)) { if (Check(n)) {
sprintf(g->Message, "Execute: %s", Msg); snprintf(g->Message, sizeof(g->Message), "Execute: %s", Msg);
return RC_FX; return RC_FX;
} // endif n } // endif n
m_Ncol = env->CallIntMethod(job, grs); m_Ncol = env->CallIntMethod(job, grs);
if (Check(m_Ncol)) { if (Check(m_Ncol)) {
sprintf(g->Message, "GetResult: %s", Msg); snprintf(g->Message, sizeof(g->Message), "GetResult: %s", Msg);
rc = RC_FX; rc = RC_FX;
} else if (m_Ncol) { } else if (m_Ncol) {
strcpy(g->Message, "Result set column number"); strcpy(g->Message, "Result set column number");
@@ -919,7 +919,7 @@ int JDBConn::Fetch(int pos)
m_Rows += (int)rc; m_Rows += (int)rc;
} else } else
sprintf(g->Message, "Fetch: %s", Msg); snprintf(g->Message, sizeof(g->Message), "Fetch: %s", Msg);
} // endif pos } // endif pos
@@ -961,7 +961,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
if (rank == 0) if (rank == 0)
if (!name || (jn = env->NewStringUTF(name)) == nullptr) { if (!name || (jn = env->NewStringUTF(name)) == nullptr) {
sprintf(g->Message, "Fail to allocate jstring %s", SVP(name)); snprintf(g->Message, sizeof(g->Message), "Fail to allocate jstring %s", SVP(name));
throw (int)TYPE_AM_JDBC; throw (int)TYPE_AM_JDBC;
} // endif name } // endif name
@@ -969,7 +969,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
ctyp = env->CallIntMethod(job, typid, rank, jn); ctyp = env->CallIntMethod(job, typid, rank, jn);
if (Check((ctyp == 666) ? -1 : 1)) { if (Check((ctyp == 666) ? -1 : 1)) {
sprintf(g->Message, "Getting ctyp: %s", Msg); snprintf(g->Message, sizeof(g->Message), "Getting ctyp: %s", Msg);
throw (int)TYPE_AM_JDBC; throw (int)TYPE_AM_JDBC;
} // endif Check } // endif Check
@@ -978,7 +978,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
jb = env->CallObjectMethod(job, objfldid, (jint)rank, jn); jb = env->CallObjectMethod(job, objfldid, (jint)rank, jn);
if (Check(0)) { if (Check(0)) {
sprintf(g->Message, "Getting jp: %s", Msg); snprintf(g->Message, sizeof(g->Message), "Getting jp: %s", Msg);
throw (int)TYPE_AM_JDBC; throw (int)TYPE_AM_JDBC;
} // endif Check } // endif Check
@@ -1098,7 +1098,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
if (rank == 0) if (rank == 0)
env->DeleteLocalRef(jn); env->DeleteLocalRef(jn);
sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp); snprintf(g->Message, sizeof(g->Message), "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp);
throw (int)TYPE_AM_JDBC; throw (int)TYPE_AM_JDBC;
} // endif Check } // endif Check
@@ -1120,7 +1120,7 @@ bool JDBConn::PrepareSQL(PCSZ sql)
jstring qry = env->NewStringUTF(sql); jstring qry = env->NewStringUTF(sql);
if (Check(env->CallBooleanMethod(job, prepid, qry))) if (Check(env->CallBooleanMethod(job, prepid, qry)))
sprintf(g->Message, "CreatePrepStmt: %s", Msg); snprintf(g->Message, sizeof(g->Message), "CreatePrepStmt: %s", Msg);
else else
b = false; b = false;
@@ -1150,7 +1150,7 @@ int JDBConn::ExecuteQuery(PCSZ sql)
m_Aff = 0; // Affected rows m_Aff = 0; // Affected rows
rc = RC_OK; rc = RC_OK;
} else } else
sprintf(g->Message, "ExecuteQuery: %s", Msg); snprintf(g->Message, sizeof(g->Message), "ExecuteQuery: %s", Msg);
env->DeleteLocalRef(qry); env->DeleteLocalRef(qry);
} // endif xqid } // endif xqid
@@ -1178,7 +1178,7 @@ int JDBConn::ExecuteUpdate(PCSZ sql)
m_Aff = (int)n; // Affected rows m_Aff = (int)n; // Affected rows
rc = RC_OK; rc = RC_OK;
} else } else
sprintf(g->Message, "ExecuteUpdate: %s n=%d", Msg, n); snprintf(g->Message, sizeof(g->Message), "ExecuteUpdate: %s n=%d", Msg, n);
env->DeleteLocalRef(qry); env->DeleteLocalRef(qry);
} // endif xuid } // endif xuid
@@ -1228,7 +1228,7 @@ int JDBConn::ExecuteSQL(void)
if (n == -3) if (n == -3)
strcpy(g->Message, "SQL statement is not prepared"); strcpy(g->Message, "SQL statement is not prepared");
else if (Check(n)) else if (Check(n))
sprintf(g->Message, "ExecutePrep: %s", Msg); snprintf(g->Message, sizeof(g->Message), "ExecutePrep: %s", Msg);
else { else {
m_Aff = (int)n; m_Aff = (int)n;
rc = RC_OK; rc = RC_OK;
@@ -1327,12 +1327,12 @@ bool JDBConn::SetParam(JDBCCOL *colp)
env->CallVoidMethod(job, setid, i, datobj); env->CallVoidMethod(job, setid, i, datobj);
break; break;
default: default:
sprintf(g->Message, "Parm type %d not supported", val->GetType()); snprintf(g->Message, sizeof(g->Message), "Parm type %d not supported", val->GetType());
return true; return true;
} // endswitch Type } // endswitch Type
if (Check(jrc)) { if (Check(jrc)) {
sprintf(g->Message, "SetParam: col=%s msg=%s", colp->GetName(), Msg); snprintf(g->Message, sizeof(g->Message), "SetParam: col=%s msg=%s", colp->GetName(), Msg);
rc = true; rc = true;
} // endif msg } // endif msg
@@ -1455,7 +1455,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
for (i = 0; i < m_Ncol; i++) { for (i = 0; i < m_Ncol; i++) {
if (!(label = (jstring)env->CallObjectMethod(job, colid, i + 1, val))) { if (!(label = (jstring)env->CallObjectMethod(job, colid, i + 1, val))) {
if (Check()) if (Check())
sprintf(g->Message, "ColumnDesc: %s", Msg); snprintf(g->Message, sizeof(g->Message), "ColumnDesc: %s", Msg);
else else
strcpy(g->Message, "No result metadata"); strcpy(g->Message, "No result metadata");
@@ -1538,7 +1538,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
break; break;
#endif // 0 #endif // 0
default: default:
sprintf(g->Message, "Invalid SQL function id"); snprintf(g->Message, sizeof(g->Message), "Invalid SQL function id");
return -1; return -1;
} // endswitch infotype } // endswitch infotype
@@ -1549,7 +1549,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
ncol = env->CallIntMethod(job, catid, parms); ncol = env->CallIntMethod(job, catid, parms);
if (Check(ncol)) { if (Check(ncol)) {
sprintf(g->Message, "%s: %s", fnc, Msg); snprintf(g->Message, sizeof(g->Message), "%s: %s", fnc, Msg);
env->DeleteLocalRef(parms); env->DeleteLocalRef(parms);
return -1; return -1;
} // endif Check } // endif Check
@@ -1574,7 +1574,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
// Prepare retrieving column values // Prepare retrieving column values
for (n = 0, crp = qrp->Colresp; crp; crp = crp->Next) { for (n = 0, crp = qrp->Colresp; crp; crp = crp->Next) {
if (!(tp = GetJDBCType(crp->Type))) { if (!(tp = GetJDBCType(crp->Type))) {
sprintf(g->Message, MSG(INV_COLUMN_TYPE), crp->Type, crp->Name); snprintf(g->Message, sizeof(g->Message), MSG(INV_COLUMN_TYPE), crp->Type, crp->Name);
return -1; return -1;
} // endif tp } // endif tp
@@ -1599,7 +1599,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
// Now fetch the result // Now fetch the result
for (i = 0; i < qrp->Maxres; i++) { for (i = 0; i < qrp->Maxres; i++) {
if (Check(rc = Fetch(0))) { if (Check(rc = Fetch(0))) {
sprintf(g->Message, "Fetch: %s", Msg); snprintf(g->Message, sizeof(g->Message), "Fetch: %s", Msg);
return -1; return -1;
} if (rc == 0) { } if (rc == 0) {
if (trace(1)) if (trace(1))
@@ -1668,7 +1668,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows, if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows,
crp->Clen, 0, FALSE, TRUE, uns))) { crp->Clen, 0, FALSE, TRUE, uns))) {
sprintf(g->Message, MSG(INV_RESULT_TYPE), snprintf(g->Message, sizeof(g->Message), MSG(INV_RESULT_TYPE),
GetFormatType(crp->Type)); GetFormatType(crp->Type));
return NULL; return NULL;
} // endif Kdata } // endif Kdata

View File

@@ -193,7 +193,7 @@ bool JMgoConn::Connect(PJPARM sop)
env->DeleteLocalRef(parms); // Not used anymore env->DeleteLocalRef(parms); // Not used anymore
if (err) { if (err) {
sprintf(g->Message, "Connecting: %s rc=%d", Msg, (int)rc); snprintf(g->Message, sizeof(g->Message), "Connecting: %s rc=%d", Msg, (int)rc);
return true; return true;
} // endif Msg } // endif Msg
@@ -208,7 +208,7 @@ bool JMgoConn::Connect(PJPARM sop)
env->DeleteLocalRef(cln); env->DeleteLocalRef(cln);
if (Check(brc ? -1 : 0)) { if (Check(brc ? -1 : 0)) {
sprintf(g->Message, "GetCollection: %s", Msg); snprintf(g->Message, sizeof(g->Message), "GetCollection: %s", Msg);
return true; return true;
} // endif Msg } // endif Msg
@@ -429,7 +429,7 @@ bool JMgoConn::FindCollection(PCSZ query, PCSZ proj)
if (!Check(brc ? -1 : 0)) { if (!Check(brc ? -1 : 0)) {
rc = false; rc = false;
} else } else
sprintf(g->Message, "FindColl: %s", Msg); snprintf(g->Message, sizeof(g->Message), "FindColl: %s", Msg);
if (query) if (query)
env->DeleteLocalRef(qry); env->DeleteLocalRef(qry);
@@ -461,7 +461,7 @@ bool JMgoConn::AggregateCollection(PCSZ pipeline)
if (!Check(brc ? -1 : 0)) { if (!Check(brc ? -1 : 0)) {
rc = false; rc = false;
} else } else
sprintf(g->Message, "AggregateColl: %s", Msg); snprintf(g->Message, sizeof(g->Message), "AggregateColl: %s", Msg);
env->DeleteLocalRef(pip); env->DeleteLocalRef(pip);
} // endif acollid } // endif acollid
@@ -506,7 +506,7 @@ int JMgoConn::Fetch(int pos)
rc = MY_MIN(rc, 1); rc = MY_MIN(rc, 1);
m_Rows += rc; m_Rows += rc;
} else } else
sprintf(g->Message, "Fetch: %s", Msg); snprintf(g->Message, sizeof(g->Message), "Fetch: %s", Msg);
//} // endif pos //} // endif pos
@@ -633,13 +633,13 @@ jobject JMgoConn::MakeObject(PGLOBAL g, PCOL colp, bool&error )
val = env->NewObject(cls, cns, valp->GetFloatValue()); val = env->NewObject(cls, cns, valp->GetFloatValue());
break; break;
default: default:
sprintf(g->Message, "Cannot make object from %d type", valp->GetType()); snprintf(g->Message, sizeof(g->Message), "Cannot make object from %d type", valp->GetType());
error = true; error = true;
break; break;
} // endswitch Type } // endswitch Type
} catch (...) { } catch (...) {
sprintf(g->Message, "Cannot make object from %s value", colp->GetName()); snprintf(g->Message, sizeof(g->Message), "Cannot make object from %s value", colp->GetName());
error = true; error = true;
} // end try/catch } // end try/catch
@@ -723,9 +723,9 @@ jobject JMgoConn::MakeDoc(PGLOBAL g, PJNCOL jcp)
} else if (env->CallBooleanMethod(job, araddid, parent, kp->N, val, j)) { } else if (env->CallBooleanMethod(job, araddid, parent, kp->N, val, j)) {
if (Check(-1)) if (Check(-1))
sprintf(g->Message, "ArrayAdd: %s", Msg); snprintf(g->Message, sizeof(g->Message), "ArrayAdd: %s", Msg);
else else
sprintf(g->Message, "ArrayAdd: unknown error"); snprintf(g->Message, sizeof(g->Message), "ArrayAdd: unknown error");
return NULL; return NULL;
} // endif ArrayAdd } // endif ArrayAdd
@@ -766,9 +766,9 @@ int JMgoConn::DocWrite(PGLOBAL g, PCSZ line)
if (env->CallBooleanMethod(job, insertid, doc)) { if (env->CallBooleanMethod(job, insertid, doc)) {
if (Check(-1)) if (Check(-1))
sprintf(g->Message, "CollInsert: %s", Msg); snprintf(g->Message, sizeof(g->Message), "CollInsert: %s", Msg);
else else
sprintf(g->Message, "CollInsert: unknown error"); snprintf(g->Message, sizeof(g->Message), "CollInsert: unknown error");
rc = RC_FX; rc = RC_FX;
} // endif Insert } // endif Insert
@@ -823,7 +823,7 @@ int JMgoConn::DocUpdate(PGLOBAL g, PTDB tdbp)
htrc("DocUpdate: ar = %ld\n", ar); htrc("DocUpdate: ar = %ld\n", ar);
if (Check((int)ar)) { if (Check((int)ar)) {
sprintf(g->Message, "CollUpdate: %s", Msg); snprintf(g->Message, sizeof(g->Message), "CollUpdate: %s", Msg);
rc = RC_FX; rc = RC_FX;
} // endif ar } // endif ar
@@ -842,7 +842,7 @@ int JMgoConn::DocDelete(PGLOBAL g, bool all)
htrc("DocDelete: ar = %ld\n", ar); htrc("DocDelete: ar = %ld\n", ar);
if (Check((int)ar)) { if (Check((int)ar)) {
sprintf(g->Message, "CollDelete: %s", Msg); snprintf(g->Message, sizeof(g->Message), "CollDelete: %s", Msg);
rc = RC_FX; rc = RC_FX;
} // endif ar } // endif ar
@@ -867,7 +867,7 @@ PSZ JMgoConn::GetColumnValue(PSZ path)
jstring fn, jn = nullptr; jstring fn, jn = nullptr;
if (!path || (jn = env->NewStringUTF(path)) == nullptr) { if (!path || (jn = env->NewStringUTF(path)) == nullptr) {
sprintf(g->Message, "Fail to allocate jstring %s", SVP(path)); snprintf(g->Message, sizeof(g->Message), "Fail to allocate jstring %s", SVP(path));
throw (int)TYPE_AM_MGO; throw (int)TYPE_AM_MGO;
} // endif name } // endif name

View File

@@ -208,7 +208,7 @@ PJSON ParseJson(PGLOBAL g, char* s, size_t len, int* ptyp, bool* comma)
break; break;
} // endif pretty } // endif pretty
sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty); snprintf(g->Message, sizeof(g->Message), "Unexpected ',' (pretty=%d)", pretty);
throw 3; throw 3;
case '(': case '(':
b = true; b = true;
@@ -229,7 +229,7 @@ PJSON ParseJson(PGLOBAL g, char* s, size_t len, int* ptyp, bool* comma)
}; // endswitch s[i] }; // endswitch s[i]
if (!jsp) if (!jsp)
sprintf(g->Message, "Invalid Json string '%.*s'", MY_MIN((int)len, 50), s); snprintf(g->Message, sizeof(g->Message), "Invalid Json string '%.*s'", MY_MIN((int)len, 50), s);
else if (ptyp && pretty == 3) { else if (ptyp && pretty == 3) {
*ptyp = 3; // Not recognized pretty *ptyp = 3; // Not recognized pretty
@@ -278,7 +278,7 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char* fn, int pretty) {
b = pretty == 1; b = pretty == 1;
} else { } else {
if (!(fs = fopen(fn, "wb"))) { if (!(fs = fopen(fn, "wb"))) {
sprintf(g->Message, MSG(OPEN_MODE_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR),
"w", (int)errno, fn); "w", (int)errno, fn);
strcat(strcat(g->Message, ": "), strerror(errno)); strcat(strcat(g->Message, ": "), strerror(errno));
throw 2; throw 2;
@@ -571,7 +571,7 @@ PJAR JDOC::ParseArray(PGLOBAL g, int& i)
switch (s[i]) { switch (s[i]) {
case ',': case ',':
if (level < 2) { if (level < 2) {
sprintf(g->Message, "Unexpected ',' near %.*s",ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected ',' near %.*s",ARGS);
throw 1; throw 1;
} else } else
level = 1; level = 1;
@@ -579,7 +579,7 @@ PJAR JDOC::ParseArray(PGLOBAL g, int& i)
break; break;
case ']': case ']':
if (level == 1) { if (level == 1) {
sprintf(g->Message, "Unexpected ',]' near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected ',]' near %.*s", ARGS);
throw 1; throw 1;
} // endif level } // endif level
@@ -594,7 +594,7 @@ PJAR JDOC::ParseArray(PGLOBAL g, int& i)
break; break;
default: default:
if (level == 2) { if (level == 2) {
sprintf(g->Message, "Unexpected value near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected value near %.*s", ARGS);
throw 1; throw 1;
} else } else
jarp->AddArrayValue(g, ParseValue(g, i)); jarp->AddArrayValue(g, ParseValue(g, i));
@@ -630,7 +630,7 @@ PJOB JDOC::ParseObject(PGLOBAL g, int& i)
jpp = jobp->AddPair(g, key); jpp = jobp->AddPair(g, key);
level = 1; level = 1;
} else { } else {
sprintf(g->Message, "misplaced string near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "misplaced string near %.*s", ARGS);
throw 2; throw 2;
} // endif level } // endif level
@@ -640,14 +640,14 @@ PJOB JDOC::ParseObject(PGLOBAL g, int& i)
jpp->Val = ParseValue(g, ++i); jpp->Val = ParseValue(g, ++i);
level = 2; level = 2;
} else { } else {
sprintf(g->Message, "Unexpected ':' near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected ':' near %.*s", ARGS);
throw 2; throw 2;
} // endif level } // endif level
break; break;
case ',': case ',':
if (level < 2) { if (level < 2) {
sprintf(g->Message, "Unexpected ',' near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected ',' near %.*s", ARGS);
throw 2; throw 2;
} else } else
level = 0; level = 0;
@@ -655,7 +655,7 @@ PJOB JDOC::ParseObject(PGLOBAL g, int& i)
break; break;
case '}': case '}':
if (level == 0 || level == 1) { if (level == 0 || level == 1) {
sprintf(g->Message, "Unexpected '}' near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected '}' near %.*s", ARGS);
throw 2; throw 2;
} // endif level } // endif level
@@ -667,7 +667,7 @@ PJOB JDOC::ParseObject(PGLOBAL g, int& i)
case '\t': case '\t':
break; break;
default: default:
sprintf(g->Message, "Unexpected character '%c' near %.*s", snprintf(g->Message, sizeof(g->Message), "Unexpected character '%c' near %.*s",
s[i], ARGS); s[i], ARGS);
throw 2; throw 2;
}; // endswitch s[i] }; // endswitch s[i]
@@ -750,7 +750,7 @@ PJVAL JDOC::ParseValue(PGLOBAL g, int& i)
return jvp; return jvp;
err: err:
sprintf(g->Message, "Unexpected character '%c' near %.*s", s[i], ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected character '%c' near %.*s", s[i], ARGS);
throw 3; throw 3;
} // end of ParseValue } // end of ParseValue
@@ -1764,7 +1764,7 @@ void JVALUE::SetValue(PGLOBAL g, PVAL valp)
DataType = TYPE_BINT; DataType = TYPE_BINT;
break; break;
default: default:
sprintf(g->Message, "Unsupported typ %d\n", valp->GetType()); snprintf(g->Message, sizeof(g->Message), "Unsupported typ %d\n", valp->GetType());
throw(777); throw(777);
} // endswitch Type } // endswitch Type

View File

@@ -160,7 +160,7 @@ my_bool JSNX::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
jnp->Rank = atoi(p) - B; jnp->Rank = atoi(p) - B;
jnp->Op = OP_EQ; jnp->Op = OP_EQ;
} else if (Wr) { } else if (Wr) {
sprintf(g->Message, "Invalid specification %s in a write path", p); snprintf(g->Message, sizeof(g->Message), "Invalid specification %s in a write path", p);
return true; return true;
} else if (n == 1) { } else if (n == 1) {
// Set the Op value; // Set the Op value;
@@ -175,7 +175,7 @@ my_bool JSNX::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
strcpy(g->Message, "Expand not supported by this function"); strcpy(g->Message, "Expand not supported by this function");
return true; return true;
default: default:
sprintf(g->Message, "Invalid function specification %c", *p); snprintf(g->Message, sizeof(g->Message), "Invalid function specification %c", *p);
return true; return true;
} // endswitch *p } // endswitch *p
@@ -267,7 +267,7 @@ my_bool JSNX::ParseJpath(PGLOBAL g)
} else if (*p == '*') { } else if (*p == '*') {
if (Wr) { if (Wr) {
sprintf(g->Message, "Invalid specification %c in a write path", *p); snprintf(g->Message, sizeof(g->Message), "Invalid specification %c in a write path", *p);
return true; return true;
} else // Return JSON } else // Return JSON
Nodes[i].Op = OP_XX; Nodes[i].Op = OP_XX;
@@ -477,7 +477,7 @@ PJVAL JSNX::GetRowValue(PGLOBAL g, PJSON row, int i, my_bool b)
val = (PJVAL)row; val = (PJVAL)row;
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->GetType()); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->GetType());
val = NULL; val = NULL;
} // endswitch Type } // endswitch Type
@@ -708,7 +708,7 @@ my_bool JSNX::CheckPath(PGLOBAL g)
val = (PJVAL)row; val = (PJVAL)row;
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->GetType()); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->GetType());
} // endswitch Type } // endswitch Type
if (i < Nod-1) if (i < Nod-1)
@@ -760,7 +760,7 @@ PJSON JSNX::GetRow(PGLOBAL g)
val = (PJVAL)row; val = (PJVAL)row;
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->GetType()); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->GetType());
val = NULL; val = NULL;
} // endswitch Type } // endswitch Type
@@ -1397,7 +1397,7 @@ static my_bool CheckPath(PGLOBAL g, UDF_ARGS *args, PJSON jsp, PJVAL& jvp, int n
return true; return true;
if (!(jvp = jsx->GetJson(g))) { if (!(jvp = jsx->GetJson(g))) {
sprintf(g->Message, "No sub-item at '%s'", path); snprintf(g->Message, sizeof(g->Message), "No sub-item at '%s'", path);
return true; return true;
} // endif jvp } // endif jvp
@@ -1854,7 +1854,7 @@ static PJSON ParseJsonFile(PGLOBAL g, char *fn, int *pretty, size_t& len)
DWORD rc = GetLastError(); DWORD rc = GetLastError();
if (!(*g->Message)) if (!(*g->Message))
sprintf(g->Message, MSG(OPEN_MODE_ERROR), "map", (int)rc, fn); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR), "map", (int)rc, fn);
return NULL; return NULL;
} // endif hFile } // endif hFile
@@ -1876,7 +1876,7 @@ static PJSON ParseJsonFile(PGLOBAL g, char *fn, int *pretty, size_t& len)
if (!memory) { if (!memory) {
CloseFileHandle(hFile); CloseFileHandle(hFile);
sprintf(g->Message, MSG(MAP_VIEW_ERROR), fn, GetLastError()); snprintf(g->Message, sizeof(g->Message), MSG(MAP_VIEW_ERROR), fn, GetLastError());
return NULL; return NULL;
} // endif Memory } // endif Memory
@@ -1906,19 +1906,19 @@ char *GetJsonFile(PGLOBAL g, char *fn)
#endif #endif
if (h == -1) { if (h == -1) {
sprintf(g->Message, "Error %d opening %s", errno, fn); snprintf(g->Message, sizeof(g->Message), "Error %d opening %s", errno, fn);
return NULL; return NULL;
} // endif h } // endif h
if ((len = _filelength(h)) < 0) { if ((len = _filelength(h)) < 0) {
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn); snprintf(g->Message, sizeof(g->Message), MSG(FILELEN_ERROR), "_filelength", fn);
close(h); close(h);
return NULL; return NULL;
} // endif len } // endif len
if ((str = (char*)PlgDBSubAlloc(g, NULL, len + 1))) { if ((str = (char*)PlgDBSubAlloc(g, NULL, len + 1))) {
if ((n = read(h, str, len)) < 0) { if ((n = read(h, str, len)) < 0) {
sprintf(g->Message, "Error %d reading %d bytes from %s", errno, len, fn); snprintf(g->Message, sizeof(g->Message), "Error %d reading %d bytes from %s", errno, len, fn);
return NULL; return NULL;
} // endif n } // endif n
@@ -3372,7 +3372,7 @@ char *json_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (!i) top = jvp->GetJson(); if (!i) top = jvp->GetJson();
if (jvp->GetValType() != TYPE_JAR && jvp->GetValType() != TYPE_JOB) { if (jvp->GetValType() != TYPE_JAR && jvp->GetValType() != TYPE_JOB) {
sprintf(g->Message, "Argument %d is not an array or object", i); snprintf(g->Message, sizeof(g->Message), "Argument %d is not an array or object", i);
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
} else } else
jsp[i] = jvp->GetJsp(); jsp[i] = jvp->GetJsp();
@@ -5533,7 +5533,7 @@ char *jbin_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (!i) top = jvp->GetJson(); if (!i) top = jvp->GetJson();
if (jvp->GetValType() != TYPE_JAR && jvp->GetValType() != TYPE_JOB) { if (jvp->GetValType() != TYPE_JAR && jvp->GetValType() != TYPE_JOB) {
sprintf(g->Message, "Argument %d is not an array or object", i); snprintf(g->Message, sizeof(g->Message), "Argument %d is not an array or object", i);
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
} else } else
jsp[i] = jvp->GetJsp(); jsp[i] = jvp->GetJsp();
@@ -6031,7 +6031,7 @@ char *jfile_bjson(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (!fgets(buf, lrecl, fin)) { if (!fgets(buf, lrecl, fin)) {
if (!feof(fin)) { if (!feof(fin)) {
sprintf(g->Message, "Error %d reading %zd bytes from %s", errno, lrecl, fn); snprintf(g->Message, sizeof(g->Message), "Error %d reading %zu bytes from %s", errno, lrecl, fn);
str = strcpy(result, g->Message); str = strcpy(result, g->Message);
} else } else
str = strcpy(result, ofn); str = strcpy(result, ofn);
@@ -6045,11 +6045,11 @@ char *jfile_bjson(UDF_INIT *initid, UDF_ARGS *args, char *result,
swp->SwapJson(jsp, true); swp->SwapJson(jsp, true);
if (fwrite(binszp, sizeof(binszp), 1, fout) != 1) { if (fwrite(binszp, sizeof(binszp), 1, fout) != 1) {
sprintf(g->Message, "Error %d writing %zd bytes to %s", snprintf(g->Message, sizeof(g->Message), "Error %d writing %zu bytes to %s",
errno, sizeof(binszp), ofn); errno, sizeof(binszp), ofn);
str = strcpy(result, g->Message); str = strcpy(result, g->Message);
} else if (fwrite(jsp, *binszp, 1, fout) != 1) { } else if (fwrite(jsp, *binszp, 1, fout) != 1) {
sprintf(g->Message, "Error %d writing %zd bytes to %s", snprintf(g->Message, sizeof(g->Message), "Error %d writing %zu bytes to %s",
errno, *binszp, ofn); errno, *binszp, ofn);
str = strcpy(result, g->Message); str = strcpy(result, g->Message);
} else } else
@@ -6127,7 +6127,7 @@ char* JUP::UnprettyJsonFile(PGLOBAL g, char *fn, char *outfn, int lrecl) {
DWORD rc = GetLastError(); DWORD rc = GetLastError();
if (!(*g->Message)) if (!(*g->Message))
sprintf(g->Message, MSG(OPEN_MODE_ERROR), "map", (int)rc, fn); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR), "map", (int)rc, fn);
return NULL; return NULL;
} // endif hFile } // endif hFile
@@ -6148,7 +6148,7 @@ char* JUP::UnprettyJsonFile(PGLOBAL g, char *fn, char *outfn, int lrecl) {
if (!mm.memory) { if (!mm.memory) {
CloseFileHandle(hFile); CloseFileHandle(hFile);
sprintf(g->Message, MSG(MAP_VIEW_ERROR), fn, GetLastError()); snprintf(g->Message, sizeof(g->Message), MSG(MAP_VIEW_ERROR), fn, GetLastError());
return NULL; return NULL;
} else } else
s = (char*)mm.memory; s = (char*)mm.memory;
@@ -6159,7 +6159,7 @@ char* JUP::UnprettyJsonFile(PGLOBAL g, char *fn, char *outfn, int lrecl) {
/* Parse the json file and allocate its tree structure. */ /* Parse the json file and allocate its tree structure. */
/*********************************************************************************/ /*********************************************************************************/
if (!(fs = fopen(outfn, "wb"))) { if (!(fs = fopen(outfn, "wb"))) {
sprintf(g->Message, MSG(OPEN_MODE_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR),
"w", (int)errno, outfn); "w", (int)errno, outfn);
strcat(strcat(g->Message, ": "), strerror(errno)); strcat(strcat(g->Message, ": "), strerror(errno));
CloseMemMap(mm.memory, len); CloseMemMap(mm.memory, len);
@@ -6224,7 +6224,7 @@ bool JUP::unPretty(PGLOBAL g, int lrecl) {
go = next = false; go = next = false;
break; break;
default: default:
sprintf(g->Message, "Unexpected '%c' near %.*s", s[i], ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected '%c' near %.*s", s[i], ARGS);
throw 4; throw 4;
break; break;
}; // endswitch s[i] }; // endswitch s[i]
@@ -6237,7 +6237,7 @@ bool JUP::unPretty(PGLOBAL g, int lrecl) {
buff[k] = 0; buff[k] = 0;
if ((fputs(buff, fs)) == EOF) { if ((fputs(buff, fs)) == EOF) {
sprintf(g->Message, MSG(FPUTS_ERROR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(FPUTS_ERROR), strerror(errno));
throw 5; throw 5;
} // endif EOF } // endif EOF
@@ -6271,7 +6271,7 @@ void JUP::CopyObject(PGLOBAL g) {
CopyString(g); CopyString(g);
level = 1; level = 1;
} else { } else {
sprintf(g->Message, "misplaced string near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "misplaced string near %.*s", ARGS);
throw 3; throw 3;
} // endif level } // endif level
@@ -6283,7 +6283,7 @@ void JUP::CopyObject(PGLOBAL g) {
CopyValue(g); CopyValue(g);
level = 2; level = 2;
} else { } else {
sprintf(g->Message, "Unexpected ':' near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected ':' near %.*s", ARGS);
throw 3; throw 3;
} // endif level } // endif level
@@ -6292,7 +6292,7 @@ void JUP::CopyObject(PGLOBAL g) {
AddBuff(s[i]); AddBuff(s[i]);
if (level < 2) { if (level < 2) {
sprintf(g->Message, "Unexpected ',' near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected ',' near %.*s", ARGS);
throw 3; throw 3;
} else } else
level = 0; level = 0;
@@ -6302,7 +6302,7 @@ void JUP::CopyObject(PGLOBAL g) {
AddBuff(s[i]); AddBuff(s[i]);
if (level == 1) { if (level == 1) {
sprintf(g->Message, "Unexpected '}' near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected '}' near %.*s", ARGS);
throw 3; throw 3;
} // endif level } // endif level
@@ -6313,7 +6313,7 @@ void JUP::CopyObject(PGLOBAL g) {
case '\t': case '\t':
break; break;
default: default:
sprintf(g->Message, "Unexpected character '%c' near %.*s", s[i], ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected character '%c' near %.*s", s[i], ARGS);
throw 3; throw 3;
}; // endswitch s[i] }; // endswitch s[i]
@@ -6330,7 +6330,7 @@ void JUP::CopyArray(PGLOBAL g) {
switch (s[i]) { switch (s[i]) {
case ',': case ',':
if (level < 2) { if (level < 2) {
sprintf(g->Message, "Unexpected ',' near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected ',' near %.*s", ARGS);
throw 2; throw 2;
} else } else
level = 1; level = 1;
@@ -6339,7 +6339,7 @@ void JUP::CopyArray(PGLOBAL g) {
break; break;
case ']': case ']':
if (level == 1) { if (level == 1) {
sprintf(g->Message, "Unexpected ',]' near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected ',]' near %.*s", ARGS);
throw 2; throw 2;
} // endif level } // endif level
@@ -6352,7 +6352,7 @@ void JUP::CopyArray(PGLOBAL g) {
break; break;
default: default:
if (level == 2) { if (level == 2) {
sprintf(g->Message, "Unexpected value near %.*s", ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected value near %.*s", ARGS);
throw 2; throw 2;
} // endif level } // endif level
@@ -6435,7 +6435,7 @@ suite:
return; return;
err: err:
sprintf(g->Message, "Unexpected character '%c' near %.*s", s[i], ARGS); snprintf(g->Message, sizeof(g->Message), "Unexpected character '%c' near %.*s", s[i], ARGS);
throw 1; throw 1;
} // end of CopyValue } // end of CopyValue

View File

@@ -661,7 +661,7 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp)
if (xmlXPathRegisterNs(Ctxp, BAD_CAST nsp->Prefix, if (xmlXPathRegisterNs(Ctxp, BAD_CAST nsp->Prefix,
BAD_CAST nsp->Uri)) { BAD_CAST nsp->Uri)) {
sprintf(g->Message, MSG(REGISTER_ERR), nsp->Prefix, nsp->Uri); snprintf(g->Message, sizeof(g->Message), MSG(REGISTER_ERR), nsp->Prefix, nsp->Uri);
if (trace(1)) if (trace(1))
htrc("Ns error: %s\n", g->Message); htrc("Ns error: %s\n", g->Message);
@@ -703,7 +703,7 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp)
// Evaluate table xpath // Evaluate table xpath
if (!(Xop = xmlXPathEval(BAD_CAST xp, Ctxp))) { if (!(Xop = xmlXPathEval(BAD_CAST xp, Ctxp))) {
sprintf(g->Message, MSG(XPATH_EVAL_ERR), xp); snprintf(g->Message, sizeof(g->Message), MSG(XPATH_EVAL_ERR), xp);
if (trace(1)) if (trace(1))
htrc("Path error: %s\n", g->Message); htrc("Path error: %s\n", g->Message);
@@ -882,7 +882,7 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len)
} // endif p1 } // endif p1
} else { } else {
sprintf(g->Message, "Truncated %s content", Nodep->name); snprintf(g->Message, sizeof(g->Message), "Truncated %s content", Nodep->name);
rc = RC_INFO; rc = RC_INFO;
} // endif len } // endif len
@@ -1260,7 +1260,7 @@ RCODE XML2ATTR::GetText(PGLOBAL g, char *buf, int len)
if (strlen((char*)txt) >= (unsigned)len) { if (strlen((char*)txt) >= (unsigned)len) {
memcpy(buf, txt, len - 1); memcpy(buf, txt, len - 1);
buf[len - 1] = 0; buf[len - 1] = 0;
sprintf(g->Message, "Truncated %s content", Atrp->name); snprintf(g->Message, sizeof(g->Message), "Truncated %s content", Atrp->name);
rc = RC_INFO; rc = RC_INFO;
} else } else
strcpy(buf, (const char*)txt); strcpy(buf, (const char*)txt);

View File

@@ -53,7 +53,7 @@ MACINFO::MACINFO(bool adap, bool fix)
void MACINFO::MakeErrorMsg(PGLOBAL g, DWORD drc) void MACINFO::MakeErrorMsg(PGLOBAL g, DWORD drc)
{ {
if (drc == ERROR_BUFFER_OVERFLOW) if (drc == ERROR_BUFFER_OVERFLOW)
sprintf(g->Message, snprintf(g->Message, sizeof(g->Message),
"GetAdaptersInfo: Buffer Overflow buflen=%d nbofadap=%d", "GetAdaptersInfo: Buffer Overflow buflen=%d nbofadap=%d",
Buflen, N); Buflen, N);
else if (drc == ERROR_INVALID_PARAMETER) else if (drc == ERROR_INVALID_PARAMETER)
@@ -146,7 +146,7 @@ bool MACINFO::GetFixedInfo(PGLOBAL g)
} // endif drc } // endif drc
if (drc != ERROR_SUCCESS) { if (drc != ERROR_SUCCESS) {
sprintf(g->Message, "GetNetworkParams failed. Rc=%08x\n", drc); snprintf(g->Message, sizeof(g->Message), "GetNetworkParams failed. Rc=%08x\n", drc);
return true; return true;
} // endif drc } // endif drc
@@ -305,7 +305,7 @@ bool MACINFO::GetOneInfo(PGLOBAL g, int flag, void *v, int lv)
n = (int)Curp->LeaseExpires; n = (int)Curp->LeaseExpires;
break; break;
default: default:
sprintf(g->Message, "Invalid flag value %d", flag); snprintf(g->Message, sizeof(g->Message), "Invalid flag value %d", flag);
return true; return true;
} // endswitch flag } // endswitch flag

View File

@@ -50,7 +50,7 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR filename,
disposition = OPEN_ALWAYS; disposition = OPEN_ALWAYS;
break; break;
default: default:
sprintf(g->Message, MSG(BAD_FUNC_MODE), "CreateFileMap", mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FUNC_MODE), "CreateFileMap", mode);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} // endswitch } // endswitch
@@ -69,11 +69,11 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR filename,
DWORD ler = GetLastError(); DWORD ler = GetLastError();
if (ler && ler != 1006) { if (ler && ler != 1006) {
sprintf(g->Message, MSG(FILE_MAP_ERROR), filename, ler); snprintf(g->Message, sizeof(g->Message), MSG(FILE_MAP_ERROR), filename, ler);
CloseHandle(hFile); CloseHandle(hFile);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} else { } else {
sprintf(g->Message, MSG(FILE_IS_EMPTY), filename); snprintf(g->Message, sizeof(g->Message), MSG(FILE_IS_EMPTY), filename);
return hFile; return hFile;
} // endif ler } // endif ler
@@ -84,7 +84,7 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR filename,
if (!(mm->memory = MapViewOfFile(hFileMap, access, 0, 0, 0))) { if (!(mm->memory = MapViewOfFile(hFileMap, access, 0, 0, 0))) {
DWORD ler = GetLastError(); DWORD ler = GetLastError();
sprintf(g->Message, "Error %ld in MapViewOfFile %s", snprintf(g->Message, sizeof(g->Message), "Error %ld in MapViewOfFile %s",
ler, filename); ler, filename);
CloseHandle(hFile); CloseHandle(hFile);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
@@ -149,7 +149,7 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR fileName,
protmode = PROT_WRITE; protmode = PROT_WRITE;
break; break;
default: default:
sprintf(g->Message, MSG(BAD_FUNC_MODE), "CreateFileMap", mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FUNC_MODE), "CreateFileMap", mode);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} // endswitch } // endswitch
@@ -159,7 +159,7 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR fileName,
if (fd != INVALID_HANDLE_VALUE && mode != MODE_INSERT) { if (fd != INVALID_HANDLE_VALUE && mode != MODE_INSERT) {
/* We must know about the size of the file. */ /* We must know about the size of the file. */
if (fstat(fd, &st)) { if (fstat(fd, &st)) {
sprintf(g->Message, MSG(FILE_MAP_ERROR), fileName, errno); snprintf(g->Message, sizeof(g->Message), MSG(FILE_MAP_ERROR), fileName, errno);
close(fd); close(fd);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} // endif fstat } // endif fstat

View File

@@ -152,14 +152,14 @@ PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info)
#if defined(CMGO_SUPPORT) #if defined(CMGO_SUPPORT)
cmgd = new(g) CMGDISC(g, (int*)length); cmgd = new(g) CMGDISC(g, (int*)length);
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "C"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "C");
goto err; goto err;
#endif #endif
} else if (drv && toupper(*drv) == 'J') { } else if (drv && toupper(*drv) == 'J') {
#if defined(JAVA_SUPPORT) #if defined(JAVA_SUPPORT)
cmgd = new(g) JMGDISC(g, (int*)length); cmgd = new(g) JMGDISC(g, (int*)length);
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "Java"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "Java");
goto err; goto err;
#endif #endif
} else { // Driver not specified } else { // Driver not specified
@@ -421,7 +421,7 @@ PTDB MGODEF::GetTable(PGLOBAL g, MODE m)
else else
return new(g) TDBCMG(this); return new(g) TDBCMG(this);
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "C"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "C");
return NULL; return NULL;
#endif #endif
} else if (Driver && toupper(*Driver) == 'J') { } else if (Driver && toupper(*Driver) == 'J') {
@@ -431,7 +431,7 @@ PTDB MGODEF::GetTable(PGLOBAL g, MODE m)
else else
return new(g) TDBJMG(this); return new(g) TDBJMG(this);
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "Java"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "Java");
return NULL; return NULL;
#endif #endif
} else { // Driver not specified } else { // Driver not specified

View File

@@ -520,7 +520,7 @@ PTABDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
// fall through // fall through
#endif // JAVA_SUPPORT || CMGO_SUPPORT #endif // JAVA_SUPPORT || CMGO_SUPPORT
default: default:
sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_TABLE_TYPE), am, name);
} // endswitch } // endswitch
// Do make the table/view definition // Do make the table/view definition

View File

@@ -272,7 +272,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
nf = sscanf(fld, "%s %s %s", buf, uns, zero) + 2; nf = sscanf(fld, "%s %s %s", buf, uns, zero) + 2;
break; break;
default: default:
sprintf(g->Message, MSG(BAD_FIELD_TYPE), fld); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FIELD_TYPE), fld);
myc.Close(); myc.Close();
return NULL; return NULL;
} // endswitch nf } // endswitch nf
@@ -280,19 +280,19 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
if ((type = MYSQLtoPLG(buf, &v)) == TYPE_ERROR) { if ((type = MYSQLtoPLG(buf, &v)) == TYPE_ERROR) {
if (v == 'K') { if (v == 'K') {
// Skip this column // Skip this column
sprintf(g->Message, "Column %s skipped (unsupported type %s)", snprintf(g->Message, sizeof(g->Message), "Column %s skipped (unsupported type %s)",
colname, buf); colname, buf);
PushWarning(g, thd); PushWarning(g, thd);
continue; continue;
} // endif v } // endif v
sprintf(g->Message, "Column %s unsupported type %s", colname, buf); snprintf(g->Message, sizeof(g->Message), "Column %s unsupported type %s", colname, buf);
myc.Close(); myc.Close();
return NULL; return NULL;
} else if (type == TYPE_STRING) { } else if (type == TYPE_STRING) {
if (v == 'X') { if (v == 'X') {
len = GetConvSize(); len = GetConvSize();
sprintf(g->Message, "Column %s converted to varchar(%d)", snprintf(g->Message, sizeof(g->Message), "Column %s converted to varchar(%d)",
colname, len); colname, len);
PushWarning(g, thd); PushWarning(g, thd);
v = 'V'; v = 'V';
@@ -532,10 +532,10 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
if (!mysql_real_connect(m_DB, host, user, pwd, db, pt, pipe, if (!mysql_real_connect(m_DB, host, user, pwd, db, pt, pipe,
CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS)) { CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS)) {
#if defined(_DEBUG) #if defined(_DEBUG)
sprintf(g->Message, "mysql_real_connect failed: (%d) %s", snprintf(g->Message, sizeof(g->Message), "mysql_real_connect failed: (%d) %s",
mysql_errno(m_DB), mysql_error(m_DB)); mysql_errno(m_DB), mysql_error(m_DB));
#else // !_DEBUG #else // !_DEBUG
sprintf(g->Message, "(%d) %s", mysql_errno(m_DB), mysql_error(m_DB)); snprintf(g->Message, sizeof(g->Message), "(%d) %s", mysql_errno(m_DB), mysql_error(m_DB));
#endif // !_DEBUG #endif // !_DEBUG
mysql_close(m_DB); mysql_close(m_DB);
m_DB = NULL; m_DB = NULL;
@@ -616,7 +616,7 @@ int MYSQLC::PrepareSQL(PGLOBAL g, const char *stmt)
#if defined(ALPHA) #if defined(ALPHA)
if (!(m_Stmt = mysql_prepare(m_DB, stmt, strlen(stmt)))) { if (!(m_Stmt = mysql_prepare(m_DB, stmt, strlen(stmt)))) {
sprintf(g->Message, "mysql_prepare failed: %s [%s]", snprintf(g->Message, sizeof(g->Message), "mysql_prepare failed: %s [%s]",
mysql_error(m_DB), stmt); mysql_error(m_DB), stmt);
return -1; return -1;
} // endif m_Stmt } // endif m_Stmt
@@ -630,7 +630,7 @@ int MYSQLC::PrepareSQL(PGLOBAL g, const char *stmt)
} // endif m_Stmt } // endif m_Stmt
if (mysql_stmt_prepare(m_Stmt, stmt, strlen(stmt))) { if (mysql_stmt_prepare(m_Stmt, stmt, strlen(stmt))) {
sprintf(g->Message, "mysql_stmt_prepare() failed: (%d) %s", snprintf(g->Message, sizeof(g->Message), "mysql_stmt_prepare() failed: (%d) %s",
mysql_stmt_errno(m_Stmt), mysql_stmt_error(m_Stmt)); mysql_stmt_errno(m_Stmt), mysql_stmt_error(m_Stmt));
return -3; return -3;
} // endif prepare } // endif prepare
@@ -653,11 +653,11 @@ int MYSQLC::BindParams(PGLOBAL g, MYSQL_BIND *bind)
#if defined(ALPHA) #if defined(ALPHA)
if (mysql_bind_param(m_Stmt, bind)) { if (mysql_bind_param(m_Stmt, bind)) {
sprintf(g->Message, "mysql_bind_param() failed: %s", snprintf(g->Message, sizeof(g->Message), "mysql_bind_param() failed: %s",
mysql_stmt_error(m_Stmt)); mysql_stmt_error(m_Stmt));
#else // !ALPHA #else // !ALPHA
if (mysql_stmt_bind_param(m_Stmt, bind)) { if (mysql_stmt_bind_param(m_Stmt, bind)) {
sprintf(g->Message, "mysql_stmt_bind_param() failed: %s", snprintf(g->Message, sizeof(g->Message), "mysql_stmt_bind_param() failed: %s",
mysql_stmt_error(m_Stmt)); mysql_stmt_error(m_Stmt));
#endif // !ALPHA #endif // !ALPHA
return RC_FX; return RC_FX;
@@ -677,13 +677,13 @@ int MYSQLC::ExecStmt(PGLOBAL g)
#if defined(ALPHA) #if defined(ALPHA)
if (mysql_execute(m_Stmt)) { if (mysql_execute(m_Stmt)) {
sprintf(g->Message, "mysql_execute() failed: %s", snprintf(g->Message, sizeof(g->Message), "mysql_execute() failed: %s",
mysql_stmt_error(m_Stmt)); mysql_stmt_error(m_Stmt));
return RC_FX; return RC_FX;
} // endif execute } // endif execute
#else // !ALPHA #else // !ALPHA
if (mysql_stmt_execute(m_Stmt)) { if (mysql_stmt_execute(m_Stmt)) {
sprintf(g->Message, "mysql_stmt_execute() failed: %s", snprintf(g->Message, sizeof(g->Message), "mysql_stmt_execute() failed: %s",
mysql_stmt_error(m_Stmt)); mysql_stmt_error(m_Stmt));
return RC_FX; return RC_FX;
} // endif execute } // endif execute
@@ -691,7 +691,7 @@ int MYSQLC::ExecStmt(PGLOBAL g)
// Check the total number of affected rows // Check the total number of affected rows
if (mysql_stmt_affected_rows(m_Stmt) != 1) { if (mysql_stmt_affected_rows(m_Stmt) != 1) {
sprintf(g->Message, "Invalid affected rows by MySQL"); snprintf(g->Message, sizeof(g->Message), "Invalid affected rows by MySQL");
return RC_FX; return RC_FX;
} // endif affected_rows } // endif affected_rows
@@ -757,7 +757,7 @@ int MYSQLC::ExecSQL(PGLOBAL g, const char *query, int *w)
} else { } else {
// m_Rows = (int)mysql_affected_rows(m_DB); // m_Rows = (int)mysql_affected_rows(m_DB);
m_Rows = (int)m_DB->affected_rows; m_Rows = (int)m_DB->affected_rows;
sprintf(g->Message, "Affected rows: %d\n", m_Rows); snprintf(g->Message, sizeof(g->Message), "Affected rows: %d\n", m_Rows);
rc = RC_NF; rc = RC_NF;
} // endif field count } // endif field count
@@ -892,7 +892,7 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
MYSQL_ROW row; MYSQL_ROW row;
if (!m_Res || !m_Fields) { if (!m_Res || !m_Fields) {
sprintf(g->Message, "%s result", (m_Res) ? "Void" : "No"); snprintf(g->Message, sizeof(g->Message), "%s result", (m_Res) ? "Void" : "No");
return NULL; return NULL;
} // endif m_Res } // endif m_Res
@@ -926,7 +926,7 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
crp->Name = name; crp->Name = name;
if ((crp->Type = MYSQLtoPLG(fld->type, &v)) == TYPE_ERROR) { if ((crp->Type = MYSQLtoPLG(fld->type, &v)) == TYPE_ERROR) {
sprintf(g->Message, "Type %d not supported for column %s", snprintf(g->Message, sizeof(g->Message), "Type %d not supported for column %s",
fld->type, crp->Name); fld->type, crp->Name);
return NULL; return NULL;
} else if (crp->Type == TYPE_DATE && !pdb) } else if (crp->Type == TYPE_DATE && !pdb)
@@ -944,7 +944,7 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows, if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows,
crp->Clen, 0, FALSE, TRUE, uns))) { crp->Clen, 0, FALSE, TRUE, uns))) {
sprintf(g->Message, MSG(INV_RESULT_TYPE), snprintf(g->Message, sizeof(g->Message), MSG(INV_RESULT_TYPE),
GetFormatType(crp->Type)); GetFormatType(crp->Type));
return NULL; return NULL;
} else if (crp->Type == TYPE_DATE) { } else if (crp->Type == TYPE_DATE) {
@@ -973,7 +973,7 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
/*********************************************************************/ /*********************************************************************/
for (n = 0; n < m_Rows; n++) { for (n = 0; n < m_Rows; n++) {
if (!(m_Row = mysql_fetch_row(m_Res))) { if (!(m_Row = mysql_fetch_row(m_Res))) {
sprintf(g->Message, "Missing row %d from result", n + 1); snprintf(g->Message, sizeof(g->Message), "Missing row %d from result", n + 1);
return NULL; return NULL;
} // endif m_Row } // endif m_Row
@@ -1051,7 +1051,7 @@ int MYSQLC::ExecSQLcmd(PGLOBAL g, const char *query, int *w)
//if (mysql_query(m_DB, query) != 0) { //if (mysql_query(m_DB, query) != 0) {
if (mysql_real_query(m_DB, query, strlen(query))) { if (mysql_real_query(m_DB, query, strlen(query))) {
m_Afrw = (int)mysql_errno(m_DB); m_Afrw = (int)mysql_errno(m_DB);
sprintf(g->Message, "Remote: %s", mysql_error(m_DB)); snprintf(g->Message, sizeof(g->Message), "Remote: %s", mysql_error(m_DB));
rc = RC_FX; rc = RC_FX;
//} else if (!(m_Fields = mysql_field_count(m_DB))) { //} else if (!(m_Fields = mysql_field_count(m_DB))) {
} else if (!(m_Fields = (int)m_DB->field_count)) { } else if (!(m_Fields = (int)m_DB->field_count)) {

View File

@@ -1180,7 +1180,7 @@ int ODBConn::Open(PCSZ ConnectString, POPARM sop, DWORD options)
// VerifyConnect(); Deprecated // VerifyConnect(); Deprecated
GetConnectInfo(); GetConnectInfo();
} catch(DBX *xp) { } catch(DBX *xp) {
sprintf(g->Message, "%s: %s", xp->m_Msg, xp->GetErrorMessage(0)); snprintf(g->Message, sizeof(g->Message), "%s: %s", xp->m_Msg, xp->GetErrorMessage(0));
Close(); Close();
// Free(); // Free();
return -1; return -1;
@@ -1646,7 +1646,7 @@ int ODBConn::Fetch(int pos)
for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++)
htrc(x->m_ErrMsg[i]); htrc(x->m_ErrMsg[i]);
sprintf(g->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0)); snprintf(g->Message, sizeof(g->Message), "%s: %s", x->m_Msg, x->GetErrorMessage(0));
irc = -1; irc = -1;
} // end try/catch } // end try/catch
@@ -1682,7 +1682,7 @@ int ODBConn::PrepareSQL(char *sql)
for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++)
htrc(x->m_ErrMsg[i]); htrc(x->m_ErrMsg[i]);
sprintf(g->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0)); snprintf(g->Message, sizeof(g->Message), "%s: %s", x->m_Msg, x->GetErrorMessage(0));
} // end try/catch } // end try/catch
} // endif Mode } // endif Mode
@@ -1728,7 +1728,7 @@ int ODBConn::PrepareSQL(char *sql)
for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++)
htrc(x->m_ErrMsg[i]); htrc(x->m_ErrMsg[i]);
sprintf(g->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0)); snprintf(g->Message, sizeof(g->Message), "%s: %s", x->m_Msg, x->GetErrorMessage(0));
if (b) if (b)
SQLCancel(hstmt); SQLCancel(hstmt);
@@ -1928,7 +1928,7 @@ bool ODBConn::ExecSQLcommand(char *sql)
for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++)
htrc(x->m_ErrMsg[i]); htrc(x->m_ErrMsg[i]);
sprintf(g->Message, "Remote %s: %s", x->m_Msg, x->GetErrorMessage(0)); snprintf(g->Message, sizeof(g->Message), "Remote %s: %s", x->m_Msg, x->GetErrorMessage(0));
if (b) if (b)
SQLCancel(hstmt); SQLCancel(hstmt);
@@ -1938,17 +1938,17 @@ bool ODBConn::ExecSQLcommand(char *sql)
} // end try/catch } // end try/catch
if (!Check(rc = SQLFreeStmt(hstmt, SQL_CLOSE))) if (!Check(rc = SQLFreeStmt(hstmt, SQL_CLOSE)))
sprintf(g->Message, "SQLFreeStmt: rc=%d", rc); snprintf(g->Message, sizeof(g->Message), "SQLFreeStmt: rc=%d", rc);
if (m_Transact) { if (m_Transact) {
// Terminate the transaction // Terminate the transaction
if (!Check(rc = SQLEndTran(SQL_HANDLE_DBC, m_hdbc, if (!Check(rc = SQLEndTran(SQL_HANDLE_DBC, m_hdbc,
(rcd) ? SQL_ROLLBACK : SQL_COMMIT))) (rcd) ? SQL_ROLLBACK : SQL_COMMIT)))
sprintf(g->Message, "SQLEndTran: rc=%d", rc); snprintf(g->Message, sizeof(g->Message), "SQLEndTran: rc=%d", rc);
if (!Check(rc = SQLSetConnectAttr(m_hdbc, SQL_ATTR_AUTOCOMMIT, if (!Check(rc = SQLSetConnectAttr(m_hdbc, SQL_ATTR_AUTOCOMMIT,
(SQLPOINTER)SQL_AUTOCOMMIT_ON, SQL_IS_UINTEGER))) (SQLPOINTER)SQL_AUTOCOMMIT_ON, SQL_IS_UINTEGER)))
sprintf(g->Message, "SQLSetConnectAttr: rc=%d", rc); snprintf(g->Message, sizeof(g->Message), "SQLSetConnectAttr: rc=%d", rc);
m_Transact = false; m_Transact = false;
} // endif m_Transact } // endif m_Transact
@@ -2013,7 +2013,7 @@ PQRYRES ODBConn::GetMetaData(PGLOBAL g, PCSZ dsn, PCSZ src)
} // endfor i } // endfor i
} catch(DBX *x) { } catch(DBX *x) {
sprintf(g->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0)); snprintf(g->Message, sizeof(g->Message), "%s: %s", x->m_Msg, x->GetErrorMessage(0));
goto err; goto err;
} // end try/catch } // end try/catch
@@ -2064,7 +2064,7 @@ PQRYRES ODBConn::GetMetaData(PGLOBAL g, PCSZ dsn, PCSZ src)
} // endfor i } // endfor i
} catch(DBX *x) { } catch(DBX *x) {
sprintf(g->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0)); snprintf(g->Message, sizeof(g->Message), "%s: %s", x->m_Msg, x->GetErrorMessage(0));
qrp = NULL; qrp = NULL;
} // end try/catch } // end try/catch
@@ -2373,7 +2373,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
// Now bind the column buffers // Now bind the column buffers
for (n = 0, crp = qrp->Colresp; crp; crp = crp->Next) { for (n = 0, crp = qrp->Colresp; crp; crp = crp->Next) {
if ((tp = GetSQLCType(crp->Type)) == SQL_TYPE_NULL) { if ((tp = GetSQLCType(crp->Type)) == SQL_TYPE_NULL) {
sprintf(g->Message, MSG(INV_COLUMN_TYPE), crp->Type, crp->Name); snprintf(g->Message, sizeof(g->Message), MSG(INV_COLUMN_TYPE), crp->Type, crp->Name);
ThrowDBX(g->Message); ThrowDBX(g->Message);
} // endif tp } // endif tp
@@ -2459,9 +2459,9 @@ int ODBConn::GetCatInfo(CATPARM *cap)
if (rc == SQL_NO_DATA_FOUND) { if (rc == SQL_NO_DATA_FOUND) {
if (cap->Pat) if (cap->Pat)
sprintf(g->Message, MSG(NO_TABCOL_DATA), cap->Tab, cap->Pat); snprintf(g->Message, sizeof(g->Message), MSG(NO_TABCOL_DATA), cap->Tab, cap->Pat);
else else
sprintf(g->Message, MSG(NO_TAB_DATA), cap->Tab); snprintf(g->Message, sizeof(g->Message), MSG(NO_TAB_DATA), cap->Tab);
ThrowDBX(g->Message); ThrowDBX(g->Message);
} else if (rc == SQL_SUCCESS) { } else if (rc == SQL_SUCCESS) {
@@ -2486,7 +2486,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++)
htrc(x->m_ErrMsg[i]); htrc(x->m_ErrMsg[i]);
sprintf(g->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0)); snprintf(g->Message, sizeof(g->Message), "%s: %s", x->m_Msg, x->GetErrorMessage(0));
irc = -1; irc = -1;
} // end try/catch } // end try/catch
@@ -2548,7 +2548,7 @@ PQRYRES ODBConn::AllocateResult(PGLOBAL g)
if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows, if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows,
crp->Clen, 0, FALSE, TRUE, uns))) { crp->Clen, 0, FALSE, TRUE, uns))) {
sprintf(g->Message, MSG(INV_RESULT_TYPE), snprintf(g->Message, sizeof(g->Message), MSG(INV_RESULT_TYPE),
GetFormatType(crp->Type)); GetFormatType(crp->Type));
return NULL; return NULL;
} // endif Kdata } // endif Kdata

View File

@@ -313,7 +313,7 @@ PDBUSER PlgMakeUser(PGLOBAL g)
PDBUSER dbuserp; PDBUSER dbuserp;
if (!(dbuserp = (PDBUSER)malloc(sizeof(DBUSERBLK)))) { if (!(dbuserp = (PDBUSER)malloc(sizeof(DBUSERBLK)))) {
sprintf(g->Message, MSG(MALLOC_ERROR), "PlgMakeUser"); snprintf(g->Message, sizeof(g->Message), MSG(MALLOC_ERROR), "PlgMakeUser");
return NULL; return NULL;
} // endif dbuserp } // endif dbuserp
@@ -416,7 +416,7 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op)
case OP_FNAME: fname = pBuff; break; case OP_FNAME: fname = pBuff; break;
case OP_FTYPE: ftype = pBuff; break; case OP_FTYPE: ftype = pBuff; break;
default: default:
sprintf(g->Message, MSG(INVALID_OPER), op, "ExtractFromPath"); snprintf(g->Message, sizeof(g->Message), MSG(INVALID_OPER), op, "ExtractFromPath");
return NULL; return NULL;
} // endswitch op } // endswitch op
@@ -1396,7 +1396,7 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
memp, size, pph->To_Free, pph->FreeBlk); memp, size, pph->To_Free, pph->FreeBlk);
if (size > pph->FreeBlk) { /* Not enough memory left in pool */ if (size > pph->FreeBlk) { /* Not enough memory left in pool */
sprintf(g->Message, snprintf(g->Message, sizeof(g->Message),
"Not enough memory in Work area for request of %zd (used=%zd free=%zd)", "Not enough memory in Work area for request of %zd (used=%zd free=%zd)",
size, pph->To_Free, pph->FreeBlk); size, pph->To_Free, pph->FreeBlk);
@@ -1527,7 +1527,7 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
if (!(tp = new TABPTR)) { if (!(tp = new TABPTR)) {
PGLOBAL g = t->G; PGLOBAL g = t->G;
sprintf(g->Message, "NewPointer: %s", MSG(MEM_ALLOC_ERROR)); snprintf(g->Message, sizeof(g->Message), "NewPointer: %s", MSG(MEM_ALLOC_ERROR));
throw 3; throw 3;
} else { } else {
tp->Next = t->P1; tp->Next = t->P1;
@@ -1562,7 +1562,7 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
if (h[i] == -1) { if (h[i] == -1) {
// if (errno != ENOENT) { // if (errno != ENOENT) {
sprintf(g->Message, MSG(OPEN_MODE_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR),
"rb", (int)errno, fn[i]); "rb", (int)errno, fn[i]);
strcat(strcat(g->Message, ": "), strerror(errno)); strcat(strcat(g->Message, ": "), strerror(errno));
throw 666; throw 666;
@@ -1571,7 +1571,7 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
} else { } else {
if ((len[i] = _filelength(h[i])) < 0) { if ((len[i] = _filelength(h[i])) < 0) {
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn[i]); snprintf(g->Message, sizeof(g->Message), MSG(FILELEN_ERROR), "_filelength", fn[i]);
throw 666; throw 666;
} // endif len } // endif len
@@ -1585,7 +1585,7 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
while (rc == -1) { while (rc == -1) {
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
if ((n[i] = read(h[i], bp[i], 4096)) < 0) { if ((n[i] = read(h[i], bp[i], 4096)) < 0) {
sprintf(g->Message, MSG(READ_ERROR), fn[i], strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), fn[i], strerror(errno));
goto fin; goto fin;
} // endif n } // endif n

View File

@@ -52,7 +52,7 @@ bool XMLDOCUMENT::InitZip(PGLOBAL g, PCSZ entry)
zip = new(g) UNZIPUTL(entry, NULL, mul); zip = new(g) UNZIPUTL(entry, NULL, mul);
return zip == NULL; return zip == NULL;
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "ZIP");
return true; return true;
#endif // !ZIP_SUPPORT #endif // !ZIP_SUPPORT
} // end of InitZip } // end of InitZip

View File

@@ -478,7 +478,7 @@ bool AllocSarea(PGLOBAL g, size_t size)
g->Sarea = malloc(size); g->Sarea = malloc(size);
if (!g->Sarea) { if (!g->Sarea) {
sprintf(g->Message, MSG(MALLOC_ERROR), "malloc"); snprintf(g->Message, sizeof(g->Message), MSG(MALLOC_ERROR), "malloc");
g->Sarea_Size = 0; g->Sarea_Size = 0;
} else { } else {
g->Sarea_Size = size; g->Sarea_Size = size;
@@ -574,7 +574,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
if (size > pph->FreeBlk) { /* Not enough memory left in pool */ if (size > pph->FreeBlk) { /* Not enough memory left in pool */
PCSZ pname = "Work"; PCSZ pname = "Work";
sprintf(g->Message, snprintf(g->Message, sizeof(g->Message),
"Not enough memory in %s area for request of %zd (used=%zd free=%zd)", "Not enough memory in %s area for request of %zd (used=%zd free=%zd)",
pname, size, pph->To_Free, pph->FreeBlk); pname, size, pph->To_Free, pph->FreeBlk);

View File

@@ -114,7 +114,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
char buf[256]; char buf[256];
DWORD rc = GetLastError(); DWORD rc = GetLastError();
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, soname); snprintf(g->Message, sizeof(g->Message), MSG(DLL_LOAD_ERROR), rc, soname);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
@@ -124,7 +124,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
// Get the function returning an instance of the external DEF class // Get the function returning an instance of the external DEF class
if (!(coldef = (XCOLDEF)GetProcAddress((HINSTANCE)hdll, getname))) { if (!(coldef = (XCOLDEF)GetProcAddress((HINSTANCE)hdll, getname))) {
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname); snprintf(g->Message, sizeof(g->Message), MSG(PROCADD_ERROR), GetLastError(), getname);
FreeLibrary((HMODULE)hdll); FreeLibrary((HMODULE)hdll);
return NULL; return NULL;
} // endif coldef } // endif coldef
@@ -134,21 +134,21 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
// Load the desired shared library // Load the desired shared library
if (!(hdll = dlopen(soname, RTLD_LAZY))) { if (!(hdll = dlopen(soname, RTLD_LAZY))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); snprintf(g->Message, sizeof(g->Message), MSG(SHARED_LIB_ERR), soname, SVP(error));
return NULL; return NULL;
} // endif Hdll } // endif Hdll
// Get the function returning an instance of the external DEF class // Get the function returning an instance of the external DEF class
if (!(coldef = (XCOLDEF)dlsym(hdll, getname))) { if (!(coldef = (XCOLDEF)dlsym(hdll, getname))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error)); snprintf(g->Message, sizeof(g->Message), MSG(GET_FUNC_ERR), getname, SVP(error));
dlclose(hdll); dlclose(hdll);
return NULL; return NULL;
} // endif coldef } // endif coldef
#endif // !_WIN32 #endif // !_WIN32
// Just in case the external Get function does not set error messages // Just in case the external Get function does not set error messages
sprintf(g->Message, "Error getting column info from %s", subtype); snprintf(g->Message, sizeof(g->Message), "Error getting column info from %s", subtype);
// Get the table column definition // Get the table column definition
qrp = coldef(g, topt, tab, db, info); qrp = coldef(g, topt, tab, db, info);
@@ -519,7 +519,7 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
case 'T': nof = sizeof(char); break; case 'T': nof = sizeof(char); break;
case 'G': nof = sizeof(longlong); break; case 'G': nof = sizeof(longlong); break;
default: /* Wrong format */ default: /* Wrong format */
sprintf(g->Message, "Invalid format %c", fty); snprintf(g->Message, sizeof(g->Message), "Invalid format %c", fty);
return -1; return -1;
} // endswitch fty } // endswitch fty
@@ -637,7 +637,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
char buf[256]; char buf[256];
DWORD rc = GetLastError(); DWORD rc = GetLastError();
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, soname); snprintf(g->Message, sizeof(g->Message), MSG(DLL_LOAD_ERROR), rc, soname);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
@@ -657,7 +657,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
char buf[256]; char buf[256];
DWORD rc = GetLastError(); DWORD rc = GetLastError();
sprintf(g->Message, MSG(PROCADD_ERROR), rc, getname); snprintf(g->Message, sizeof(g->Message), MSG(PROCADD_ERROR), rc, getname);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
@@ -675,13 +675,13 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
if (dladdr(&connect_hton, &dl_info)) { if (dladdr(&connect_hton, &dl_info)) {
if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) { if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) {
error = dlerror(); error = dlerror();
sprintf(g->Message, "dlopen failed: %s, OEM not supported", SVP(error)); snprintf(g->Message, sizeof(g->Message), "dlopen failed: %s, OEM not supported", SVP(error));
return NULL; return NULL;
} // endif dlopen } // endif dlopen
} else { } else {
error = dlerror(); error = dlerror();
sprintf(g->Message, "dladdr failed: %s, OEM not supported", SVP(error)); snprintf(g->Message, sizeof(g->Message), "dladdr failed: %s, OEM not supported", SVP(error));
return NULL; return NULL;
} // endif dladdr } // endif dladdr
#endif // 0 #endif // 0
@@ -689,7 +689,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
// Load the desired shared library // Load the desired shared library
if (!Hdll && !(Hdll = dlopen(soname, RTLD_LAZY))) { if (!Hdll && !(Hdll = dlopen(soname, RTLD_LAZY))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); snprintf(g->Message, sizeof(g->Message), MSG(SHARED_LIB_ERR), soname, SVP(error));
return NULL; return NULL;
} // endif Hdll } // endif Hdll
@@ -703,14 +703,14 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
// Get the function returning an instance of the external DEF class // Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) { if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error)); snprintf(g->Message, sizeof(g->Message), MSG(GET_FUNC_ERR), getname, SVP(error));
dlclose(Hdll); dlclose(Hdll);
return NULL; return NULL;
} // endif getdef } // endif getdef
#endif // !_WIN32 #endif // !_WIN32
// Just in case the external Get function does not set error messages // Just in case the external Get function does not set error messages
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype); snprintf(g->Message, sizeof(g->Message), MSG(DEF_ALLOC_ERROR), Subtype);
// Get the table definition block // Get the table definition block
if (!(xdefp = getdef(g, NULL))) if (!(xdefp = getdef(g, NULL)))
@@ -920,7 +920,7 @@ int COLDEF::Define(PGLOBAL g, void *, PCOLINFO cfp, int poff)
Buf_Type = cfp->Type; Buf_Type = cfp->Type;
if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) < 0) { if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) < 0) {
sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name);
return -1; return -1;
} // endswitch } // endswitch

View File

@@ -233,7 +233,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
(tdp->Version == 2) ? "Mongo2Interface" : "Mongo3Interface"); (tdp->Version == 2) ? "Mongo2Interface" : "Mongo3Interface");
tdp->Pretty = 0; tdp->Pretty = 0;
#else // !MONGO_SUPPORT #else // !MONGO_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "MONGO");
return 0; return 0;
#endif // !MONGO_SUPPORT #endif // !MONGO_SUPPORT
} // endif Uri } // endif Uri
@@ -245,7 +245,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
tjsp = new(g) TDBBSON(g, tdp, new(g) UNZFAM(tdp)); tjsp = new(g) TDBBSON(g, tdp, new(g) UNZFAM(tdp));
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "ZIP");
return 0; return 0;
#endif // !ZIP_SUPPORT #endif // !ZIP_SUPPORT
} else } else
@@ -261,7 +261,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
} else { } else {
if (!((tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0)))) { if (!((tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0)))) {
if (!mgo) { if (!mgo) {
sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty); snprintf(g->Message, sizeof(g->Message), "LRECL must be specified for pretty=%d", tdp->Pretty);
return 0; return 0;
} else } else
tdp->Lrecl = 8192; // Should be enough tdp->Lrecl = 8192; // Should be enough
@@ -276,7 +276,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
tjnp = new(g)TDBBSN(g, tdp, new(g) UNZFAM(tdp)); tjnp = new(g)TDBBSN(g, tdp, new(g) UNZFAM(tdp));
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "ZIP");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !ZIP_SUPPORT
} else if (tdp->Uri) { } else if (tdp->Uri) {
@@ -284,14 +284,14 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
#if defined(CMGO_SUPPORT) #if defined(CMGO_SUPPORT)
tjnp = new(g) TDBBSN(g, tdp, new(g) CMGFAM(tdp)); tjnp = new(g) TDBBSN(g, tdp, new(g) CMGFAM(tdp));
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "C"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "C");
return 0; return 0;
#endif #endif
} else if (tdp->Driver && toupper(*tdp->Driver) == 'J') { } else if (tdp->Driver && toupper(*tdp->Driver) == 'J') {
#if defined(JAVA_SUPPORT) #if defined(JAVA_SUPPORT)
tjnp = new(g) TDBBSN(g, tdp, new(g) JMGFAM(tdp)); tjnp = new(g) TDBBSN(g, tdp, new(g) JMGFAM(tdp));
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "Java"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "Java");
return 0; return 0;
#endif #endif
} else { // Driver not specified } else { // Driver not specified
@@ -300,7 +300,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
#elif defined(JAVA_SUPPORT) #elif defined(JAVA_SUPPORT)
tjnp = new(g) TDBBSN(g, tdp, new(g) JMGFAM(tdp)); tjnp = new(g) TDBBSN(g, tdp, new(g) JMGFAM(tdp));
#else #else
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "MONGO");
return 0; return 0;
#endif #endif
} // endif Driver } // endif Driver
@@ -503,7 +503,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j)
return false; return false;
default: default:
sprintf(g->Message, "Logical error after %s", fmt); snprintf(g->Message, sizeof(g->Message), "Logical error after %s", fmt);
return true; return true;
} // endswitch Type } // endswitch Type
@@ -626,7 +626,7 @@ PBVAL BTUTIL::FindRow(PGLOBAL g)
} else { } else {
if (bp || *objpath == '[') { // Old style if (bp || *objpath == '[') { // Old style
if (objpath[strlen(objpath) - 1] != ']') { if (objpath[strlen(objpath) - 1] != ']') {
sprintf(g->Message, "Invalid Table path %s", Tp->Objname); snprintf(g->Message, sizeof(g->Message), "Invalid Table path %s", Tp->Objname);
return NULL; return NULL;
} else if (!bp) } else if (!bp)
objpath++; objpath++;
@@ -706,7 +706,7 @@ PBVAL BTUTIL::MakeTopTree(PGLOBAL g, int type)
if (bp || *objpath == '[') { if (bp || *objpath == '[') {
// Old style // Old style
if (objpath[strlen(objpath) - 1] != ']') { if (objpath[strlen(objpath) - 1] != ']') {
sprintf(g->Message, "Invalid Table path %s", Tp->Objname); snprintf(g->Message, sizeof(g->Message), "Invalid Table path %s", Tp->Objname);
return NULL; return NULL;
} else if (!bp) } else if (!bp)
objpath++; objpath++;
@@ -918,7 +918,7 @@ PBVAL BCUTIL::GetRowValue(PGLOBAL g, PBVAL row, int i)
bvp = row; bvp = row;
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->Type); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->Type);
bvp = NULL; bvp = NULL;
} // endswitch Type } // endswitch Type
@@ -1122,7 +1122,7 @@ PBVAL BCUTIL::GetRow(PGLOBAL g)
val = row; val = row;
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->Type); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->Type);
val = NULL; val = NULL;
} // endswitch Type } // endswitch Type
@@ -1222,7 +1222,7 @@ bool BSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Wrapname = GetStringCatInfo(g, "Wrapper", "Mongo3Interface"); Wrapname = GetStringCatInfo(g, "Wrapper", "Mongo3Interface");
#endif // JAVA_SUPPORT #endif // JAVA_SUPPORT
#else // !MONGO_SUPPORT #else // !MONGO_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "MONGO");
return true; return true;
#endif // !MONGO_SUPPORT #endif // !MONGO_SUPPORT
} // endif Uri } // endif Uri
@@ -1266,14 +1266,14 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
#if defined(CMGO_SUPPORT) #if defined(CMGO_SUPPORT)
txfp = new(g) CMGFAM(this); txfp = new(g) CMGFAM(this);
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "C"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "C");
return NULL; return NULL;
#endif #endif
} else if (Driver && toupper(*Driver) == 'J') { } else if (Driver && toupper(*Driver) == 'J') {
#if defined(JAVA_SUPPORT) #if defined(JAVA_SUPPORT)
txfp = new(g) JMGFAM(this); txfp = new(g) JMGFAM(this);
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "Java"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "Java");
return NULL; return NULL;
#endif #endif
} else { // Driver not specified } else { // Driver not specified
@@ -1282,7 +1282,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
#elif defined(JAVA_SUPPORT) #elif defined(JAVA_SUPPORT)
txfp = new(g) JMGFAM(this); txfp = new(g) JMGFAM(this);
#else // !MONGO_SUPPORT #else // !MONGO_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "MONGO");
return NULL; return NULL;
#endif // !MONGO_SUPPORT #endif // !MONGO_SUPPORT
} // endif Driver } // endif Driver
@@ -1299,7 +1299,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
return NULL; return NULL;
} // endif's m } // endif's m
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "ZIP");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !ZIP_SUPPORT
} else if (Compressed) { } else if (Compressed) {
@@ -1309,7 +1309,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
else else
txfp = new(g) ZLBFAM(this); txfp = new(g) ZLBFAM(this);
#else // !GZ_SUPPORT #else // !GZ_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif // !GZ_SUPPORT #endif // !GZ_SUPPORT
} else if (map) { } else if (map) {
@@ -1332,7 +1332,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
return NULL; return NULL;
} // endif's m } // endif's m
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "ZIP");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !ZIP_SUPPORT
} else } else
@@ -1554,7 +1554,7 @@ bool TDBBSN::OpenDB(PGLOBAL g)
case MODE_ARRAY: type = TYPE_JAR; break; case MODE_ARRAY: type = TYPE_JAR; break;
case MODE_VALUE: type = TYPE_JVAL; break; case MODE_VALUE: type = TYPE_JVAL; break;
default: default:
sprintf(g->Message, "Invalid Jmode %d", Jmode); snprintf(g->Message, sizeof(g->Message), "Invalid Jmode %d", Jmode);
return true; return true;
} // endswitch Jmode } // endswitch Jmode
@@ -1662,7 +1662,7 @@ bool TDBBSN::PrepareWriting(PGLOBAL g)
if ((signed)strlen(s) > Lrecl) { if ((signed)strlen(s) > Lrecl) {
strncpy(To_Line, s, Lrecl); strncpy(To_Line, s, Lrecl);
sprintf(g->Message, "Line truncated (lrecl=%d)", Lrecl); snprintf(g->Message, sizeof(g->Message), "Line truncated (lrecl=%d)", Lrecl);
return PushWarning(g, this); return PushWarning(g, this);
} else } else
strcpy(To_Line, s); strcpy(To_Line, s);
@@ -1847,7 +1847,7 @@ bool BSONCOL::SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm)
break; break;
default: default:
sprintf(g->Message, snprintf(g->Message, sizeof(g->Message),
"Invalid function specification %c for %s", *p, Name); "Invalid function specification %c for %s", *p, Name);
return true; return true;
} // endswitch *p } // endswitch *p
@@ -1863,7 +1863,7 @@ bool BSONCOL::SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm)
} // endif n } // endif n
} else { } else {
sprintf(g->Message, "Wrong array specification for %s", Name); snprintf(g->Message, sizeof(g->Message), "Wrong array specification for %s", Name);
return true; return true;
} // endif's } // endif's
@@ -1932,7 +1932,7 @@ bool BSONCOL::ParseJpath(PGLOBAL g)
goto fin; goto fin;
} // endif Name } // endif Name
sprintf(g->Message, "Cannot parse updated column %s", Name); snprintf(g->Message, sizeof(g->Message), "Cannot parse updated column %s", Name);
return true; return true;
} // endif To_Orig } // endif To_Orig
@@ -2172,7 +2172,7 @@ void BSONCOL::WriteColumn(PGLOBAL g)
break; break;
default: // ?????????? default: // ??????????
sprintf(g->Message, "Invalid column type %d", Buf_Type); snprintf(g->Message, sizeof(g->Message), "Invalid column type %d", Buf_Type);
} // endswitch Type } // endswitch Type
} // end of WriteColumn } // end of WriteColumn
@@ -2322,7 +2322,7 @@ int TDBBSON::MakeDocument(PGLOBAL g)
val = Bp->GetKeyValue(objp, key); val = Bp->GetKeyValue(objp, key);
if (!val || !(jsp = Bp->GetBson(val))) { if (!val || !(jsp = Bp->GetBson(val))) {
sprintf(g->Message, "Cannot find object key %s", key); snprintf(g->Message, sizeof(g->Message), "Cannot find object key %s", key);
return RC_FX; return RC_FX;
} // endif val } // endif val
@@ -2330,7 +2330,7 @@ int TDBBSON::MakeDocument(PGLOBAL g)
if (*p == '[') { if (*p == '[') {
// Old style // Old style
if (p[strlen(p) - 1] != ']') { if (p[strlen(p) - 1] != ']') {
sprintf(g->Message, "Invalid Table path near %s", p); snprintf(g->Message, sizeof(g->Message), "Invalid Table path near %s", p);
return RC_FX; return RC_FX;
} else } else
p++; p++;
@@ -2348,7 +2348,7 @@ int TDBBSON::MakeDocument(PGLOBAL g)
val = Bp->GetArrayValue(arp, i); val = Bp->GetArrayValue(arp, i);
if (!val) { if (!val) {
sprintf(g->Message, "Cannot find array value %d", i); snprintf(g->Message, sizeof(g->Message), "Cannot find array value %d", i);
return RC_FX; return RC_FX;
} // endif val } // endif val
@@ -2513,7 +2513,7 @@ bool TDBBSON::OpenDB(PGLOBAL g)
case MODE_ARRAY: Row = Bp->NewVal(TYPE_JAR); break; case MODE_ARRAY: Row = Bp->NewVal(TYPE_JAR); break;
case MODE_VALUE: Row = Bp->NewVal(TYPE_JVAL); break; case MODE_VALUE: Row = Bp->NewVal(TYPE_JVAL); break;
default: default:
sprintf(g->Message, "Invalid Jmode %d", Jmode); snprintf(g->Message, sizeof(g->Message), "Invalid Jmode %d", Jmode);
return true; return true;
} // endswitch Jmode } // endswitch Jmode

View File

@@ -199,7 +199,7 @@ bool DOSDEF::GetOptFileName(PGLOBAL g, char *filename)
case RECFM_CSV: ftype = ".cop"; break; case RECFM_CSV: ftype = ".cop"; break;
case RECFM_DBF: ftype = ".dbp"; break; case RECFM_DBF: ftype = ".dbp"; break;
default: default:
sprintf(g->Message, MSG(INVALID_FTYPE), Recfm); snprintf(g->Message, sizeof(g->Message), MSG(INVALID_FTYPE), Recfm);
return true; return true;
} // endswitch Ftype } // endswitch Ftype
@@ -270,7 +270,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
case RECFM_CSV: ftype = ".cnx"; break; case RECFM_CSV: ftype = ".cnx"; break;
case RECFM_DBF: ftype = ".dbx"; break; case RECFM_DBF: ftype = ".dbx"; break;
default: default:
sprintf(g->Message, MSG(BAD_RECFM_VAL), Recfm); snprintf(g->Message, sizeof(g->Message), MSG(BAD_RECFM_VAL), Recfm);
return true; return true;
} // endswitch Ftype } // endswitch Ftype
@@ -323,7 +323,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
} // endif sep } // endif sep
if (rc) if (rc)
sprintf(g->Message, MSG(DEL_FILE_ERR), filename); snprintf(g->Message, sizeof(g->Message), MSG(DEL_FILE_ERR), filename);
return rc; // Return true if error return rc; // Return true if error
} // end of DeleteIndexFile } // end of DeleteIndexFile
@@ -405,7 +405,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
} // endif Recfm } // endif Recfm
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "ZIP");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !ZIP_SUPPORT
} else if (Recfm != RECFM_VAR && Compressed < 2) { } else if (Recfm != RECFM_VAR && Compressed < 2) {
@@ -417,7 +417,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
#if defined(GZ_SUPPORT) #if defined(GZ_SUPPORT)
txfp = new(g) GZXFAM(this); txfp = new(g) GZXFAM(this);
#else // !GZ_SUPPORT #else // !GZ_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif // !GZ_SUPPORT #endif // !GZ_SUPPORT
} else } else
@@ -433,7 +433,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
txfp = new(g) ZLBFAM(this); txfp = new(g) ZLBFAM(this);
#else // !GZ_SUPPORT #else // !GZ_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif // !GZ_SUPPORT #endif // !GZ_SUPPORT
} else if (map) } else if (map)
@@ -468,7 +468,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
((PZLBFAM)txfp)->SetOptimized(To_Pos != NULL); ((PZLBFAM)txfp)->SetOptimized(To_Pos != NULL);
} // endelse } // endelse
#else #else
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif #endif
} else } else
@@ -912,7 +912,7 @@ bool TDBDOS::SaveBlockValues(PGLOBAL g)
return true; return true;
if (!(opfile = fopen(filename, "wb"))) { if (!(opfile = fopen(filename, "wb"))) {
sprintf(g->Message, MSG(OPEN_MODE_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR),
"wb", (int)errno, filename); "wb", (int)errno, filename);
strcat(strcat(g->Message, ": "), strerror(errno)); strcat(strcat(g->Message, ": "), strerror(errno));
@@ -933,12 +933,12 @@ bool TDBDOS::SaveBlockValues(PGLOBAL g)
n[0] = Txfp->Last; n[1] = lg; n[2] = Txfp->Nrec; n[3] = Txfp->Block; n[0] = Txfp->Last; n[1] = lg; n[2] = Txfp->Nrec; n[3] = Txfp->Block;
if (fwrite(n, sizeof(int), NZ, opfile) != NZ) { if (fwrite(n, sizeof(int), NZ, opfile) != NZ) {
sprintf(g->Message, MSG(OPT_HEAD_WR_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_HEAD_WR_ERR), strerror(errno));
rc = true; rc = true;
} // endif size } // endif size
if (fwrite(Txfp->BlkPos, lg, block, opfile) != block) { if (fwrite(Txfp->BlkPos, lg, block, opfile) != block) {
sprintf(g->Message, MSG(OPTBLK_WR_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPTBLK_WR_ERR), strerror(errno));
rc = true; rc = true;
} // endif size } // endif size
@@ -961,17 +961,17 @@ bool TDBDOS::SaveBlockValues(PGLOBAL g)
n[4] = ndv; n[5] = nbm; n[4] = ndv; n[5] = nbm;
if (fwrite(n, sizeof(int), NZ + 2, opfile) != NZ + 2) { if (fwrite(n, sizeof(int), NZ + 2, opfile) != NZ + 2) {
sprintf(g->Message, MSG(OPT_HEAD_WR_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_HEAD_WR_ERR), strerror(errno));
rc = true; rc = true;
} // endif size } // endif size
if (fwrite(colp->Dval->GetValPointer(), lg, ndv, opfile) != ndv) { if (fwrite(colp->Dval->GetValPointer(), lg, ndv, opfile) != ndv) {
sprintf(g->Message, MSG(OPT_DVAL_WR_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_DVAL_WR_ERR), strerror(errno));
rc = true; rc = true;
} // endif size } // endif size
if (fwrite(colp->Bmap->GetValPointer(), sizeof(int), nbk, opfile) != nbk) { if (fwrite(colp->Bmap->GetValPointer(), sizeof(int), nbk, opfile) != nbk) {
sprintf(g->Message, MSG(OPT_BMAP_WR_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_BMAP_WR_ERR), strerror(errno));
rc = true; rc = true;
} // endif size } // endif size
@@ -979,17 +979,17 @@ bool TDBDOS::SaveBlockValues(PGLOBAL g)
n[0] = colp->Index; n[1] = lg; n[2] = Txfp->Nrec; n[3] = block; n[0] = colp->Index; n[1] = lg; n[2] = Txfp->Nrec; n[3] = block;
if (fwrite(n, sizeof(int), NZ, opfile) != NZ) { if (fwrite(n, sizeof(int), NZ, opfile) != NZ) {
sprintf(g->Message, MSG(OPT_HEAD_WR_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_HEAD_WR_ERR), strerror(errno));
rc = true; rc = true;
} // endif size } // endif size
if (fwrite(colp->Min->GetValPointer(), lg, block, opfile) != block) { if (fwrite(colp->Min->GetValPointer(), lg, block, opfile) != block) {
sprintf(g->Message, MSG(OPT_MIN_WR_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_MIN_WR_ERR), strerror(errno));
rc = true; rc = true;
} // endif size } // endif size
if (fwrite(colp->Max->GetValPointer(), lg, block, opfile) != block) { if (fwrite(colp->Max->GetValPointer(), lg, block, opfile) != block) {
sprintf(g->Message, MSG(OPT_MAX_WR_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_MAX_WR_ERR), strerror(errno));
rc = true; rc = true;
} // endif size } // endif size
@@ -1095,12 +1095,12 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
lg = sizeof(int); lg = sizeof(int);
if (fread(n, sizeof(int), NZ, opfile) != NZ) { if (fread(n, sizeof(int), NZ, opfile) != NZ) {
sprintf(g->Message, MSG(OPT_HEAD_RD_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_HEAD_RD_ERR), strerror(errno));
goto err; goto err;
} // endif size } // endif size
if (n[1] != lg || n[2] != nrec) { if (n[1] != lg || n[2] != nrec) {
sprintf(g->Message, MSG(OPT_NOT_MATCH), filename); snprintf(g->Message, sizeof(g->Message), MSG(OPT_NOT_MATCH), filename);
goto err; goto err;
} // endif } // endif
@@ -1111,7 +1111,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
defp->To_Pos = (int*)PlugSubAlloc(g, NULL, blk * lg); defp->To_Pos = (int*)PlugSubAlloc(g, NULL, blk * lg);
if (fread(defp->To_Pos, lg, blk, opfile) != blk) { if (fread(defp->To_Pos, lg, blk, opfile) != blk) {
sprintf(g->Message, MSG(OPTBLK_RD_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPTBLK_RD_ERR), strerror(errno));
goto err; goto err;
} // endif size } // endif size
@@ -1127,19 +1127,19 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
// Now start the reading process. // Now start the reading process.
if (fread(n, sizeof(int), NZ, opfile) != NZ) { if (fread(n, sizeof(int), NZ, opfile) != NZ) {
sprintf(g->Message, MSG(OPT_HEAD_RD_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_HEAD_RD_ERR), strerror(errno));
goto err; goto err;
} // endif size } // endif size
if (n[0] == -i) { if (n[0] == -i) {
// Read the XDB2 opt values from the opt file // Read the XDB2 opt values from the opt file
if (n[1] != lg || n[2] != nrec || n[3] != block) { if (n[1] != lg || n[2] != nrec || n[3] != block) {
sprintf(g->Message, MSG(OPT_NOT_MATCH), filename); snprintf(g->Message, sizeof(g->Message), MSG(OPT_NOT_MATCH), filename);
goto err; goto err;
} // endif } // endif
if (fread(n, sizeof(int), 2, opfile) != 2) { if (fread(n, sizeof(int), 2, opfile) != 2) {
sprintf(g->Message, MSG(OPT_HEAD_RD_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_HEAD_RD_ERR), strerror(errno));
goto err; goto err;
} // endif fread } // endif fread
@@ -1151,7 +1151,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
cdp->SetNdv((int)ndv); cdp->SetNdv((int)ndv);
if (fread(cdp->GetDval(), lg, ndv, opfile) != ndv) { if (fread(cdp->GetDval(), lg, ndv, opfile) != ndv) {
sprintf(g->Message, MSG(OPT_DVAL_RD_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_DVAL_RD_ERR), strerror(errno));
goto err; goto err;
} // endif size } // endif size
@@ -1161,7 +1161,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
cdp->SetNbm((int)nbm); cdp->SetNbm((int)nbm);
if (fread(cdp->GetBmap(), sizeof(int), nbk, opfile) != nbk) { if (fread(cdp->GetBmap(), sizeof(int), nbk, opfile) != nbk) {
sprintf(g->Message, MSG(OPT_BMAP_RD_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_BMAP_RD_ERR), strerror(errno));
goto err; goto err;
} // endif size } // endif size
@@ -1169,7 +1169,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
} else { } else {
// Read the Min/Max values from the opt file // Read the Min/Max values from the opt file
if (n[0] != i || n[1] != lg || n[2] != nrec || n[3] != block) { if (n[0] != i || n[1] != lg || n[2] != nrec || n[3] != block) {
sprintf(g->Message, MSG(OPT_NOT_MATCH), filename); snprintf(g->Message, sizeof(g->Message), MSG(OPT_NOT_MATCH), filename);
goto err; goto err;
} // endif } // endif
@@ -1177,7 +1177,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
cdp->SetMin(PlugSubAlloc(g, NULL, blk * lg)); cdp->SetMin(PlugSubAlloc(g, NULL, blk * lg));
if (fread(cdp->GetMin(), lg, blk, opfile) != blk) { if (fread(cdp->GetMin(), lg, blk, opfile) != blk) {
sprintf(g->Message, MSG(OPT_MIN_RD_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_MIN_RD_ERR), strerror(errno));
goto err; goto err;
} // endif size } // endif size
@@ -1185,7 +1185,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
cdp->SetMax(PlugSubAlloc(g, NULL, blk * lg)); cdp->SetMax(PlugSubAlloc(g, NULL, blk * lg));
if (fread(cdp->GetMax(), lg, blk, opfile) != blk) { if (fread(cdp->GetMax(), lg, blk, opfile) != blk) {
sprintf(g->Message, MSG(OPT_MAX_RD_ERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(OPT_MAX_RD_ERR), strerror(errno));
goto err; goto err;
} // endif size } // endif size
@@ -1488,7 +1488,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
if (conv) { if (conv) {
// The constant has not the good type and will not match // The constant has not the good type and will not match
// the block min/max values. Warn and abort. // the block min/max values. Warn and abort.
sprintf(g->Message, "Block opt: %s", MSG(VALTYPE_NOMATCH)); snprintf(g->Message, sizeof(g->Message), "Block opt: %s", MSG(VALTYPE_NOMATCH));
PushWarning(g, this); PushWarning(g, this);
return NULL; return NULL;
} // endif Conv } // endif Conv
@@ -1693,7 +1693,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
if (add && dfp->GetIndx()) { if (add && dfp->GetIndx()) {
for (sxp = dfp->GetIndx(); sxp; sxp = sxp->GetNext()) for (sxp = dfp->GetIndx(); sxp; sxp = sxp->GetNext())
if (!stricmp(sxp->GetName(), pxdf->GetName())) { if (!stricmp(sxp->GetName(), pxdf->GetName())) {
sprintf(g->Message, MSG(INDEX_YET_ON), pxdf->GetName(), Name); snprintf(g->Message, sizeof(g->Message), MSG(INDEX_YET_ON), pxdf->GetName(), Name);
return RC_FX; return RC_FX;
} else if (!sxp->GetNext()) } else if (!sxp->GetNext())
break; break;
@@ -1714,10 +1714,10 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
for (n = 0, xdp = pxdf; xdp; xdp = xdp->GetNext()) for (n = 0, xdp = pxdf; xdp; xdp = xdp->GetNext())
for (kdp = xdp->GetToKeyParts(); kdp; kdp = kdp->GetNext()) { for (kdp = xdp->GetToKeyParts(); kdp; kdp = kdp->GetNext()) {
if (!(colp = ColDB(g, kdp->GetName(), 0))) { if (!(colp = ColDB(g, kdp->GetName(), 0))) {
sprintf(g->Message, MSG(INDX_COL_NOTIN), kdp->GetName(), Name); snprintf(g->Message, sizeof(g->Message), MSG(INDX_COL_NOTIN), kdp->GetName(), Name);
goto err; goto err;
} else if (colp->GetResultType() == TYPE_DECIM) { } else if (colp->GetResultType() == TYPE_DECIM) {
sprintf(g->Message, "Decimal columns are not indexable yet"); snprintf(g->Message, sizeof(g->Message), "Decimal columns are not indexable yet");
goto err; goto err;
} // endif Type } // endif Type
@@ -1845,14 +1845,14 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
// Get the key column description list // Get the key column description list
for (k = 0, kdp = xdp->GetToKeyParts(); kdp; kdp = kdp->GetNext()) for (k = 0, kdp = xdp->GetToKeyParts(); kdp; kdp = kdp->GetNext())
if (!(colp = ColDB(g, kdp->GetName(), 0)) || colp->InitValue(g)) { if (!(colp = ColDB(g, kdp->GetName(), 0)) || colp->InitValue(g)) {
sprintf(g->Message, "Wrong column %s", kdp->GetName()); snprintf(g->Message, sizeof(g->Message), "Wrong column %s", kdp->GetName());
return true; return true;
} else } else
To_Key_Col[k++] = colp; To_Key_Col[k++] = colp;
#if defined(_DEBUG) #if defined(_DEBUG)
if (k != Knum) { if (k != Knum) {
sprintf(g->Message, "Key part number mismatch for %s", snprintf(g->Message, sizeof(g->Message), "Key part number mismatch for %s",
xdp->GetName()); xdp->GetName());
return 0; return 0;
} // endif k } // endif k
@@ -1953,7 +1953,7 @@ int TDBDOS::RowNumber(PGLOBAL g, bool)
/*******************************************************************/ /*******************************************************************/
/* Don't know how to retrieve RowID from file address. */ /* Don't know how to retrieve RowID from file address. */
/*******************************************************************/ /*******************************************************************/
sprintf(g->Message, MSG(NO_ROWID_FOR_AM), snprintf(g->Message, sizeof(g->Message), MSG(NO_ROWID_FOR_AM),
GetAmName(g, Txfp->GetAmType())); GetAmName(g, Txfp->GetAmType()));
return 0; return 0;
} else } else
@@ -2479,7 +2479,7 @@ bool DOSCOL::VarSize(void)
bool DOSCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) bool DOSCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
{ {
if (!(To_Val = value)) { if (!(To_Val = value)) {
sprintf(g->Message, MSG(VALUE_ERROR), Name); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_ERROR), Name);
return true; return true;
} else if (Buf_Type == value->GetType()) { } else if (Buf_Type == value->GetType()) {
// Values are of the (good) column type // Values are of the (good) column type
@@ -2498,7 +2498,7 @@ bool DOSCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
} else { } else {
// Values are not of the (good) column type // Values are not of the (good) column type
if (check) { if (check) {
sprintf(g->Message, MSG(TYPE_VALUE_ERR), Name, snprintf(g->Message, sizeof(g->Message), MSG(TYPE_VALUE_ERR), Name,
GetTypeName(Buf_Type), GetTypeName(value->GetType())); GetTypeName(Buf_Type), GetTypeName(value->GetType()));
return true; return true;
} // endif check } // endif check
@@ -2550,7 +2550,7 @@ void DOSCOL::ReadColumn(PGLOBAL g)
if (!tdbp->IsRead()) if (!tdbp->IsRead())
if ((rc = tdbp->ReadBuffer(g)) != RC_OK) { if ((rc = tdbp->ReadBuffer(g)) != RC_OK) {
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); snprintf(g->Message, sizeof(g->Message), MSG(INV_DEF_READ), rc);
throw 11; throw 11;
} // endif } // endif
@@ -2615,12 +2615,12 @@ void DOSCOL::ReadColumn(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, MSG(BAD_RECFM), tdbp->Ftype); snprintf(g->Message, sizeof(g->Message), MSG(BAD_RECFM), tdbp->Ftype);
throw 34; throw 34;
} // endswitch Ftype } // endswitch Ftype
if (err) { if (err) {
sprintf(g->Message, "Out of range value for column %s at row %d", snprintf(g->Message, sizeof(g->Message), "Out of range value for column %s at row %d",
Name, tdbp->RowNumber(g)); Name, tdbp->RowNumber(g));
PushWarning(g, tdbp); PushWarning(g, tdbp);
} // endif err } // endif err
@@ -2730,7 +2730,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
len = strlen(Buf); len = strlen(Buf);
break; break;
default: default:
sprintf(g->Message, "Invalid field format for column %s", Name); snprintf(g->Message, sizeof(g->Message), "Invalid field format for column %s", Name);
throw 31; throw 31;
} // endswitch BufType } // endswitch BufType
@@ -2744,7 +2744,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
if ((len = n) > field) { if ((len = n) > field) {
char *p = Value->GetCharString(Buf); char *p = Value->GetCharString(Buf);
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, field); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_TOO_LONG), p, Name, field);
throw 31; throw 31;
} else if (Dsp) } else if (Dsp)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
@@ -2772,7 +2772,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
/* Updating to be done only during the second pass (Status=true) */ /* Updating to be done only during the second pass (Status=true) */
/*******************************************************************/ /*******************************************************************/
if (Value->GetBinValue(p, Long, Status)) { if (Value->GetBinValue(p, Long, Status)) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG), snprintf(g->Message, sizeof(g->Message), MSG(BIN_F_TOO_LONG),
Name, Value->GetSize(), Long); Name, Value->GetSize(), Long);
throw 31; throw 31;
} // endif } // endif
@@ -2832,11 +2832,11 @@ bool DOSCOL::SetBitMap(PGLOBAL g)
if ((i = Dval->Find(Value)) < 0) { if ((i = Dval->Find(Value)) < 0) {
char buf[32]; char buf[32];
sprintf(g->Message, MSG(DVAL_NOTIN_LIST), snprintf(g->Message, sizeof(g->Message), MSG(DVAL_NOTIN_LIST),
Value->GetCharString(buf), Name); Value->GetCharString(buf), Name);
return true; return true;
} else if (i >= dup->Maxbmp) { } else if (i >= dup->Maxbmp) {
sprintf(g->Message, MSG(OPT_LOGIC_ERR), i); snprintf(g->Message, sizeof(g->Message), MSG(OPT_LOGIC_ERR), i);
return true; return true;
} else { } else {
m = i / MAXBMP; m = i / MAXBMP;
@@ -2859,7 +2859,7 @@ bool DOSCOL::CheckSorted(PGLOBAL g)
// Verify whether this column is sorted all right // Verify whether this column is sorted all right
if (OldVal->CompareValue(Value) > 0) { if (OldVal->CompareValue(Value) > 0) {
// Column is no more in ascending order // Column is no more in ascending order
sprintf(g->Message, MSG(COL_NOT_SORTED), Name, To_Tdb->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(COL_NOT_SORTED), Name, To_Tdb->GetName());
Sorted = false; Sorted = false;
return true; return true;
} else } else
@@ -2900,7 +2900,7 @@ bool DOSCOL::AddDistinctValue(PGLOBAL g)
// Check whether we have room for an additional value // Check whether we have room for an additional value
if (Ndv == Freq) { if (Ndv == Freq) {
// Too many values because of wrong Freq setting // Too many values because of wrong Freq setting
sprintf(g->Message, MSG(BAD_FREQ_SET), Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FREQ_SET), Name);
return true; return true;
} // endif Ndv } // endif Ndv

View File

@@ -613,7 +613,7 @@ bool TDBEXT::MakeCommand(PGLOBAL g)
strcat(stmt, body); strcat(stmt, body);
} else { } else {
sprintf(g->Message, "Cannot use this %s command", snprintf(g->Message, sizeof(g->Message), "Cannot use this %s command",
(Mode == MODE_UPDATE) ? "UPDATE" : "DELETE"); (Mode == MODE_UPDATE) ? "UPDATE" : "DELETE");
return true; return true;
} // endif p } // endif p
@@ -724,7 +724,7 @@ EXTCOL::EXTCOL(PEXTCOL col1, PTDB tdbp) : COLBLK(col1, tdbp)
bool EXTCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) bool EXTCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
{ {
if (!(To_Val = value)) { if (!(To_Val = value)) {
sprintf(g->Message, MSG(VALUE_ERROR), Name); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_ERROR), Name);
return true; return true;
} else if (Buf_Type == value->GetType()) { } else if (Buf_Type == value->GetType()) {
// Values are of the (good) column type // Values are of the (good) column type
@@ -743,7 +743,7 @@ bool EXTCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
} else { } else {
// Values are not of the (good) column type // Values are not of the (good) column type
if (check) { if (check) {
sprintf(g->Message, MSG(TYPE_VALUE_ERR), Name, snprintf(g->Message, sizeof(g->Message), MSG(TYPE_VALUE_ERR), Name,
GetTypeName(Buf_Type), GetTypeName(value->GetType())); GetTypeName(Buf_Type), GetTypeName(value->GetType()));
return true; return true;
} // endif check } // endif check

View File

@@ -258,7 +258,7 @@ int TDBFIX::RowNumber(PGLOBAL g, bool b)
/* Don't know how to retrieve Rows from DBF file address */ /* Don't know how to retrieve Rows from DBF file address */
/* because of eventual deleted lines still in the file. */ /* because of eventual deleted lines still in the file. */
/*****************************************************************/ /*****************************************************************/
sprintf(g->Message, MSG(NO_ROWID_FOR_AM), snprintf(g->Message, sizeof(g->Message), MSG(NO_ROWID_FOR_AM),
GetAmName(g, Txfp->GetAmType())); GetAmName(g, Txfp->GetAmType()));
return 0; return 0;
} // endif To_Kindex } // endif To_Kindex
@@ -410,7 +410,7 @@ BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PCSZ am)
case 'F': M = sizeof(float); break; case 'F': M = sizeof(float); break;
case 'D': M = sizeof(double); break; case 'D': M = sizeof(double); break;
default: default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_BIN_FMT), Fmt, Name);
throw 11; throw 11;
} // endswitch Fmt } // endswitch Fmt
@@ -484,7 +484,7 @@ void BINCOL::ReadColumn(PGLOBAL g)
if (!tdbp->IsRead()) if (!tdbp->IsRead())
if ((rc = tdbp->ReadBuffer(g)) != RC_OK) { if ((rc = tdbp->ReadBuffer(g)) != RC_OK) {
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); snprintf(g->Message, sizeof(g->Message), MSG(INV_DEF_READ), rc);
throw 11; throw 11;
} // endif } // endif
@@ -537,14 +537,14 @@ void BINCOL::ReadColumn(PGLOBAL g)
break; break;
case 'C': // Text case 'C': // Text
if (Value->SetValue_char(p, Long)) { if (Value->SetValue_char(p, Long)) {
sprintf(g->Message, "Out of range value for column %s at row %d", snprintf(g->Message, sizeof(g->Message), "Out of range value for column %s at row %d",
Name, tdbp->RowNumber(g)); Name, tdbp->RowNumber(g));
PushWarning(g, tdbp); PushWarning(g, tdbp);
} // endif SetValue_char } // endif SetValue_char
break; break;
default: default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_BIN_FMT), Fmt, Name);
throw 11; throw 11;
} // endswitch Fmt } // endswitch Fmt
@@ -593,7 +593,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
if (Status) if (Status)
Value->GetValueNonAligned<longlong>(p, Value->GetBigintValue()); Value->GetValueNonAligned<longlong>(p, Value->GetBigintValue());
} else if (Value->GetBinValue(p, Long, Status)) { } else if (Value->GetBinValue(p, Long, Status)) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG), snprintf(g->Message, sizeof(g->Message), MSG(BIN_F_TOO_LONG),
Name, Value->GetSize(), Long); Name, Value->GetSize(), Long);
throw 31; throw 31;
} // endif p } // endif p
@@ -603,7 +603,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
n = Value->GetBigintValue(); n = Value->GetBigintValue();
if (n > 32767LL || n < -32768LL) { if (n > 32767LL || n < -32768LL) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_TOO_BIG), n, Name);
throw 31; throw 31;
} else if (Status) } else if (Status)
Value->GetValueNonAligned<short>(p, (short)n); Value->GetValueNonAligned<short>(p, (short)n);
@@ -613,7 +613,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
n = Value->GetBigintValue(); n = Value->GetBigintValue();
if (n > 255LL || n < -256LL) { if (n > 255LL || n < -256LL) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_TOO_BIG), n, Name);
throw 31; throw 31;
} else if (Status) } else if (Status)
*p = (char)n; *p = (char)n;
@@ -623,7 +623,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
n = Value->GetBigintValue(); n = Value->GetBigintValue();
if (n > INT_MAX || n < INT_MIN) { if (n > INT_MAX || n < INT_MIN) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_TOO_BIG), n, Name);
throw 31; throw 31;
} else if (Status) } else if (Status)
Value->GetValueNonAligned<int>(p, (int)n); Value->GetValueNonAligned<int>(p, (int)n);
@@ -647,7 +647,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
break; break;
case 'C': // Characters case 'C': // Characters
if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) { if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long); snprintf(g->Message, sizeof(g->Message), MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
throw 31; throw 31;
} // endif n } // endif n
@@ -659,7 +659,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_BIN_FMT), Fmt, Name);
throw 31; throw 31;
} // endswitch Fmt } // endswitch Fmt

View File

@@ -230,7 +230,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
colname[0] = p; colname[0] = p;
} else if (rc == RC_EF) { } else if (rc == RC_EF) {
sprintf(g->Message, MSG(FILE_IS_EMPTY), fn); snprintf(g->Message, sizeof(g->Message), MSG(FILE_IS_EMPTY), fn);
goto err; goto err;
} else } else
goto err; goto err;
@@ -269,10 +269,10 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
/*******************************************************************/ /*******************************************************************/
if ((rc = tdbp->ReadDB(g)) == RC_OK) { if ((rc = tdbp->ReadDB(g)) == RC_OK) {
} else if (rc == RC_EF) { } else if (rc == RC_EF) {
sprintf(g->Message, MSG(EOF_AFTER_LINE), num_read -1); snprintf(g->Message, sizeof(g->Message), MSG(EOF_AFTER_LINE), num_read -1);
break; break;
} else { } else {
sprintf(g->Message, MSG(ERR_READING_REC), num_read, fn); snprintf(g->Message, sizeof(g->Message), MSG(ERR_READING_REC), num_read, fn);
goto err; goto err;
} // endif's } // endif's
@@ -285,7 +285,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
if (*p == sep) { if (*p == sep) {
if (phase != 1) { if (phase != 1) {
if (i == MAXCOL - 1) { if (i == MAXCOL - 1) {
sprintf(g->Message, MSG(TOO_MANY_FIELDS), num_read, fn); snprintf(g->Message, sizeof(g->Message), MSG(TOO_MANY_FIELDS), num_read, fn);
goto err; goto err;
} // endif i } // endif i
@@ -313,7 +313,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
if (phase == 0) { if (phase == 0) {
if (blank) { if (blank) {
if (++nerr > mxr) { if (++nerr > mxr) {
sprintf(g->Message, MSG(MISPLACED_QUOTE), num_read); snprintf(g->Message, sizeof(g->Message), MSG(MISPLACED_QUOTE), num_read);
goto err; goto err;
} else } else
goto skip; goto skip;
@@ -325,7 +325,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
if (*(p+1) == q) { if (*(p+1) == q) {
// This is currently not implemented for CSV tables // This is currently not implemented for CSV tables
// if (++nerr > mxr) { // if (++nerr > mxr) {
// sprintf(g->Message, MSG(QUOTE_IN_QUOTE), num_read); // snprintf(g->Message, sizeof(g->Message), MSG(QUOTE_IN_QUOTE), num_read);
// goto err; // goto err;
// } else // } else
// goto skip; // goto skip;
@@ -336,7 +336,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
phase = 2; phase = 2;
} else if (++nerr > mxr) { // phase == 2 } else if (++nerr > mxr) { // phase == 2
sprintf(g->Message, MSG(MISPLACED_QUOTE), num_read); snprintf(g->Message, sizeof(g->Message), MSG(MISPLACED_QUOTE), num_read);
goto err; goto err;
} else } else
goto skip; goto skip;
@@ -344,7 +344,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
} else { } else {
if (phase == 2) { if (phase == 2) {
if (++nerr > mxr) { if (++nerr > mxr) {
sprintf(g->Message, MSG(MISPLACED_QUOTE), num_read); snprintf(g->Message, sizeof(g->Message), MSG(MISPLACED_QUOTE), num_read);
goto err; goto err;
} else } else
goto skip; goto skip;
@@ -366,7 +366,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
if (phase == 1) { if (phase == 1) {
if (++nerr > mxr) { if (++nerr > mxr) {
sprintf(g->Message, MSG(UNBALANCE_QUOTE), num_read); snprintf(g->Message, sizeof(g->Message), MSG(UNBALANCE_QUOTE), num_read);
goto err; goto err;
} else } else
goto skip; goto skip;
@@ -583,7 +583,7 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
((PZLBFAM)txfp)->SetOptimized(To_Pos != NULL); ((PZLBFAM)txfp)->SetOptimized(To_Pos != NULL);
} // endelse } // endelse
#else #else
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif #endif
} else } else
@@ -865,7 +865,7 @@ bool TDBCSV::SkipHeader(PGLOBAL g)
} // endfor cdp } // endfor cdp
if (hlen > Lrecl) { if (hlen > Lrecl) {
sprintf(g->Message, MSG(LRECL_TOO_SMALL), hlen); snprintf(g->Message, sizeof(g->Message), MSG(LRECL_TOO_SMALL), hlen);
return true; return true;
} // endif hlen } // endif hlen
@@ -949,7 +949,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g)
if (*p != Sep && i != Fields - 1) { // Should be the separator if (*p != Sep && i != Fields - 1) { // Should be the separator
if (CheckErr()) { if (CheckErr()) {
sprintf(g->Message, MSG(MISSING_FIELD), snprintf(g->Message, sizeof(g->Message), MSG(MISSING_FIELD),
i+1, Name, RowNumber(g)); i+1, Name, RowNumber(g));
return RC_FX; return RC_FX;
} else if (Accept) } else if (Accept)
@@ -976,7 +976,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g)
} // endif n } // endif n
} else if (CheckErr()) { } else if (CheckErr()) {
sprintf(g->Message, MSG(BAD_QUOTE_FIELD), snprintf(g->Message, sizeof(g->Message), MSG(BAD_QUOTE_FIELD),
Name, i+1, RowNumber(g)); Name, i+1, RowNumber(g));
return RC_FX; return RC_FX;
} else if (Accept) { } else if (Accept) {
@@ -993,7 +993,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g)
len = strlen(p2); len = strlen(p2);
bad = true; bad = true;
} else if (CheckErr()) { } else if (CheckErr()) {
sprintf(g->Message, MSG(MISSING_FIELD), i+1, Name, RowNumber(g)); snprintf(g->Message, sizeof(g->Message), MSG(MISSING_FIELD), i+1, Name, RowNumber(g));
return RC_FX; return RC_FX;
} else if (Accept) { } else if (Accept) {
len = strlen(p2); len = strlen(p2);
@@ -1009,7 +1009,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g)
if (Mode != MODE_UPDATE) if (Mode != MODE_UPDATE)
Fldlen[i] = len; Fldlen[i] = len;
else if (len > Fldlen[i]) { else if (len > Fldlen[i]) {
sprintf(g->Message, MSG(FIELD_TOO_LONG), i+1, RowNumber(g)); snprintf(g->Message, sizeof(g->Message), MSG(FIELD_TOO_LONG), i+1, RowNumber(g));
return RC_FX; return RC_FX;
} else { } else {
strncpy(Field[i], p2, len); strncpy(Field[i], p2, len);
@@ -1143,7 +1143,7 @@ int TDBCSV::CheckWrite(PGLOBAL g)
else if (strchr(Field[i], Sep) || (Qot && *Field[i] == Qot) else if (strchr(Field[i], Sep) || (Qot && *Field[i] == Qot)
|| Quoted > 1 || (Quoted == 1 && !Fldtyp[i])) || Quoted > 1 || (Quoted == 1 && !Fldtyp[i]))
if (!Qot) { if (!Qot) {
sprintf(g->Message, MSG(SEP_IN_FIELD), i + 1); snprintf(g->Message, sizeof(g->Message), MSG(SEP_IN_FIELD), i + 1);
return -1; return -1;
} else { } else {
// Quotes inside a quoted field must be doubled // Quotes inside a quoted field must be doubled
@@ -1225,7 +1225,7 @@ bool TDBFMT::OpenDB(PGLOBAL g)
Linenum = 0; Linenum = 0;
if (Mode == MODE_INSERT || Mode == MODE_UPDATE) { if (Mode == MODE_INSERT || Mode == MODE_UPDATE) {
sprintf(g->Message, MSG(FMT_WRITE_NIY), "FMT"); snprintf(g->Message, sizeof(g->Message), MSG(FMT_WRITE_NIY), "FMT");
return true; // NIY return true; // NIY
} // endif Mode } // endif Mode
@@ -1255,13 +1255,13 @@ bool TDBFMT::OpenDB(PGLOBAL g)
if (!cdp->IsSpecial() && !cdp->IsVirtual() if (!cdp->IsSpecial() && !cdp->IsVirtual()
&& (i = cdp->GetOffset() - 1) < Fields) { && (i = cdp->GetOffset() - 1) < Fields) {
if (!(pfm = cdp->GetFmt())) { if (!(pfm = cdp->GetFmt())) {
sprintf(g->Message, MSG(NO_FLD_FORMAT), i + 1, Name); snprintf(g->Message, sizeof(g->Message), MSG(NO_FLD_FORMAT), i + 1, Name);
return true; return true;
} // endif pfm } // endif pfm
// Roughly check the Fmt format // Roughly check the Fmt format
if ((n = strlen(pfm) - 2) < 4) { if ((n = strlen(pfm) - 2) < 4) {
sprintf(g->Message, MSG(BAD_FLD_FORMAT), i + 1, Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FLD_FORMAT), i + 1, Name);
return true; return true;
} // endif n } // endif n
@@ -1338,7 +1338,7 @@ int TDBFMT::ReadBuffer(PGLOBAL g)
sscanf("a", "%*c"); // Seems to reset things Ok sscanf("a", "%*c"); // Seems to reset things Ok
if (CheckErr()) { if (CheckErr()) {
sprintf(g->Message, MSG(BAD_LINEFLD_FMT), Linenum, i + 1, Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_LINEFLD_FMT), Linenum, i + 1, Name);
return RC_FX; return RC_FX;
} else if (Accept) } else if (Accept)
bad = true; bad = true;
@@ -1361,7 +1361,7 @@ int TDBFMT::ReadBuffer(PGLOBAL g)
// if (Mode != MODE_UPDATE) // if (Mode != MODE_UPDATE)
Fldlen[i] = len; Fldlen[i] = len;
// else if (len > Fldlen[i]) { // else if (len > Fldlen[i]) {
// sprintf(g->Message, MSG(FIELD_TOO_LONG), i+1, To_Tdb->RowNumber(g)); // snprintf(g->Message, sizeof(g->Message), MSG(FIELD_TOO_LONG), i+1, To_Tdb->RowNumber(g));
// return RC_FX; // return RC_FX;
// } else { // } else {
// strncpy(Field[i], To_Line + pos, len); // strncpy(Field[i], To_Line + pos, len);
@@ -1384,7 +1384,7 @@ int TDBFMT::ReadBuffer(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int TDBFMT::WriteDB(PGLOBAL g) int TDBFMT::WriteDB(PGLOBAL g)
{ {
sprintf(g->Message, MSG(FMT_WRITE_NIY), "FMT"); snprintf(g->Message, sizeof(g->Message), MSG(FMT_WRITE_NIY), "FMT");
return RC_FX; // NIY return RC_FX; // NIY
} // end of WriteDB } // end of WriteDB
@@ -1443,7 +1443,7 @@ void CSVCOL::ReadColumn(PGLOBAL g)
if (!tdbp->IsRead()) if (!tdbp->IsRead())
if ((rc = tdbp->ReadBuffer(g)) != RC_OK) { if ((rc = tdbp->ReadBuffer(g)) != RC_OK) {
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); snprintf(g->Message, sizeof(g->Message), MSG(INV_DEF_READ), rc);
throw 34; throw 34;
} // endif } // endif
@@ -1461,7 +1461,7 @@ void CSVCOL::ReadColumn(PGLOBAL g)
if (Long > colen && tdbp->CheckErr()) { if (Long > colen && tdbp->CheckErr()) {
Long = colen; // Restore column length Long = colen; // Restore column length
sprintf(g->Message, MSG(FLD_TOO_LNG_FOR), snprintf(g->Message, sizeof(g->Message), MSG(FLD_TOO_LNG_FOR),
Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g)); Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g));
throw 34; throw 34;
} // endif Long } // endif Long
@@ -1525,7 +1525,7 @@ void CSVCOL::WriteColumn(PGLOBAL g)
htrc("new length(%p)=%d\n", p, n); htrc("new length(%p)=%d\n", p, n);
if (n > flen) { if (n > flen) {
sprintf(g->Message, MSG(BAD_FLD_LENGTH), Name, p, n, snprintf(g->Message, sizeof(g->Message), MSG(BAD_FLD_LENGTH), Name, p, n,
tdbp->RowNumber(g), tdbp->GetFile(g)); tdbp->RowNumber(g), tdbp->GetFile(g));
throw 34; throw 34;
} else if (Dsp) } else if (Dsp)
@@ -1542,7 +1542,7 @@ void CSVCOL::WriteColumn(PGLOBAL g)
/*********************************************************************/ /*********************************************************************/
if (Fldnum < 0) { if (Fldnum < 0) {
// This can happen for wrong offset value in XDB files // This can happen for wrong offset value in XDB files
sprintf(g->Message, MSG(BAD_FIELD_RANK), Fldnum + 1, Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FIELD_RANK), Fldnum + 1, Name);
throw 34; throw 34;
} else } else
strncpy(tdbp->Field[Fldnum], p, flen); strncpy(tdbp->Field[Fldnum], p, flen);

View File

@@ -163,7 +163,7 @@ class DllExport TDBFMT : public TDBCSV {
protected: protected:
virtual bool PrepareWriting(PGLOBAL g) virtual bool PrepareWriting(PGLOBAL g)
{sprintf(g->Message, MSG(TABLE_READ_ONLY), "FMT"); return true;} {snprintf(g->Message, sizeof(g->Message), MSG(TABLE_READ_ONLY), "FMT"); return true;}
// Members // Members
PSZ *FldFormat; // Field read format PSZ *FldFormat; // Field read format

View File

@@ -159,7 +159,7 @@ int JDBCDEF::ParseURL(PGLOBAL g, char *url, bool b)
// get_server_by_name() clones the server if exists // get_server_by_name() clones the server if exists
if (!(server= get_server_by_name(current_thd->mem_root, url, &server_buffer))) { if (!(server= get_server_by_name(current_thd->mem_root, url, &server_buffer))) {
sprintf(g->Message, "Server %s does not exist!", url); snprintf(g->Message, sizeof(g->Message), "Server %s does not exist!", url);
return RC_FX; return RC_FX;
} // endif server } // endif server
@@ -224,7 +224,7 @@ bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Url = GetStringCatInfo(g, "Url", NULL); Url = GetStringCatInfo(g, "Url", NULL);
if (!Url) { if (!Url) {
sprintf(g->Message, "Missing URL for JDBC table %s", Name); snprintf(g->Message, sizeof(g->Message), "Missing URL for JDBC table %s", Name);
return true; return true;
} // endif Url } // endif Url
@@ -232,7 +232,7 @@ bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if (Url) if (Url)
if ((rc = ParseURL(g, Url)) == RC_FX) { if ((rc = ParseURL(g, Url)) == RC_FX) {
sprintf(g->Message, "Wrong JDBC URL %s", Url); snprintf(g->Message, sizeof(g->Message), "Wrong JDBC URL %s", Url);
return true; return true;
} // endif rc } // endif rc
@@ -646,7 +646,7 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
if ((n = Jcp->GetResultSize(Query->GetStr(), Cnp)) < 0) { if ((n = Jcp->GetResultSize(Query->GetStr(), Cnp)) < 0) {
char* msg = PlugDup(g, g->Message); char* msg = PlugDup(g, g->Message);
sprintf(g->Message, "Get result size: %s (rc=%d)", msg, n); snprintf(g->Message, sizeof(g->Message), "Get result size: %s (rc=%d)", msg, n);
return true; return true;
} else if (n) { } else if (n) {
Jcp->m_Rows = n; Jcp->m_Rows = n;
@@ -692,7 +692,7 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
} else if (Mode == MODE_UPDATE || Mode == MODE_DELETE) { } else if (Mode == MODE_UPDATE || Mode == MODE_DELETE) {
rc = false; // wait for CheckCond before calling MakeCommand(g); rc = false; // wait for CheckCond before calling MakeCommand(g);
} else } else
sprintf(g->Message, "Invalid mode %d", Mode); snprintf(g->Message, sizeof(g->Message), "Invalid mode %d", Mode);
if (rc) { if (rc) {
Jcp->Close(); Jcp->Close();
@@ -949,7 +949,7 @@ int TDBJDBC::DeleteDB(PGLOBAL g, int irc)
// Send the DELETE (all) command to the remote table // Send the DELETE (all) command to the remote table
if (Jcp->ExecuteUpdate(Query->GetStr()) == RC_OK) { if (Jcp->ExecuteUpdate(Query->GetStr()) == RC_OK) {
AftRows = Jcp->m_Aff; AftRows = Jcp->m_Aff;
sprintf(g->Message, "%s: %d affected rows", TableName, AftRows); snprintf(g->Message, sizeof(g->Message), "%s: %d affected rows", TableName, AftRows);
if (trace(1)) if (trace(1))
htrc("%s\n", g->Message); htrc("%s\n", g->Message);
@@ -977,7 +977,7 @@ void TDBJDBC::CloseDB(PGLOBAL g)
if (!Werr && if (!Werr &&
(Mode == MODE_INSERT || Mode == MODE_UPDATE || Mode == MODE_DELETE)) { (Mode == MODE_INSERT || Mode == MODE_UPDATE || Mode == MODE_DELETE)) {
sprintf(g->Message, "%s: %d affected rows", TableName, AftRows); snprintf(g->Message, sizeof(g->Message), "%s: %d affected rows", TableName, AftRows);
if (trace(1)) if (trace(1))
htrc("%s\n", g->Message); htrc("%s\n", g->Message);

View File

@@ -96,7 +96,7 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
n = Jcp->env->GetIntArrayElements(val, 0); n = Jcp->env->GetIntArrayElements(val, 0);
if (Jcp->Check(n[0])) { if (Jcp->Check(n[0])) {
sprintf(g->Message, "ColDesc: %s", Jcp->Msg); snprintf(g->Message, sizeof(g->Message), "ColDesc: %s", Jcp->Msg);
goto err; goto err;
} else if (!n[0]) } else if (!n[0])
continue; continue;
@@ -526,7 +526,7 @@ char *JMGCOL::Mini(PGLOBAL g, const bson_t *bson, bool b)
bson_free(str); bson_free(str);
if (i >= Long) { if (i >= Long) {
sprintf(g->Message, "Value too long for column %s", Name); snprintf(g->Message, sizeof(g->Message), "Value too long for column %s", Name);
throw (int)TYPE_AM_MGO; throw (int)TYPE_AM_MGO;
} // endif i } // endif i
@@ -596,7 +596,7 @@ bool JMGCOL::AddValue(PGLOBAL g, bson_t *doc, char *key, bool upd)
rc = BSON_APPEND_DATE_TIME(doc, key, Value->GetBigintValue() * 1000); rc = BSON_APPEND_DATE_TIME(doc, key, Value->GetBigintValue() * 1000);
break; break;
default: default:
sprintf(g->Message, "Type %d not supported yet", Buf_Type); snprintf(g->Message, sizeof(g->Message), "Type %d not supported yet", Buf_Type);
return true; return true;
} // endswitch Buf_Type } // endswitch Buf_Type

View File

@@ -239,7 +239,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
(tdp->Version == 2) ? "Mongo2Interface" : "Mongo3Interface"); (tdp->Version == 2) ? "Mongo2Interface" : "Mongo3Interface");
tdp->Pretty = 0; tdp->Pretty = 0;
#else // !MONGO_SUPPORT #else // !MONGO_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "MONGO");
return 0; return 0;
#endif // !MONGO_SUPPORT #endif // !MONGO_SUPPORT
} // endif Uri } // endif Uri
@@ -249,7 +249,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
tjsp = new(g) TDBJSON(tdp, new(g) UNZFAM(tdp)); tjsp = new(g) TDBJSON(tdp, new(g) UNZFAM(tdp));
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "ZIP");
return 0; return 0;
#endif // !ZIP_SUPPORT #endif // !ZIP_SUPPORT
} else } else
@@ -262,7 +262,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
} else { } else {
if (!((tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0)))) { if (!((tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0)))) {
if (!mgo && !tdp->Uri) { if (!mgo && !tdp->Uri) {
sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty); snprintf(g->Message, sizeof(g->Message), "LRECL must be specified for pretty=%d", tdp->Pretty);
return 0; return 0;
} else } else
tdp->Lrecl = 8192; // Should be enough tdp->Lrecl = 8192; // Should be enough
@@ -275,7 +275,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
tjnp = new(g)TDBJSN(tdp, new(g) UNZFAM(tdp)); tjnp = new(g)TDBJSN(tdp, new(g) UNZFAM(tdp));
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "ZIP");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !ZIP_SUPPORT
} else if (tdp->Uri) { } else if (tdp->Uri) {
@@ -283,14 +283,14 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
#if defined(CMGO_SUPPORT) #if defined(CMGO_SUPPORT)
tjnp = new(g) TDBJSN(tdp, new(g) CMGFAM(tdp)); tjnp = new(g) TDBJSN(tdp, new(g) CMGFAM(tdp));
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "C"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "C");
return 0; return 0;
#endif #endif
} else if (tdp->Driver && toupper(*tdp->Driver) == 'J') { } else if (tdp->Driver && toupper(*tdp->Driver) == 'J') {
#if defined(JAVA_SUPPORT) #if defined(JAVA_SUPPORT)
tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp)); tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp));
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "Java"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "Java");
return 0; return 0;
#endif #endif
} else { // Driver not specified } else { // Driver not specified
@@ -299,7 +299,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
#elif defined(JAVA_SUPPORT) #elif defined(JAVA_SUPPORT)
tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp)); tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp));
#else #else
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "MONGO");
return 0; return 0;
#endif #endif
} // endif Driver } // endif Driver
@@ -513,7 +513,7 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
return false; return false;
default: default:
sprintf(g->Message, "Logical error after %s", fmt); snprintf(g->Message, sizeof(g->Message), "Logical error after %s", fmt);
return true; return true;
} // endswitch Type } // endswitch Type
@@ -671,7 +671,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Wrapname = GetStringCatInfo(g, "Wrapper", "Mongo3Interface"); Wrapname = GetStringCatInfo(g, "Wrapper", "Mongo3Interface");
#endif // JAVA_SUPPORT #endif // JAVA_SUPPORT
#else // !MONGO_SUPPORT #else // !MONGO_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "MONGO");
return true; return true;
#endif // !MONGO_SUPPORT #endif // !MONGO_SUPPORT
} // endif Uri } // endif Uri
@@ -706,14 +706,14 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
#if defined(CMGO_SUPPORT) #if defined(CMGO_SUPPORT)
txfp = new(g) CMGFAM(this); txfp = new(g) CMGFAM(this);
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "C"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "C");
return NULL; return NULL;
#endif #endif
} else if (Driver && toupper(*Driver) == 'J') { } else if (Driver && toupper(*Driver) == 'J') {
#if defined(JAVA_SUPPORT) #if defined(JAVA_SUPPORT)
txfp = new(g) JMGFAM(this); txfp = new(g) JMGFAM(this);
#else #else
sprintf(g->Message, "Mongo %s Driver not available", "Java"); snprintf(g->Message, sizeof(g->Message), "Mongo %s Driver not available", "Java");
return NULL; return NULL;
#endif #endif
} else { // Driver not specified } else { // Driver not specified
@@ -722,7 +722,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
#elif defined(JAVA_SUPPORT) #elif defined(JAVA_SUPPORT)
txfp = new(g) JMGFAM(this); txfp = new(g) JMGFAM(this);
#else // !MONGO_SUPPORT #else // !MONGO_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "MONGO");
return NULL; return NULL;
#endif // !MONGO_SUPPORT #endif // !MONGO_SUPPORT
} // endif Driver } // endif Driver
@@ -739,7 +739,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
return NULL; return NULL;
} // endif's m } // endif's m
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "ZIP");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !ZIP_SUPPORT
} else if (Compressed) { } else if (Compressed) {
@@ -749,7 +749,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
else else
txfp = new(g) ZLBFAM(this); txfp = new(g) ZLBFAM(this);
#else // !GZ_SUPPORT #else // !GZ_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif // !GZ_SUPPORT #endif // !GZ_SUPPORT
} else if (map) } else if (map)
@@ -792,7 +792,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
return NULL; return NULL;
} // endif's m } // endif's m
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); snprintf(g->Message, sizeof(g->Message), MSG(NO_FEAT_SUPPORT), "ZIP");
return NULL; return NULL;
#endif // !ZIP_SUPPORT #endif // !ZIP_SUPPORT
} else } else
@@ -980,7 +980,7 @@ PJSON TDBJSN::FindRow(PGLOBAL g)
} else { } else {
if (bp || *objpath == '[') { if (bp || *objpath == '[') {
if (objpath[strlen(objpath) - 1] != ']') { if (objpath[strlen(objpath) - 1] != ']') {
sprintf(g->Message, "Invalid Table path %s", Objname); snprintf(g->Message, sizeof(g->Message), "Invalid Table path %s", Objname);
return NULL; return NULL;
} else if (!bp) } else if (!bp)
objpath++; objpath++;
@@ -1031,7 +1031,7 @@ bool TDBJSN::OpenDB(PGLOBAL g)
case MODE_ARRAY: Row = new(g) JARRAY; break; case MODE_ARRAY: Row = new(g) JARRAY; break;
case MODE_VALUE: Row = new(g) JVALUE; break; case MODE_VALUE: Row = new(g) JVALUE; break;
default: default:
sprintf(g->Message, "Invalid Jmode %d", Jmode); snprintf(g->Message, sizeof(g->Message), "Invalid Jmode %d", Jmode);
return true; return true;
} // endswitch Jmode } // endswitch Jmode
@@ -1210,7 +1210,7 @@ bool TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
if (bp || *objpath == '[') { if (bp || *objpath == '[') {
// Old style // Old style
if (objpath[strlen(objpath) - 1] != ']') { if (objpath[strlen(objpath) - 1] != ']') {
sprintf(g->Message, "Invalid Table path %s", Objname); snprintf(g->Message, sizeof(g->Message), "Invalid Table path %s", Objname);
return true; return true;
} else if (!bp) } else if (!bp)
objpath++; objpath++;
@@ -1259,7 +1259,7 @@ bool TDBJSN::PrepareWriting(PGLOBAL g)
if ((signed)strlen(s) > Lrecl) { if ((signed)strlen(s) > Lrecl) {
strncpy(To_Line, s, Lrecl); strncpy(To_Line, s, Lrecl);
sprintf(g->Message, "Line truncated (lrecl=%d)", Lrecl); snprintf(g->Message, sizeof(g->Message), "Line truncated (lrecl=%d)", Lrecl);
return PushWarning(g, this); return PushWarning(g, this);
} else } else
strcpy(To_Line, s); strcpy(To_Line, s);
@@ -1443,7 +1443,7 @@ bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
break; break;
default: default:
sprintf(g->Message, snprintf(g->Message, sizeof(g->Message),
"Invalid function specification %c for %s", *p, Name); "Invalid function specification %c for %s", *p, Name);
return true; return true;
} // endswitch *p } // endswitch *p
@@ -1459,7 +1459,7 @@ bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
} // endif n } // endif n
} else { } else {
sprintf(g->Message, "Wrong array specification for %s", Name); snprintf(g->Message, sizeof(g->Message), "Wrong array specification for %s", Name);
return true; return true;
} // endif's } // endif's
@@ -1528,7 +1528,7 @@ bool JSONCOL::ParseJpath(PGLOBAL g)
goto fin; goto fin;
} // endif Name } // endif Name
sprintf(g->Message, "Cannot parse updated column %s", Name); snprintf(g->Message, sizeof(g->Message), "Cannot parse updated column %s", Name);
return true; return true;
} // endif To_Orig } // endif To_Orig
@@ -1742,7 +1742,7 @@ PJVAL JSONCOL::GetRowValue(PGLOBAL g, PJSON row, int i)
val = (PJVAL)row; val = (PJVAL)row;
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->GetType()); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->GetType());
val = NULL; val = NULL;
} // endswitch Type } // endswitch Type
@@ -1804,7 +1804,7 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL jvp)
break; break;
default: default:
sprintf(g->Message, "Unsupported column type %d\n", vp->GetType()); snprintf(g->Message, sizeof(g->Message), "Unsupported column type %d\n", vp->GetType());
throw 888; throw 888;
} // endswitch Type } // endswitch Type
@@ -1905,7 +1905,7 @@ PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i)
val = (PJVAL)row; val = (PJVAL)row;
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->GetType()); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->GetType());
val = NULL; val = NULL;
} // endswitch Type } // endswitch Type
@@ -2100,7 +2100,7 @@ PJSON JSONCOL::GetRow(PGLOBAL g)
val = (PJVAL)row; val = (PJVAL)row;
break; break;
default: default:
sprintf(g->Message, "Invalid row JSON type %d", row->GetType()); snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->GetType());
val = NULL; val = NULL;
} // endswitch Type } // endswitch Type
@@ -2227,7 +2227,7 @@ void JSONCOL::WriteColumn(PGLOBAL g)
break; break;
default: // ?????????? default: // ??????????
sprintf(g->Message, "Invalid column type %d", Buf_Type); snprintf(g->Message, sizeof(g->Message), "Invalid column type %d", Buf_Type);
} // endswitch Type } // endswitch Type
} // end of WriteColumn } // end of WriteColumn
@@ -2373,7 +2373,7 @@ int TDBJSON::MakeDocument(PGLOBAL g)
val = objp->GetKeyValue(key); val = objp->GetKeyValue(key);
if (!val || !(jsp = val->GetJson())) { if (!val || !(jsp = val->GetJson())) {
sprintf(g->Message, "Cannot find object key %s", key); snprintf(g->Message, sizeof(g->Message), "Cannot find object key %s", key);
return RC_FX; return RC_FX;
} // endif val } // endif val
@@ -2381,7 +2381,7 @@ int TDBJSON::MakeDocument(PGLOBAL g)
if (*p == '[') { if (*p == '[') {
// Old style // Old style
if (p[strlen(p) - 1] != ']') { if (p[strlen(p) - 1] != ']') {
sprintf(g->Message, "Invalid Table path near %s", p); snprintf(g->Message, sizeof(g->Message), "Invalid Table path near %s", p);
return RC_FX; return RC_FX;
} else } else
p++; p++;
@@ -2399,7 +2399,7 @@ int TDBJSON::MakeDocument(PGLOBAL g)
val = arp->GetArrayValue(i); val = arp->GetArrayValue(i);
if (!val) { if (!val) {
sprintf(g->Message, "Cannot find array value %d", i); snprintf(g->Message, sizeof(g->Message), "Cannot find array value %d", i);
return RC_FX; return RC_FX;
} // endif val } // endif val
@@ -2564,7 +2564,7 @@ bool TDBJSON::OpenDB(PGLOBAL g)
case MODE_ARRAY: Row = new(g) JARRAY; break; case MODE_ARRAY: Row = new(g) JARRAY; break;
case MODE_VALUE: Row = new(g) JVALUE; break; case MODE_VALUE: Row = new(g) JVALUE; break;
default: default:
sprintf(g->Message, "Invalid Jmode %d", Jmode); snprintf(g->Message, sizeof(g->Message), "Invalid Jmode %d", Jmode);
return true; return true;
} // endswitch Jmode } // endswitch Jmode
@@ -2648,7 +2648,7 @@ int TDBJSON::DeleteDB(PGLOBAL g, int irc)
if (irc == RC_OK) { if (irc == RC_OK) {
// Deleted current row // Deleted current row
if (Doc->DeleteValue(Fpos)) { if (Doc->DeleteValue(Fpos)) {
sprintf(g->Message, "Value %d does not exist", Fpos + 1); snprintf(g->Message, sizeof(g->Message), "Value %d does not exist", Fpos + 1);
return RC_FX; return RC_FX;
} // endif Delete } // endif Delete

View File

@@ -207,7 +207,7 @@ PCOL TDB::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp)
!stricmp(name, "FPATH") || !stricmp(name, "FNAME") || !stricmp(name, "FPATH") || !stricmp(name, "FNAME") ||
!stricmp(name, "FTYPE") || !stricmp(name, "SERVID")) { !stricmp(name, "FTYPE") || !stricmp(name, "SERVID")) {
if (!To_Def || !(To_Def->GetPseudo() & 2)) { if (!To_Def || !(To_Def->GetPseudo() & 2)) {
sprintf(g->Message, MSG(BAD_SPEC_COLUMN)); snprintf(g->Message, sizeof(g->Message), MSG(BAD_SPEC_COLUMN));
return NULL; return NULL;
} // endif Pseudo } // endif Pseudo
@@ -235,12 +235,12 @@ PCOL TDB::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp)
} else if (!stricmp(name, "ROWNUM")) { } else if (!stricmp(name, "ROWNUM")) {
colp = new(g)RIDBLK(cp, true); colp = new(g)RIDBLK(cp, true);
} else { } else {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_SPECIAL_COL), name);
return NULL; return NULL;
} // endif's name } // endif's name
if (!(colp = InsertSpecialColumn(colp))) { if (!(colp = InsertSpecialColumn(colp))) {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_SPECIAL_COL), name);
return NULL; return NULL;
} // endif Insert } // endif Insert
@@ -266,7 +266,7 @@ void TDB::MarkDB(PGLOBAL, PTDB tdb2)
/***********************************************************************/ /***********************************************************************/
int TDB::RowNumber(PGLOBAL g, bool) int TDB::RowNumber(PGLOBAL g, bool)
{ {
sprintf(g->Message, MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType())); snprintf(g->Message, sizeof(g->Message), MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType()));
return 0; return 0;
} // end of RowNumber } // end of RowNumber
@@ -495,7 +495,7 @@ PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp)
!stricmp(name, "FPATH") || !stricmp(name, "FNAME") || !stricmp(name, "FPATH") || !stricmp(name, "FNAME") ||
!stricmp(name, "FTYPE") || !stricmp(name, "SERVID")) { !stricmp(name, "FTYPE") || !stricmp(name, "SERVID")) {
if (!To_Def || !(To_Def->GetPseudo() & 2)) { if (!To_Def || !(To_Def->GetPseudo() & 2)) {
sprintf(g->Message, MSG(BAD_SPEC_COLUMN)); snprintf(g->Message, sizeof(g->Message), MSG(BAD_SPEC_COLUMN));
return NULL; return NULL;
} // endif Pseudo } // endif Pseudo
@@ -523,12 +523,12 @@ PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp)
} else if (!stricmp(name, "ROWNUM")) { } else if (!stricmp(name, "ROWNUM")) {
colp = new(g) RIDBLK(cp, true); colp = new(g) RIDBLK(cp, true);
} else { } else {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_SPECIAL_COL), name);
return NULL; return NULL;
} // endif's name } // endif's name
if (!(colp = InsertSpecialColumn(colp))) { if (!(colp = InsertSpecialColumn(colp))) {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_SPECIAL_COL), name);
return NULL; return NULL;
} // endif Insert } // endif Insert
@@ -642,12 +642,12 @@ bool TDBCAT::Initialize(PGLOBAL g)
return true; return true;
if (Qrp->Truncated) { if (Qrp->Truncated) {
sprintf(g->Message, "Result limited to %d lines", Qrp->Maxres); snprintf(g->Message, sizeof(g->Message), "Result limited to %d lines", Qrp->Maxres);
PushWarning(g, this); PushWarning(g, this);
} // endif Truncated } // endif Truncated
if (Qrp->BadLines) { if (Qrp->BadLines) {
sprintf(g->Message, "%d bad lines in result", Qrp->BadLines); snprintf(g->Message, sizeof(g->Message), "%d bad lines in result", Qrp->BadLines);
PushWarning(g, this); PushWarning(g, this);
} // endif Badlines } // endif Badlines
@@ -720,7 +720,7 @@ bool TDBCAT::InitCol(PGLOBAL g)
if (!colp->Crp /*&& !colp->GetValue()->IsConstant()*/) { if (!colp->Crp /*&& !colp->GetValue()->IsConstant()*/) {
sprintf(g->Message, "Invalid flag %d for column %s", snprintf(g->Message, sizeof(g->Message), "Invalid flag %d for column %s",
colp->Flag, colp->Name); colp->Flag, colp->Name);
return true; return true;
} else if (crp->Fld == FLD_SCALE || crp->Fld == FLD_RADIX) } else if (crp->Fld == FLD_SCALE || crp->Fld == FLD_RADIX)

View File

@@ -100,7 +100,7 @@ PCOL TDBMAC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
void TDBMAC::MakeErrorMsg(PGLOBAL g, DWORD drc) void TDBMAC::MakeErrorMsg(PGLOBAL g, DWORD drc)
{ {
if (drc == ERROR_BUFFER_OVERFLOW) if (drc == ERROR_BUFFER_OVERFLOW)
sprintf(g->Message, snprintf(g->Message, sizeof(g->Message),
"GetAdaptersInfo: Buffer Overflow buflen=%d maxsize=%d", "GetAdaptersInfo: Buffer Overflow buflen=%d maxsize=%d",
Buflen, MaxSize); Buflen, MaxSize);
else if (drc == ERROR_INVALID_PARAMETER) else if (drc == ERROR_INVALID_PARAMETER)
@@ -111,7 +111,7 @@ void TDBMAC::MakeErrorMsg(PGLOBAL g, DWORD drc)
else if (drc == ERROR_NOT_SUPPORTED) else if (drc == ERROR_NOT_SUPPORTED)
strcpy(g->Message, "GetAdaptersInfo is not supported"); strcpy(g->Message, "GetAdaptersInfo is not supported");
else else
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(),
0, g->Message, sizeof(g->Message), NULL); 0, g->Message, sizeof(g->Message), NULL);
@@ -159,7 +159,7 @@ bool TDBMAC::GetFixedInfo(PGLOBAL g)
} // endif drc } // endif drc
if (drc != ERROR_SUCCESS) { if (drc != ERROR_SUCCESS) {
sprintf(g->Message, "GetNetworkParams failed. Rc=%08x\n", drc); snprintf(g->Message, sizeof(g->Message), "GetNetworkParams failed. Rc=%08x\n", drc);
return true; return true;
} // endif drc } // endif drc

View File

@@ -723,7 +723,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), 0, (LPTSTR)&buf, sizeof(buf), NULL); NULL, GetLastError(), 0, (LPTSTR)&buf, sizeof(buf), NULL);
sprintf(g->Message, MSG(BAD_FILE_HANDLE), buf); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FILE_HANDLE), buf);
return -1; return -1;
} // endif rc } // endif rc
@@ -738,7 +738,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
rc = GetLastError(); rc = GetLastError();
if (rc != ERROR_NO_MORE_FILES) { if (rc != ERROR_NO_MORE_FILES) {
sprintf(g->Message, MSG(NEXT_FILE_ERROR), rc); snprintf(g->Message, sizeof(g->Message), MSG(NEXT_FILE_ERROR), rc);
FindClose(hSearch); FindClose(hSearch);
return -1; return -1;
} // endif rc } // endif rc
@@ -755,7 +755,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
// Start searching files in the target directory. // Start searching files in the target directory.
if (!(Dir = opendir(Direc))) { if (!(Dir = opendir(Direc))) {
sprintf(g->Message, MSG(BAD_DIRECTORY), Direc, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(BAD_DIRECTORY), Direc, strerror(errno));
return -1; return -1;
} // endif dir } // endif dir
@@ -763,7 +763,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
strcat(strcpy(Fpath, Direc), Entry->d_name); strcat(strcpy(Fpath, Direc), Entry->d_name);
if (lstat(Fpath, &Fileinfo) < 0) { if (lstat(Fpath, &Fileinfo) < 0) {
sprintf(g->Message, "%s: %s", Fpath, strerror(errno)); snprintf(g->Message, sizeof(g->Message), "%s: %s", Fpath, strerror(errno));
return -1; return -1;
} else if (S_ISREG(Fileinfo.st_mode)) } else if (S_ISREG(Fileinfo.st_mode))
// Test whether the file name matches the table name filter // Test whether the file name matches the table name filter
@@ -851,7 +851,7 @@ int TDBDIR::ReadDB(PGLOBAL g)
if (!Dir) if (!Dir)
// Start searching files in the target directory. // Start searching files in the target directory.
if (!(Dir = opendir(Direc))) { if (!(Dir = opendir(Direc))) {
sprintf(g->Message, MSG(BAD_DIRECTORY), Direc, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(BAD_DIRECTORY), Direc, strerror(errno));
rc = RC_FX; rc = RC_FX;
} // endif dir } // endif dir
@@ -861,7 +861,7 @@ int TDBDIR::ReadDB(PGLOBAL g)
strcat(strcpy(Fpath, Direc), Entry->d_name); strcat(strcpy(Fpath, Direc), Entry->d_name);
if (lstat(Fpath, &Fileinfo) < 0) { if (lstat(Fpath, &Fileinfo) < 0) {
sprintf(g->Message, "%s: %s", Fpath, strerror(errno)); snprintf(g->Message, sizeof(g->Message), "%s: %s", Fpath, strerror(errno));
rc = RC_FX; rc = RC_FX;
} else if (S_ISREG(Fileinfo.st_mode)) } else if (S_ISREG(Fileinfo.st_mode))
// Test whether the file name matches the table name filter // Test whether the file name matches the table name filter
@@ -1015,7 +1015,7 @@ void DIRCOL::ReadColumn(PGLOBAL g)
case 10: Value->SetValue((int)Tdbp->Fileinfo.st_gid); break; case 10: Value->SetValue((int)Tdbp->Fileinfo.st_gid); break;
#endif // !_WIN32 #endif // !_WIN32
default: default:
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N); snprintf(g->Message, sizeof(g->Message), MSG(INV_DIRCOL_OFST), N);
throw GetAmType(); throw GetAmType();
} // endswitch N } // endswitch N
@@ -1065,7 +1065,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), 0, (LPTSTR)&buf, sizeof(buf), NULL); NULL, GetLastError(), 0, (LPTSTR)&buf, sizeof(buf), NULL);
sprintf(g->Message, MSG(BAD_FILE_HANDLE), buf); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FILE_HANDLE), buf);
return -1; return -1;
} // endif rc } // endif rc
@@ -1086,7 +1086,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
rc = GetLastError(); rc = GetLastError();
if (rc != ERROR_NO_MORE_FILES) { if (rc != ERROR_NO_MORE_FILES) {
sprintf(g->Message, MSG(NEXT_FILE_ERROR), rc); snprintf(g->Message, sizeof(g->Message), MSG(NEXT_FILE_ERROR), rc);
FindClose(h); FindClose(h);
return -1; return -1;
} // endif rc } // endif rc
@@ -1107,7 +1107,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), 0, (LPTSTR)&buf, sizeof(buf), NULL); NULL, GetLastError(), 0, (LPTSTR)&buf, sizeof(buf), NULL);
sprintf(g->Message, MSG(BAD_FILE_HANDLE), buf); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FILE_HANDLE), buf);
return -1; return -1;
} // endif rc } // endif rc
@@ -1121,7 +1121,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
rc = GetLastError(); rc = GetLastError();
if (rc != ERROR_NO_MORE_FILES) { if (rc != ERROR_NO_MORE_FILES) {
sprintf(g->Message, MSG(NEXT_FILE_ERROR), rc); snprintf(g->Message, sizeof(g->Message), MSG(NEXT_FILE_ERROR), rc);
FindClose(h); FindClose(h);
return -1; return -1;
} // endif rc } // endif rc
@@ -1160,7 +1160,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
DIR *dir = opendir(Direc); DIR *dir = opendir(Direc);
if (!dir) { if (!dir) {
sprintf(g->Message, MSG(BAD_DIRECTORY), Direc, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(BAD_DIRECTORY), Direc, strerror(errno));
return -1; return -1;
} // endif dir } // endif dir
@@ -1168,7 +1168,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
strcat(strcpy(Fpath, Direc), Entry->d_name); strcat(strcpy(Fpath, Direc), Entry->d_name);
if (lstat(Fpath, &Fileinfo) < 0) { if (lstat(Fpath, &Fileinfo) < 0) {
sprintf(g->Message, "%s: %s", Fpath, strerror(errno)); snprintf(g->Message, sizeof(g->Message), "%s: %s", Fpath, strerror(errno));
return -1; return -1;
} else if (S_ISDIR(Fileinfo.st_mode) && *Entry->d_name != '.') { } else if (S_ISDIR(Fileinfo.st_mode) && *Entry->d_name != '.') {
// Look in the name sub-directory // Look in the name sub-directory
@@ -1287,7 +1287,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
if (!Sub->D) if (!Sub->D)
// Start searching files in the target directory. // Start searching files in the target directory.
if (!(Sub->D = opendir(Direc))) { if (!(Sub->D = opendir(Direc))) {
sprintf(g->Message, MSG(BAD_DIRECTORY), Direc, strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(BAD_DIRECTORY), Direc, strerror(errno));
rc = RC_FX; rc = RC_FX;
} // endif dir } // endif dir
@@ -1297,7 +1297,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
strcat(strcpy(Fpath, Direc), Entry->d_name); strcat(strcpy(Fpath, Direc), Entry->d_name);
if (lstat(Fpath, &Fileinfo) < 0) { if (lstat(Fpath, &Fileinfo) < 0) {
sprintf(g->Message, "%s: %s", Fpath, strerror(errno)); snprintf(g->Message, sizeof(g->Message), "%s: %s", Fpath, strerror(errno));
rc = RC_FX; rc = RC_FX;
} else if (S_ISDIR(Fileinfo.st_mode) && strcmp(Entry->d_name, ".") } else if (S_ISDIR(Fileinfo.st_mode) && strcmp(Entry->d_name, ".")
&& strcmp(Entry->d_name, "..")) { && strcmp(Entry->d_name, "..")) {
@@ -1418,7 +1418,7 @@ int TDBDHR::GetMaxSize(PGLOBAL g)
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, rc, 0, NULL, rc, 0,
(LPTSTR)&filename, sizeof(filename), NULL); (LPTSTR)&filename, sizeof(filename), NULL);
sprintf(g->Message, MSG(BAD_FILE_HANDLE), filename); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FILE_HANDLE), filename);
} // endswitch rc } // endswitch rc
} else { } else {
@@ -1427,7 +1427,7 @@ int TDBDHR::GetMaxSize(PGLOBAL g)
rc = GetLastError(); rc = GetLastError();
if (rc != ERROR_NO_MORE_FILES) { if (rc != ERROR_NO_MORE_FILES) {
sprintf(g->Message, MSG(NEXT_FILE_ERROR), rc); snprintf(g->Message, sizeof(g->Message), MSG(NEXT_FILE_ERROR), rc);
n = -1; n = -1;
} // endif rc } // endif rc
@@ -1469,7 +1469,7 @@ bool TDBDHR::OpenDB(PGLOBAL g)
/*********************************************************************/ /*********************************************************************/
if (NeedIndexing(g)) { if (NeedIndexing(g)) {
// Direct access of DHR tables is not implemented yet // Direct access of DHR tables is not implemented yet
sprintf(g->Message, MSG(NO_DIR_INDX_RD), "DHR"); snprintf(g->Message, sizeof(g->Message), MSG(NO_DIR_INDX_RD), "DHR");
return true; return true;
} // endif NeedIndexing } // endif NeedIndexing
@@ -1510,7 +1510,7 @@ int TDBDHR::ReadDB(PGLOBAL g)
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, erc, 0, NULL, erc, 0,
(LPTSTR)&filename, sizeof(filename), NULL); (LPTSTR)&filename, sizeof(filename), NULL);
sprintf(g->Message, MSG(BAD_FILE_HANDLE), filename); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FILE_HANDLE), filename);
rc = RC_FX; rc = RC_FX;
} // endswitch erc } // endswitch erc
@@ -1519,7 +1519,7 @@ int TDBDHR::ReadDB(PGLOBAL g)
DWORD erc = GetLastError(); DWORD erc = GetLastError();
if (erc != ERROR_NO_MORE_FILES) { if (erc != ERROR_NO_MORE_FILES) {
sprintf(g->Message, MSG(NEXT_FILE_ERROR), erc); snprintf(g->Message, sizeof(g->Message), MSG(NEXT_FILE_ERROR), erc);
FindClose(Hsearch); FindClose(Hsearch);
rc = RC_FX; rc = RC_FX;
} else } else

View File

@@ -712,7 +712,7 @@ bool TDBMYSQL::MakeCommand(PGLOBAL g)
strlwr(strcpy(qrystr, Query->GetStr())); strlwr(strcpy(qrystr, Query->GetStr()));
} else { } else {
sprintf(g->Message, "Cannot use this %s command", snprintf(g->Message, sizeof(g->Message), "Cannot use this %s command",
(Mode == MODE_UPDATE) ? "UPDATE" : "DELETE"); (Mode == MODE_UPDATE) ? "UPDATE" : "DELETE");
return true; return true;
} // endif p } // endif p
@@ -922,7 +922,7 @@ bool TDBMYSQL::OpenDB(PGLOBAL g)
#if 0 #if 0
if (!Myc.m_Res || !Myc.m_Fields) { if (!Myc.m_Res || !Myc.m_Fields) {
sprintf(g->Message, "%s result", (Myc.m_Res) ? "Void" : "No"); snprintf(g->Message, sizeof(g->Message), "%s result", (Myc.m_Res) ? "Void" : "No");
Myc.Close(); Myc.Close();
return true; return true;
} // endif m_Res } // endif m_Res
@@ -1011,7 +1011,7 @@ PCOL TDBMYSQL::MakeFieldColumn(PGLOBAL g, char *name)
} // endfor n } // endfor n
if (!colp) if (!colp)
sprintf(g->Message, "Column %s is not in view", name); snprintf(g->Message, sizeof(g->Message), "Column %s is not in view", name);
return colp; return colp;
} // end of MakeFieldColumn } // end of MakeFieldColumn
@@ -1048,7 +1048,7 @@ int TDBMYSQL::SendCommand(PGLOBAL g)
if (Myc.ExecSQLcmd(g, Query->GetStr(), &w) == RC_NF) { if (Myc.ExecSQLcmd(g, Query->GetStr(), &w) == RC_NF) {
AftRows = Myc.m_Afrw; AftRows = Myc.m_Afrw;
sprintf(g->Message, "%s: %d affected rows", TableName, AftRows); snprintf(g->Message, sizeof(g->Message), "%s: %d affected rows", TableName, AftRows);
PushWarning(g, this, 0); // 0 means a Note PushWarning(g, this, 0); // 0 means a Note
if (trace(1)) if (trace(1))
@@ -1057,7 +1057,7 @@ int TDBMYSQL::SendCommand(PGLOBAL g)
if (w && Myc.ExecSQL(g, "SHOW WARNINGS") == RC_OK) { if (w && Myc.ExecSQL(g, "SHOW WARNINGS") == RC_OK) {
// We got warnings from the remote server // We got warnings from the remote server
while (Myc.Fetch(g, -1) == RC_OK) { while (Myc.Fetch(g, -1) == RC_OK) {
sprintf(g->Message, "%s: (%s) %s", TableName, snprintf(g->Message, sizeof(g->Message), "%s: (%s) %s", TableName,
Myc.GetCharField(1), Myc.GetCharField(2)); Myc.GetCharField(1), Myc.GetCharField(2));
PushWarning(g, this); PushWarning(g, this);
} // endwhile Fetch } // endwhile Fetch
@@ -1310,7 +1310,7 @@ bool MYSQLCOL::FindRank(PGLOBAL g)
return false; return false;
} // endif Name } // endif Name
sprintf(g->Message, "Column %s not in result set", Name); snprintf(g->Message, sizeof(g->Message), "Column %s not in result set", Name);
return true; return true;
} // end of FindRank } // end of FindRank
@@ -1320,7 +1320,7 @@ bool MYSQLCOL::FindRank(PGLOBAL g)
bool MYSQLCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) bool MYSQLCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
{ {
if (!(To_Val = value)) { if (!(To_Val = value)) {
sprintf(g->Message, MSG(VALUE_ERROR), Name); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_ERROR), Name);
return true; return true;
} else if (Buf_Type == value->GetType()) { } else if (Buf_Type == value->GetType()) {
// Values are of the (good) column type // Values are of the (good) column type
@@ -1339,7 +1339,7 @@ bool MYSQLCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
} else { } else {
// Values are not of the (good) column type // Values are not of the (good) column type
if (check) { if (check) {
sprintf(g->Message, MSG(TYPE_VALUE_ERR), Name, snprintf(g->Message, sizeof(g->Message), MSG(TYPE_VALUE_ERR), Name,
GetTypeName(Buf_Type), GetTypeName(value->GetType())); GetTypeName(Buf_Type), GetTypeName(value->GetType()));
return true; return true;
} // endif check } // endif check
@@ -1401,7 +1401,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
if (!tdbp->Fetched) if (!tdbp->Fetched)
if ((rc = tdbp->Myc.Fetch(g, tdbp->N)) != RC_OK) { if ((rc = tdbp->Myc.Fetch(g, tdbp->N)) != RC_OK) {
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); snprintf(g->Message, sizeof(g->Message), MSG(INV_DEF_READ), rc);
throw 11; throw 11;
} else } else
@@ -1419,7 +1419,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
p = buf; p = buf;
if (Value->SetValue_char(p, strlen(p))) { if (Value->SetValue_char(p, strlen(p))) {
sprintf(g->Message, "Out of range value for column %s at row %d", snprintf(g->Message, sizeof(g->Message), "Out of range value for column %s at row %d",
Name, tdbp->RowNumber(g)); Name, tdbp->RowNumber(g));
PushWarning(g, tdbp); PushWarning(g, tdbp);
} // endif SetValue_char } // endif SetValue_char

View File

@@ -361,7 +361,7 @@ bool TDBOCCUR::MakeColumnList(PGLOBAL g)
for (i = 0, pn = Colist; i < Mult; i++, pn += (strlen(pn) + 1)) { for (i = 0, pn = Colist; i < Mult; i++, pn += (strlen(pn) + 1)) {
if (!(Col[i] = Tdbp->ColDB(g, pn, 0))) { if (!(Col[i] = Tdbp->ColDB(g, pn, 0))) {
// Column not found in table // Column not found in table
sprintf(g->Message, MSG(COL_ISNOT_TABLE), pn, Tabname); snprintf(g->Message, sizeof(g->Message), MSG(COL_ISNOT_TABLE), pn, Tabname);
return true; return true;
} // endif Col } // endif Col
@@ -409,7 +409,7 @@ bool TDBOCCUR::ViewColumnList(PGLOBAL g)
for (i = 0, pn = Colist; i < Mult; i++, pn += (strlen(pn) + 1)) for (i = 0, pn = Colist; i < Mult; i++, pn += (strlen(pn) + 1))
if (!(Col[i] = tdbp->MakeFieldColumn(g, pn))) { if (!(Col[i] = tdbp->MakeFieldColumn(g, pn))) {
// Column not found in table // Column not found in table
sprintf(g->Message, MSG(COL_ISNOT_TABLE), pn, Tabname); snprintf(g->Message, sizeof(g->Message), MSG(COL_ISNOT_TABLE), pn, Tabname);
return true; return true;
} // endif Col } // endif Col

View File

@@ -109,7 +109,7 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Desc = Connect = GetStringCatInfo(g, "Connect", NULL); Desc = Connect = GetStringCatInfo(g, "Connect", NULL);
if (!Connect && !Catfunc) { if (!Connect && !Catfunc) {
sprintf(g->Message, "Missing connection for ODBC table %s", Name); snprintf(g->Message, sizeof(g->Message), "Missing connection for ODBC table %s", Name);
return true; return true;
} // endif Connect } // endif Connect
@@ -607,7 +607,7 @@ bool TDBODBC::OpenDB(PGLOBAL g)
if ((n = Ocp->GetResultSize(Query->GetStr(), Cnp)) < 0) { if ((n = Ocp->GetResultSize(Query->GetStr(), Cnp)) < 0) {
char* msg = PlugDup(g, g->Message); char* msg = PlugDup(g, g->Message);
sprintf(g->Message, "Get result size: %s (rc=%d)", msg, n); snprintf(g->Message, sizeof(g->Message), "Get result size: %s (rc=%d)", msg, n);
return true; return true;
} else if (n) { } else if (n) {
Ocp->m_Rows = n; Ocp->m_Rows = n;
@@ -652,7 +652,7 @@ bool TDBODBC::OpenDB(PGLOBAL g)
} else if (Mode == MODE_UPDATE || Mode == MODE_DELETE) { } else if (Mode == MODE_UPDATE || Mode == MODE_DELETE) {
rc = false; // wait for CheckCond before calling MakeCommand(g); rc = false; // wait for CheckCond before calling MakeCommand(g);
} else } else
sprintf(g->Message, "Invalid mode %d", Mode); snprintf(g->Message, sizeof(g->Message), "Invalid mode %d", Mode);
if (rc) { if (rc) {
Ocp->Close(); Ocp->Close();
@@ -777,7 +777,7 @@ int TDBODBC::ReadDB(PGLOBAL g)
// Send the UPDATE/DELETE command to the remote table // Send the UPDATE/DELETE command to the remote table
if (!Ocp->ExecSQLcommand(Query->GetStr())) { if (!Ocp->ExecSQLcommand(Query->GetStr())) {
sprintf(g->Message, "%s: %d affected rows", TableName, AftRows); snprintf(g->Message, sizeof(g->Message), "%s: %d affected rows", TableName, AftRows);
if (trace(1)) if (trace(1))
htrc("%s\n", g->Message); htrc("%s\n", g->Message);
@@ -853,7 +853,7 @@ int TDBODBC::DeleteDB(PGLOBAL g, int irc)
// Send the DELETE (all) command to the remote table // Send the DELETE (all) command to the remote table
if (!Ocp->ExecSQLcommand(Query->GetStr())) { if (!Ocp->ExecSQLcommand(Query->GetStr())) {
sprintf(g->Message, "%s: %d affected rows", TableName, AftRows); snprintf(g->Message, sizeof(g->Message), "%s: %d affected rows", TableName, AftRows);
if (trace(1)) if (trace(1))
htrc("%s\n", g->Message); htrc("%s\n", g->Message);

View File

@@ -193,7 +193,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
*pcrp = crp->Next; *pcrp = crp->Next;
} else if (!stricmp(Picol, crp->Name)) { } else if (!stricmp(Picol, crp->Name)) {
if (crp->Nulls) { if (crp->Nulls) {
sprintf(g->Message, "Pivot column %s cannot be nullable", Picol); snprintf(g->Message, sizeof(g->Message), "Pivot column %s cannot be nullable", Picol);
goto err; goto err;
} // endif Nulls } // endif Nulls
@@ -550,14 +550,14 @@ bool TDBPIVOT::MakePivotColumns(PGLOBAL g)
// Now it is time to allocate the pivot and function columns // Now it is time to allocate the pivot and function columns
if (!(Fcolp = Tdbp->ColDB(g, Fncol, 0))) { if (!(Fcolp = Tdbp->ColDB(g, Fncol, 0))) {
// Function column not found in table // Function column not found in table
sprintf(g->Message, MSG(COL_ISNOT_TABLE), Fncol, Tabname); snprintf(g->Message, sizeof(g->Message), MSG(COL_ISNOT_TABLE), Fncol, Tabname);
return true; return true;
} else if (Fcolp->InitValue(g)) } else if (Fcolp->InitValue(g))
return true; return true;
if (!(Xcolp = Tdbp->ColDB(g, Picol, 0))) { if (!(Xcolp = Tdbp->ColDB(g, Picol, 0))) {
// Pivot column not found in table // Pivot column not found in table
sprintf(g->Message, MSG(COL_ISNOT_TABLE), Picol, Tabname); snprintf(g->Message, sizeof(g->Message), MSG(COL_ISNOT_TABLE), Picol, Tabname);
return true; return true;
} else if (Xcolp->InitValue(g)) } else if (Xcolp->InitValue(g))
return true; return true;
@@ -671,7 +671,7 @@ bool TDBPIVOT::OpenDB(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
/* Currently PIVOT tables cannot be modified. */ /* Currently PIVOT tables cannot be modified. */
/*******************************************************************/ /*******************************************************************/
sprintf(g->Message, MSG(TABLE_READ_ONLY), "PIVOT"); snprintf(g->Message, sizeof(g->Message), MSG(TABLE_READ_ONLY), "PIVOT");
return TRUE; return TRUE;
} // endif Mode } // endif Mode
@@ -797,7 +797,7 @@ int TDBPIVOT::ReadDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int TDBPIVOT::WriteDB(PGLOBAL g) int TDBPIVOT::WriteDB(PGLOBAL g)
{ {
sprintf(g->Message, MSG(TABLE_READ_ONLY), "PIVOT"); snprintf(g->Message, sizeof(g->Message), MSG(TABLE_READ_ONLY), "PIVOT");
return RC_FX; return RC_FX;
} // end of WriteDB } // end of WriteDB
@@ -806,7 +806,7 @@ int TDBPIVOT::WriteDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int TDBPIVOT::DeleteDB(PGLOBAL g, int) int TDBPIVOT::DeleteDB(PGLOBAL g, int)
{ {
sprintf(g->Message, MSG(NO_TABLE_DEL), "PIVOT"); snprintf(g->Message, sizeof(g->Message), MSG(NO_TABLE_DEL), "PIVOT");
return RC_FX; return RC_FX;
} // end of DeleteDB } // end of DeleteDB

View File

@@ -87,7 +87,7 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename)
CloseHandle(pi.hProcess); CloseHandle(pi.hProcess);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
} else { } else {
sprintf(g->Message, "CreateProcess curl failed (%d)", GetLastError()); snprintf(g->Message, sizeof(g->Message), "CreateProcess curl failed (%d)", GetLastError());
rc = 1; rc = 1;
} // endif CreateProcess } // endif CreateProcess
#else // !_WIN32 #else // !_WIN32
@@ -159,7 +159,7 @@ XGETREST GetRestFunction(PGLOBAL g)
char buf[256]; char buf[256];
DWORD rc = GetLastError(); DWORD rc = GetLastError();
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, soname); snprintf(g->Message, sizeof(g->Message), MSG(DLL_LOAD_ERROR), rc, soname);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
@@ -172,7 +172,7 @@ XGETREST GetRestFunction(PGLOBAL g)
char buf[256]; char buf[256];
DWORD rc = GetLastError(); DWORD rc = GetLastError();
sprintf(g->Message, MSG(PROCADD_ERROR), rc, "restGetFile"); snprintf(g->Message, sizeof(g->Message), MSG(PROCADD_ERROR), rc, "restGetFile");
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
@@ -188,14 +188,14 @@ XGETREST GetRestFunction(PGLOBAL g)
// Load the desired shared library // Load the desired shared library
if (!(Hso = dlopen(soname, RTLD_LAZY))) { if (!(Hso = dlopen(soname, RTLD_LAZY))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); snprintf(g->Message, sizeof(g->Message), MSG(SHARED_LIB_ERR), soname, SVP(error));
return NULL; return NULL;
} // endif Hdll } // endif Hdll
// Get the function returning an instance of the external DEF class // Get the function returning an instance of the external DEF class
if (!(getRestFnc = (XGETREST)dlsym(Hso, "restGetFile"))) { if (!(getRestFnc = (XGETREST)dlsym(Hso, "restGetFile"))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), "restGetFile", SVP(error)); snprintf(g->Message, sizeof(g->Message), MSG(GET_FUNC_ERR), "restGetFile", SVP(error));
dlclose(Hso); dlclose(Hso);
return NULL; return NULL;
} // endif getdef } // endif getdef
@@ -239,7 +239,7 @@ PQRYRES RESTColumns(PGLOBAL g, PTOS tp, char *tab, char *db, bool info)
fn = filename; fn = filename;
tp->subtype = PlugDup(g, fn); tp->subtype = PlugDup(g, fn);
sprintf(g->Message, "No file name. Table will use %s", fn); snprintf(g->Message, sizeof(g->Message), "No file name. Table will use %s", fn);
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
} // endif fn } // endif fn
@@ -265,7 +265,7 @@ PQRYRES RESTColumns(PGLOBAL g, PTOS tp, char *tab, char *db, bool info)
qrp = XMLColumns(g, db, tab, tp, info); qrp = XMLColumns(g, db, tab, tp, info);
#endif // XML_SUPPORT #endif // XML_SUPPORT
else else
sprintf(g->Message, "Usupported file type %s", ftype); snprintf(g->Message, sizeof(g->Message), "Usupported file type %s", ftype);
return qrp; return qrp;
} // end of RESTColumns } // end of RESTColumns
@@ -300,7 +300,7 @@ bool RESTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if (n == 0) { if (n == 0) {
htrc("DefineAM: Unsupported REST table type %s\n", ftype); htrc("DefineAM: Unsupported REST table type %s\n", ftype);
sprintf(g->Message, "Unsupported REST table type %s", ftype); snprintf(g->Message, sizeof(g->Message), "Unsupported REST table type %s", ftype);
return true; return true;
} // endif n } // endif n

View File

@@ -318,7 +318,7 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc)
case RC_FX: case RC_FX:
while (ReadDB(g) == RC_OK) while (ReadDB(g) == RC_OK)
if (!WritePrivateProfileString(Section, NULL, NULL, Ifile)) { if (!WritePrivateProfileString(Section, NULL, NULL, Ifile)) {
sprintf(g->Message, "Error %d accessing %s", snprintf(g->Message, sizeof(g->Message), "Error %d accessing %s",
GetLastError(), Ifile); GetLastError(), Ifile);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -330,7 +330,7 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc)
return RC_FX; return RC_FX;
} else } else
if (!WritePrivateProfileString(Section, NULL, NULL, Ifile)) { if (!WritePrivateProfileString(Section, NULL, NULL, Ifile)) {
sprintf(g->Message, "Error %d accessing %s", snprintf(g->Message, sizeof(g->Message), "Error %d accessing %s",
GetLastError(), Ifile); GetLastError(), Ifile);
return RC_FX; return RC_FX;
} // endif rc } // endif rc
@@ -401,7 +401,7 @@ void INICOL::AllocBuf(PGLOBAL g)
bool INICOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) bool INICOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
{ {
if (!(To_Val = value)) { if (!(To_Val = value)) {
sprintf(g->Message, MSG(VALUE_ERROR), Name); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_ERROR), Name);
return true; return true;
} else if (Buf_Type == value->GetType()) { } else if (Buf_Type == value->GetType()) {
// Values are of the (good) column type // Values are of the (good) column type
@@ -420,7 +420,7 @@ bool INICOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
} else { } else {
// Values are not of the (good) column type // Values are not of the (good) column type
if (check) { if (check) {
sprintf(g->Message, MSG(TYPE_VALUE_ERR), Name, snprintf(g->Message, sizeof(g->Message), MSG(TYPE_VALUE_ERR), Name,
GetTypeName(Buf_Type), GetTypeName(value->GetType())); GetTypeName(Buf_Type), GetTypeName(value->GetType()));
return true; return true;
} // endif check } // endif check
@@ -510,7 +510,7 @@ void INICOL::WriteColumn(PGLOBAL g)
p = Value->GetCharString(Valbuf); p = Value->GetCharString(Valbuf);
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_TOO_LONG), p, Name, Long);
throw 31; throw 31;
} else if (Flag == 1) { } else if (Flag == 1) {
if (tdbp->Mode == MODE_UPDATE) { if (tdbp->Mode == MODE_UPDATE) {
@@ -534,7 +534,7 @@ void INICOL::WriteColumn(PGLOBAL g)
rc = WritePrivateProfileString(tdbp->Section, Name, p, tdbp->Ifile); rc = WritePrivateProfileString(tdbp->Section, Name, p, tdbp->Ifile);
if (!rc) { if (!rc) {
sprintf(g->Message, "Error %d writing to %s", snprintf(g->Message, sizeof(g->Message), "Error %d writing to %s",
GetLastError(), tdbp->Ifile); GetLastError(), tdbp->Ifile);
throw 31; throw 31;
} // endif rc } // endif rc
@@ -746,7 +746,7 @@ int TDBXIN::DeleteDB(PGLOBAL g, int irc)
} else if (irc == RC_FX) { } else if (irc == RC_FX) {
for (Section = Seclist; *Section; Section += (strlen(Section) + 1)) for (Section = Seclist; *Section; Section += (strlen(Section) + 1))
if (!WritePrivateProfileString(Section, NULL, NULL, Ifile)) { if (!WritePrivateProfileString(Section, NULL, NULL, Ifile)) {
sprintf(g->Message, "Error %d accessing %s", snprintf(g->Message, sizeof(g->Message), "Error %d accessing %s",
GetLastError(), Ifile); GetLastError(), Ifile);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -756,7 +756,7 @@ int TDBXIN::DeleteDB(PGLOBAL g, int irc)
return RC_FX; return RC_FX;
} else } else
if (!WritePrivateProfileString(Section, Keycur, NULL, Ifile)) { if (!WritePrivateProfileString(Section, Keycur, NULL, Ifile)) {
sprintf(g->Message, "Error %d accessing %s", snprintf(g->Message, sizeof(g->Message), "Error %d accessing %s",
GetLastError(), Ifile); GetLastError(), Ifile);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -836,7 +836,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
p = Value->GetCharString(Valbuf); p = Value->GetCharString(Valbuf);
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_TOO_LONG), p, Name, Long);
throw 31; throw 31;
} else if (Flag == 1) { } else if (Flag == 1) {
if (tdbp->Mode == MODE_UPDATE) { if (tdbp->Mode == MODE_UPDATE) {
@@ -870,7 +870,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
rc = WritePrivateProfileString(tdbp->Section, tdbp->Keycur, p, tdbp->Ifile); rc = WritePrivateProfileString(tdbp->Section, tdbp->Keycur, p, tdbp->Ifile);
if (!rc) { if (!rc) {
sprintf(g->Message, "Error %d writing to %s", snprintf(g->Message, sizeof(g->Message), "Error %d writing to %s",
GetLastError(), tdbp->Ifile); GetLastError(), tdbp->Ifile);
throw 31; throw 31;
} // endif rc } // endif rc

View File

@@ -691,7 +691,7 @@ bool TDBTBM::OpenTables(PGLOBAL g)
// pthread_attr_setdetachstate(&tp->attr, PTHREAD_CREATE_JOINABLE); // pthread_attr_setdetachstate(&tp->attr, PTHREAD_CREATE_JOINABLE);
if ((k = pthread_create(&tp->Tid, &tp->attr, ThreadOpen, tp))) { if ((k = pthread_create(&tp->Tid, &tp->attr, ThreadOpen, tp))) {
sprintf(g->Message, "pthread_create error %d", k); snprintf(g->Message, sizeof(g->Message), "pthread_create error %d", k);
Nbc++; Nbc++;
continue; continue;
} // endif k } // endif k

View File

@@ -109,7 +109,7 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db,
if (thd->is_error()) if (thd->is_error())
thd->clear_error(); // Avoid stopping info commands thd->clear_error(); // Avoid stopping info commands
sprintf(g->Message, "Error %d opening share\n", s->error); snprintf(g->Message, sizeof(g->Message), "Error %d opening share\n", s->error);
free_table_share(s); free_table_share(s);
return NULL; return NULL;
} // endif open_table_def } // endif open_table_def
@@ -204,19 +204,19 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
if ((type = MYSQLtoPLG(fp->type(), &v)) == TYPE_ERROR) { if ((type = MYSQLtoPLG(fp->type(), &v)) == TYPE_ERROR) {
if (v == 'K') { if (v == 'K') {
// Skip this column // Skip this column
sprintf(g->Message, "Column %s skipped (unsupported type)", colname); snprintf(g->Message, sizeof(g->Message), "Column %s skipped (unsupported type)", colname);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
continue; continue;
} // endif v } // endif v
sprintf(g->Message, "Column %s unsupported type", colname); snprintf(g->Message, sizeof(g->Message), "Column %s unsupported type", colname);
qrp = NULL; qrp = NULL;
break; break;
} // endif type } // endif type
if (v == 'X') { if (v == 'X') {
len = zconv; len = zconv;
sprintf(g->Message, "Column %s converted to varchar(%d)", snprintf(g->Message, sizeof(g->Message), "Column %s converted to varchar(%d)",
colname, len); colname, len);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
} // endif v } // endif v
@@ -411,7 +411,7 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
cdb = (tp->Schema) ? tp->Schema : curdb; cdb = (tp->Schema) ? tp->Schema : curdb;
if (!stricmp(name, tp->Name) && !stricmp(db, cdb)) { if (!stricmp(name, tp->Name) && !stricmp(db, cdb)) {
sprintf(g->Message, "Table %s.%s pointing on itself", db, name); snprintf(g->Message, sizeof(g->Message), "Table %s.%s pointing on itself", db, name);
return NULL; return NULL;
} // endif } // endif
@@ -441,7 +441,7 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
char buf[MAX_STR]; char buf[MAX_STR];
strcpy(buf, g->Message); strcpy(buf, g->Message);
snprintf(g->Message, MAX_STR, "Error accessing %s.%s: %s", db, name, buf); snprintf(g->Message, sizeof(g->Message), "Error accessing %s.%s: %s", db, name, buf);
hc->tshp = NULL; hc->tshp = NULL;
goto err; goto err;
} // endif Define } // endif Define
@@ -578,7 +578,7 @@ bool TDBPRX::OpenDB(PGLOBAL g)
PTDB utp; PTDB utp;
if (!(utp= Tdbp->Duplicate(g))) { if (!(utp= Tdbp->Duplicate(g))) {
sprintf(g->Message, MSG(INV_UPDT_TABLE), Tdbp->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(INV_UPDT_TABLE), Tdbp->GetName());
return true; return true;
} // endif tp } // endif tp
@@ -721,7 +721,7 @@ bool PRXCOL::Init(PGLOBAL g, PTDB tp)
// this may be needed by some tables (which?) // this may be needed by some tables (which?)
Colp->SetColUse(ColUse); Colp->SetColUse(ColUse);
} else { } else {
sprintf(g->Message, MSG(NO_MATCHING_COL), Name, tp->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(NO_MATCHING_COL), Name, tp->GetName());
return true; return true;
} // endif Colp } // endif Colp

View File

@@ -251,7 +251,7 @@ int TDBVIR::ReadDB(PGLOBAL)
/***********************************************************************/ /***********************************************************************/
int TDBVIR::WriteDB(PGLOBAL g) int TDBVIR::WriteDB(PGLOBAL g)
{ {
sprintf(g->Message, MSG(VIR_READ_ONLY), To_Def->GetType()); snprintf(g->Message, sizeof(g->Message), MSG(VIR_READ_ONLY), To_Def->GetType());
return RC_FX; return RC_FX;
} // end of WriteDB } // end of WriteDB
@@ -260,7 +260,7 @@ int TDBVIR::WriteDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int TDBVIR::DeleteDB(PGLOBAL g, int) int TDBVIR::DeleteDB(PGLOBAL g, int)
{ {
sprintf(g->Message, MSG(VIR_NO_DELETE), To_Def->GetType()); snprintf(g->Message, sizeof(g->Message), MSG(VIR_NO_DELETE), To_Def->GetType());
return RC_FX; return RC_FX;
} // end of DeleteDB } // end of DeleteDB
@@ -288,7 +288,7 @@ VIRCOL::VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ)
void VIRCOL::ReadColumn(PGLOBAL g) void VIRCOL::ReadColumn(PGLOBAL g)
{ {
// This should never be called // This should never be called
sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name); snprintf(g->Message, sizeof(g->Message), "ReadColumn: Column %s is not virtual", Name);
throw (int)TYPE_COLBLK; throw (int)TYPE_COLBLK;
} // end of ReadColumn } // end of ReadColumn

View File

@@ -62,7 +62,7 @@ PWMIUT InitWMI(PGLOBAL g, PCSZ nsp, PCSZ classname)
res = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); res = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (FAILED(res)) { if (FAILED(res)) {
sprintf(g->Message, "Failed to initialize COM library. " snprintf(g->Message, sizeof(g->Message), "Failed to initialize COM library. "
"Error code = %x", res); "Error code = %x", res);
return NULL; return NULL;
} // endif res } // endif res
@@ -74,7 +74,7 @@ PWMIUT InitWMI(PGLOBAL g, PCSZ nsp, PCSZ classname)
NULL, EOAC_NONE, NULL); NULL, EOAC_NONE, NULL);
if (res != RPC_E_TOO_LATE && FAILED(res)) { if (res != RPC_E_TOO_LATE && FAILED(res)) {
sprintf(g->Message, "Failed to initialize security. " snprintf(g->Message, sizeof(g->Message), "Failed to initialize security. "
"Error code = %p", res); "Error code = %p", res);
CoUninitialize(); CoUninitialize();
return NULL; return NULL;
@@ -85,7 +85,7 @@ PWMIUT InitWMI(PGLOBAL g, PCSZ nsp, PCSZ classname)
CLSCTX_INPROC_SERVER, IID_IWbemLocator, CLSCTX_INPROC_SERVER, IID_IWbemLocator,
(void**) &loc); (void**) &loc);
if (FAILED(res)) { if (FAILED(res)) {
sprintf(g->Message, "Failed to create Locator. " snprintf(g->Message, sizeof(g->Message), "Failed to create Locator. "
"Error code = %x", res); "Error code = %x", res);
CoUninitialize(); CoUninitialize();
return NULL; return NULL;
@@ -95,7 +95,7 @@ PWMIUT InitWMI(PGLOBAL g, PCSZ nsp, PCSZ classname)
NULL, NULL, NULL, 0, NULL, NULL, &wp->Svc); NULL, NULL, NULL, 0, NULL, NULL, &wp->Svc);
if (FAILED(res)) { if (FAILED(res)) {
sprintf(g->Message, "Could not connect. Error code = %x", res); snprintf(g->Message, sizeof(g->Message), "Could not connect. Error code = %x", res);
loc->Release(); loc->Release();
CoUninitialize(); CoUninitialize();
return NULL; return NULL;
@@ -119,7 +119,7 @@ PWMIUT InitWMI(PGLOBAL g, PCSZ nsp, PCSZ classname)
res = wp->Svc->GetObject(bstr_t(p), 0, 0, &wp->Cobj, 0); res = wp->Svc->GetObject(bstr_t(p), 0, 0, &wp->Cobj, 0);
if (FAILED(res)) { if (FAILED(res)) {
sprintf(g->Message, "failed GetObject %s in %s\n", classname, nsp); snprintf(g->Message, sizeof(g->Message), "failed GetObject %s in %s\n", classname, nsp);
wp->Svc->Release(); wp->Svc->Release();
wp->Svc = NULL; // MUST be set to NULL (why?) wp->Svc = NULL; // MUST be set to NULL (why?)
return NULL; return NULL;
@@ -164,12 +164,12 @@ PQRYRES WMIColumns(PGLOBAL g, PCSZ nsp, PCSZ cls, bool info)
res = wp->Cobj->Get(bstr_t("__Property_Count"), 0, &val, NULL, NULL); res = wp->Cobj->Get(bstr_t("__Property_Count"), 0, &val, NULL, NULL);
if (FAILED(res)) { if (FAILED(res)) {
sprintf(g->Message, "failed Get(__Property_Count) res=%d\n", res); snprintf(g->Message, sizeof(g->Message), "failed Get(__Property_Count) res=%d\n", res);
goto err; goto err;
} // endif res } // endif res
if (!(n = val.lVal)) { if (!(n = val.lVal)) {
sprintf(g->Message, "Class %s in %s has no properties\n", snprintf(g->Message, sizeof(g->Message), "Class %s in %s has no properties\n",
cls, nsp); cls, nsp);
goto err; goto err;
} // endif res } // endif res
@@ -182,7 +182,7 @@ PQRYRES WMIColumns(PGLOBAL g, PCSZ nsp, PCSZ cls, bool info)
NULL, &prnlist); NULL, &prnlist);
if (FAILED(res)) { if (FAILED(res)) {
sprintf(g->Message, "failed GetNames res=%d\n", res); snprintf(g->Message, sizeof(g->Message), "failed GetNames res=%d\n", res);
goto err; goto err;
} // endif res } // endif res
@@ -194,7 +194,7 @@ PQRYRES WMIColumns(PGLOBAL g, PCSZ nsp, PCSZ cls, bool info)
res = SafeArrayGetElement(prnlist, &i, &propname); res = SafeArrayGetElement(prnlist, &i, &propname);
if (FAILED(res)) { if (FAILED(res)) {
sprintf(g->Message, "failed GetArrayElement res=%d\n", res); snprintf(g->Message, sizeof(g->Message), "failed GetArrayElement res=%d\n", res);
goto err; goto err;
} // endif res } // endif res
@@ -221,7 +221,7 @@ PQRYRES WMIColumns(PGLOBAL g, PCSZ nsp, PCSZ cls, bool info)
res = wp->Cobj->BeginEnumeration(WBEM_FLAG_NONSYSTEM_ONLY); res = wp->Cobj->BeginEnumeration(WBEM_FLAG_NONSYSTEM_ONLY);
if (FAILED(res)) { if (FAILED(res)) {
sprintf(g->Message, "failed BeginEnumeration hr=%d\n", res); snprintf(g->Message, sizeof(g->Message), "failed BeginEnumeration hr=%d\n", res);
qrp = NULL; qrp = NULL;
goto err; goto err;
} // endif hr } // endif hr
@@ -230,7 +230,7 @@ PQRYRES WMIColumns(PGLOBAL g, PCSZ nsp, PCSZ cls, bool info)
res = wp->Cobj->Next(0, &propname, &val, &type, NULL); res = wp->Cobj->Next(0, &propname, &val, &type, NULL);
if (FAILED(res)) { if (FAILED(res)) {
sprintf(g->Message, "failed getting Next hr=%d\n", res); snprintf(g->Message, sizeof(g->Message), "failed getting Next hr=%d\n", res);
qrp = NULL; qrp = NULL;
goto err; goto err;
} else if (res == WBEM_S_NO_MORE_DATA) { } else if (res == WBEM_S_NO_MORE_DATA) {
@@ -340,7 +340,7 @@ bool WMIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
!stricmp(Nspace, "root\\cli") ? "Msft_CliAlias" : "")); !stricmp(Nspace, "root\\cli") ? "Msft_CliAlias" : ""));
if (!*Wclass) { if (!*Wclass) {
sprintf(g->Message, "Missing class name for %s", Nspace); snprintf(g->Message, sizeof(g->Message), "Missing class name for %s", Nspace);
return true; return true;
} else if (!strchr(Wclass, '_')) { } else if (!strchr(Wclass, '_')) {
char *p = (char*)PlugSubAlloc(g, NULL, strlen(Wclass) + 7); char *p = (char*)PlugSubAlloc(g, NULL, strlen(Wclass) + 7);
@@ -363,7 +363,7 @@ PTDB WMIDEF::GetTable(PGLOBAL g, MODE m)
else if (Catfunc == FNC_COL) else if (Catfunc == FNC_COL)
return new(g) TDBWCL(this); return new(g) TDBWCL(this);
sprintf(g->Message, "Bad catfunc %ud for WMI", Catfunc); snprintf(g->Message, sizeof(g->Message), "Bad catfunc %ud for WMI", Catfunc);
return NULL; return NULL;
} // end of GetTable } // end of GetTable
@@ -423,7 +423,7 @@ bool TDBWMI::Initialize(PGLOBAL g)
Res = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); Res = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (FAILED(Res)) { if (FAILED(Res)) {
sprintf(g->Message, "Failed to initialize COM library. " snprintf(g->Message, sizeof(g->Message), "Failed to initialize COM library. "
"Error code = %x", Res); "Error code = %x", Res);
return true; // Program has failed. return true; // Program has failed.
} // endif Res } // endif Res
@@ -436,8 +436,8 @@ bool TDBWMI::Initialize(PGLOBAL g)
IID_IWbemLocator, (LPVOID*) &loc); IID_IWbemLocator, (LPVOID*) &loc);
if (FAILED(Res)) { if (FAILED(Res)) {
sprintf(g->Message, "Failed to create Locator. " snprintf(g->Message, sizeof(g->Message), "Failed to create Locator. "
"Error code = %x", Res); "Error code = %x", Res);
CoUninitialize(); CoUninitialize();
return true; // Program has failed. return true; // Program has failed.
} // endif Res } // endif Res
@@ -449,7 +449,7 @@ bool TDBWMI::Initialize(PGLOBAL g)
NULL, NULL,0, NULL, 0, 0, &Svc); NULL, NULL,0, NULL, 0, 0, &Svc);
if (FAILED(Res)) { if (FAILED(Res)) {
sprintf(g->Message, "Could not connect. Error code = %x", Res); snprintf(g->Message, sizeof(g->Message), "Could not connect. Error code = %x", Res);
loc->Release(); loc->Release();
CoUninitialize(); CoUninitialize();
return true; // Program has failed. return true; // Program has failed.
@@ -464,7 +464,7 @@ bool TDBWMI::Initialize(PGLOBAL g)
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE); RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
if (FAILED(Res)) { if (FAILED(Res)) {
sprintf(g->Message, "Could not set proxy. Error code = %x", Res); snprintf(g->Message, sizeof(g->Message), "Could not set proxy. Error code = %x", Res);
Svc->Release(); Svc->Release();
CoUninitialize(); CoUninitialize();
return true; // Program has failed. return true; // Program has failed.
@@ -561,7 +561,7 @@ bool TDBWMI::GetWMIInfo(PGLOBAL g)
char *cmd = MakeWQL(g); char *cmd = MakeWQL(g);
if (cmd == NULL) { if (cmd == NULL) {
sprintf(g->Message, "Error making WQL statement"); snprintf(g->Message, sizeof(g->Message), "Error making WQL statement");
Svc->Release(); Svc->Release();
CoUninitialize(); CoUninitialize();
return true; // Program has failed. return true; // Program has failed.
@@ -574,7 +574,7 @@ bool TDBWMI::GetWMIInfo(PGLOBAL g)
NULL, &Enumerator); NULL, &Enumerator);
if (FAILED(Rc)) { if (FAILED(Rc)) {
sprintf(g->Message, "Query %s failed. Error code = %x", cmd, Rc); snprintf(g->Message, sizeof(g->Message), "Query %s failed. Error code = %x", cmd, Rc);
Svc->Release(); Svc->Release();
CoUninitialize(); CoUninitialize();
return true; // Program has failed. return true; // Program has failed.

View File

@@ -512,7 +512,7 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
defcol = "TD"; defcol = "TD";
break; break;
default: default:
sprintf(g->Message, MSG(INV_COL_TYPE), buf); snprintf(g->Message, sizeof(g->Message), MSG(INV_COL_TYPE), buf);
return true; return true;
} // endswitch typname } // endswitch typname
@@ -777,7 +777,7 @@ int TDBXML::LoadTableFile(PGLOBAL g, char *filename)
// Initialize the implementation // Initialize the implementation
if (Docp->Initialize(g, Entry, Zipped)) { if (Docp->Initialize(g, Entry, Zipped)) {
sprintf(g->Message, MSG(INIT_FAILED), (Usedom) ? "DOM" : "libxml2"); snprintf(g->Message, sizeof(g->Message), MSG(INIT_FAILED), (Usedom) ? "DOM" : "libxml2");
return RC_FX; return RC_FX;
} // endif init } // endif init
@@ -867,7 +867,7 @@ bool TDBXML::Initialize(PGLOBAL g)
// Evaluate table xpath // Evaluate table xpath
if ((TabNode = Root->SelectSingleNode(g, tabpath))) { if ((TabNode = Root->SelectSingleNode(g, tabpath))) {
if (TabNode->GetType() != XML_ELEMENT_NODE) { if (TabNode->GetType() != XML_ELEMENT_NODE) {
sprintf(g->Message, MSG(BAD_NODE_TYPE), TabNode->GetType()); snprintf(g->Message, sizeof(g->Message), MSG(BAD_NODE_TYPE), TabNode->GetType());
goto error; goto error;
} // endif Type } // endif Type
@@ -884,12 +884,12 @@ bool TDBXML::Initialize(PGLOBAL g)
if (!(DBnode = Root->SelectSingleNode(g, tabpath))) { if (!(DBnode = Root->SelectSingleNode(g, tabpath))) {
// DB node does not exist yet; we cannot create it // DB node does not exist yet; we cannot create it
// because we don't know where it should be placed // because we don't know where it should be placed
sprintf(g->Message, MSG(MISSING_NODE), XmlDB, Xfile); snprintf(g->Message, sizeof(g->Message), MSG(MISSING_NODE), XmlDB, Xfile);
goto error; goto error;
} // endif DBnode } // endif DBnode
if (!(TabNode = DBnode->AddChildNode(g, Tabname))) { if (!(TabNode = DBnode->AddChildNode(g, Tabname))) {
sprintf(g->Message, MSG(FAIL_ADD_NODE), Tabname); snprintf(g->Message, sizeof(g->Message), MSG(FAIL_ADD_NODE), Tabname);
goto error; goto error;
} // endif TabNode } // endif TabNode
@@ -934,7 +934,7 @@ bool TDBXML::Initialize(PGLOBAL g)
goto error; goto error;
} else { } else {
sprintf(g->Message, MSG(FILE_UNFOUND), Xfile); snprintf(g->Message, sizeof(g->Message), MSG(FILE_UNFOUND), Xfile);
if (Mode == MODE_READ) { if (Mode == MODE_READ) {
PushWarning(g, this); PushWarning(g, this);
@@ -946,7 +946,7 @@ bool TDBXML::Initialize(PGLOBAL g)
} else if (rc == RC_INFO) { } else if (rc == RC_INFO) {
// Loading failed // Loading failed
sprintf(g->Message, MSG(LOADING_FAILED), Xfile); snprintf(g->Message, sizeof(g->Message), MSG(LOADING_FAILED), Xfile);
goto error; goto error;
} else // (rc == RC_FX) } else // (rc == RC_FX)
goto error; goto error;
@@ -979,9 +979,9 @@ bool TDBXML::Initialize(PGLOBAL g)
buf, sizeof(buf), NULL, NULL); buf, sizeof(buf), NULL, NULL);
if (rc) if (rc)
sprintf(g->Message, "%s: %s", MSG(COM_ERROR), buf); snprintf(g->Message, sizeof(g->Message), "%s: %s", MSG(COM_ERROR), buf);
else else
sprintf(g->Message, "%s hr=%x", MSG(COM_ERROR), e.Error()); snprintf(g->Message, sizeof(g->Message), "%s hr=%x", MSG(COM_ERROR), e.Error());
goto error; goto error;
#endif // _WIN32 #endif // _WIN32
@@ -1138,7 +1138,7 @@ int TDBXML::RowNumber(PGLOBAL g, bool b)
/*******************************************************************/ /*******************************************************************/
/* Don't know how to retrieve RowID for expanded XML tables. */ /* Don't know how to retrieve RowID for expanded XML tables. */
/*******************************************************************/ /*******************************************************************/
sprintf(g->Message, MSG(NO_ROWID_FOR_AM), snprintf(g->Message, sizeof(g->Message), MSG(NO_ROWID_FOR_AM),
GetAmName(g, GetAmType())); GetAmName(g, GetAmType()));
return 0; // Means error return 0; // Means error
} else } else
@@ -1260,7 +1260,7 @@ int TDBXML::ReadDB(PGLOBAL g)
// Get the new row node // Get the new row node
if (Nlist) { if (Nlist) {
if ((RowNode = Nlist->GetItem(g, Irow, RowNode)) == NULL) { if ((RowNode = Nlist->GetItem(g, Irow, RowNode)) == NULL) {
sprintf(g->Message, MSG(MISSING_ROWNODE), Irow); snprintf(g->Message, sizeof(g->Message), MSG(MISSING_ROWNODE), Irow);
return RC_FX; return RC_FX;
} // endif RowNode } // endif RowNode
@@ -1325,7 +1325,7 @@ int TDBXML::DeleteDB(PGLOBAL g, int irc)
// Delete all rows // Delete all rows
for (Irow = 0; Irow < Nrow; Irow++) for (Irow = 0; Irow < Nrow; Irow++)
if ((RowNode = Nlist->GetItem(g, Irow, RowNode)) == NULL) { if ((RowNode = Nlist->GetItem(g, Irow, RowNode)) == NULL) {
sprintf(g->Message, MSG(MISSING_ROWNODE), Irow); snprintf(g->Message, sizeof(g->Message), MSG(MISSING_ROWNODE), Irow);
return RC_FX; return RC_FX;
} else { } else {
TabNode->DeleteChild(g, RowNode); TabNode->DeleteChild(g, RowNode);
@@ -1521,7 +1521,7 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode)
if (Xname) { if (Xname) {
if (Type == 2) { if (Type == 2) {
sprintf(g->Message, MSG(BAD_COL_XPATH), Name, Tdbp->Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_COL_XPATH), Name, Tdbp->Name);
return true; return true;
} else } else
strcat(pbuf, Xname); strcat(pbuf, Xname);
@@ -1551,7 +1551,7 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode)
if (mode) { if (mode) {
// For Update or Insert the Xpath must be explicit // For Update or Insert the Xpath must be explicit
if (strchr("@/.*", *p)) { if (strchr("@/.*", *p)) {
sprintf(g->Message, MSG(XPATH_NOT_SUPP), Name); snprintf(g->Message, sizeof(g->Message), MSG(XPATH_NOT_SUPP), Name);
return true; return true;
} else } else
Nodes[i] = p; Nodes[i] = p;
@@ -1562,7 +1562,7 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode)
} // endfor i, p } // endfor i, p
if (*p == '/' || *p == '.') { if (*p == '/' || *p == '.') {
sprintf(g->Message, MSG(XPATH_NOT_SUPP), Name); snprintf(g->Message, sizeof(g->Message), MSG(XPATH_NOT_SUPP), Name);
return true; return true;
} else if (*p == '@') { } else if (*p == '@') {
p++; // Remove the @ if mode p++; // Remove the @ if mode
@@ -1623,7 +1623,7 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode)
bool XMLCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) bool XMLCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
{ {
if (!(To_Val = value)) { if (!(To_Val = value)) {
sprintf(g->Message, MSG(VALUE_ERROR), Name); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_ERROR), Name);
return true; return true;
} else if (Buf_Type == value->GetType()) { } else if (Buf_Type == value->GetType()) {
// Values are of the (good) column type // Values are of the (good) column type
@@ -1642,7 +1642,7 @@ bool XMLCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
} else { } else {
// Values are not of the (good) column type // Values are not of the (good) column type
if (check) { if (check) {
sprintf(g->Message, MSG(TYPE_VALUE_ERR), Name, snprintf(g->Message, sizeof(g->Message), MSG(TYPE_VALUE_ERR), Name,
GetTypeName(Buf_Type), GetTypeName(value->GetType())); GetTypeName(Buf_Type), GetTypeName(value->GetType()));
return true; return true;
} // endif check } // endif check
@@ -1695,7 +1695,7 @@ void XMLCOL::ReadColumn(PGLOBAL g)
if (ValNode) { if (ValNode) {
if (ValNode->GetType() != XML_ELEMENT_NODE && if (ValNode->GetType() != XML_ELEMENT_NODE &&
ValNode->GetType() != XML_ATTRIBUTE_NODE) { ValNode->GetType() != XML_ATTRIBUTE_NODE) {
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_VALNODE), ValNode->GetType(), Name);
throw (int)TYPE_AM_XML; throw (int)TYPE_AM_XML;
} // endif type } // endif type
@@ -1861,7 +1861,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
p = Value->GetCharString(buf); p = Value->GetCharString(buf);
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_TOO_LONG), p, Name, Long);
throw (int)TYPE_AM_XML; throw (int)TYPE_AM_XML;
} else } else
strcpy(Valbuf, p); strcpy(Valbuf, p);
@@ -1902,7 +1902,7 @@ void XMULCOL::ReadColumn(PGLOBAL g)
if (N > Tdbp->Limit) { if (N > Tdbp->Limit) {
N = Tdbp->Limit; N = Tdbp->Limit;
sprintf(g->Message, "Multiple values limited to %d", Tdbp->Limit); snprintf(g->Message, sizeof(g->Message), "Multiple values limited to %d", Tdbp->Limit);
PushWarning(g, Tdbp); PushWarning(g, Tdbp);
} // endif N } // endif N
@@ -1911,7 +1911,7 @@ void XMULCOL::ReadColumn(PGLOBAL g)
if (ValNode->GetType() != XML_ELEMENT_NODE && if (ValNode->GetType() != XML_ELEMENT_NODE &&
ValNode->GetType() != XML_ATTRIBUTE_NODE) { ValNode->GetType() != XML_ATTRIBUTE_NODE) {
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_VALNODE), ValNode->GetType(), Name);
throw (int)TYPE_AM_XML; throw (int)TYPE_AM_XML;
} // endif type } // endif type
@@ -2046,7 +2046,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
len = Nlx->GetLength(); len = Nlx->GetLength();
if (len > 1 && !Tdbp->Xpand) { if (len > 1 && !Tdbp->Xpand) {
sprintf(g->Message, MSG(BAD_VAL_UPDATE), Name); snprintf(g->Message, sizeof(g->Message), MSG(BAD_VAL_UPDATE), Name);
throw (int)TYPE_AM_XML; throw (int)TYPE_AM_XML;
} else } else
ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp); ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp);
@@ -2117,7 +2117,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
p = Value->GetCharString(buf); p = Value->GetCharString(buf);
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_TOO_LONG), p, Name, Long);
throw (int)TYPE_AM_XML; throw (int)TYPE_AM_XML;
} else } else
strcpy(Valbuf, p); strcpy(Valbuf, p);
@@ -2244,7 +2244,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
p = Value->GetCharString(buf); p = Value->GetCharString(buf);
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); snprintf(g->Message, sizeof(g->Message), MSG(VALUE_TOO_LONG), p, Name, Long);
throw (int)TYPE_AM_XML; throw (int)TYPE_AM_XML;
} else } else
strcpy(Valbuf, p); strcpy(Valbuf, p);

View File

@@ -85,7 +85,7 @@ bool TDBZIP::open(PGLOBAL g, const char *fn)
PlugSetPath(filename, fn, GetPath()); PlugSetPath(filename, fn, GetPath());
if (!zipfile && !(zipfile = unzOpen64(filename))) if (!zipfile && !(zipfile = unzOpen64(filename)))
sprintf(g->Message, "Zipfile open error"); snprintf(g->Message, sizeof(g->Message), "Zipfile open error");
return (zipfile == NULL); return (zipfile == NULL);
} // end of open } // end of open
@@ -155,7 +155,7 @@ int TDBZIP::ReadDB(PGLOBAL g)
if (nexterr == UNZ_END_OF_LIST_OF_FILE) if (nexterr == UNZ_END_OF_LIST_OF_FILE)
return RC_EF; return RC_EF;
else if (nexterr != UNZ_OK) { else if (nexterr != UNZ_OK) {
sprintf(g->Message, "unzGoToNextFile error %d", nexterr); snprintf(g->Message, sizeof(g->Message), "unzGoToNextFile error %d", nexterr);
return RC_FX; return RC_FX;
} // endif nexterr } // endif nexterr
@@ -163,7 +163,7 @@ int TDBZIP::ReadDB(PGLOBAL g)
sizeof(fn), NULL, 0, NULL, 0); sizeof(fn), NULL, 0, NULL, 0);
if (err != UNZ_OK) { if (err != UNZ_OK) {
sprintf(g->Message, "unzGetCurrentFileInfo64 error %d", err); snprintf(g->Message, sizeof(g->Message), "unzGetCurrentFileInfo64 error %d", err);
return RC_FX; return RC_FX;
} // endif err } // endif err

View File

@@ -105,7 +105,7 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
blkp = new(g) PTRBLK(g, mp, nval); blkp = new(g) PTRBLK(g, mp, nval);
break; break;
default: default:
sprintf(g->Message, MSG(BAD_VALBLK_TYPE), type); snprintf(g->Message, sizeof(g->Message), MSG(BAD_VALBLK_TYPE), type);
return NULL; return NULL;
} // endswitch Type } // endswitch Type
@@ -138,7 +138,7 @@ PSZ VALBLK::GetCharValue(int)
PGLOBAL& g = Global; PGLOBAL& g = Global;
assert(g); assert(g);
sprintf(g->Message, MSG(NO_CHAR_FROM), Type); snprintf(g->Message, sizeof(g->Message), MSG(NO_CHAR_FROM), Type);
throw Type; throw Type;
return NULL; return NULL;
} // end of GetCharValue } // end of GetCharValue
@@ -148,7 +148,7 @@ PSZ VALBLK::GetCharValue(int)
/***********************************************************************/ /***********************************************************************/
bool VALBLK::SetFormat(PGLOBAL g, PCSZ, int, int) bool VALBLK::SetFormat(PGLOBAL g, PCSZ, int, int)
{ {
sprintf(g->Message, MSG(NO_DATE_FMT), Type); snprintf(g->Message, sizeof(g->Message), MSG(NO_DATE_FMT), Type);
return true; return true;
} // end of SetFormat } // end of SetFormat
@@ -191,7 +191,7 @@ bool VALBLK::AllocBuff(PGLOBAL g, size_t size)
Mblk.Size = size; Mblk.Size = size;
if (!(Blkp = PlgDBalloc(g, NULL, Mblk))) { if (!(Blkp = PlgDBalloc(g, NULL, Mblk))) {
sprintf(g->Message, MSG(MEM_ALLOC_ERR), "Blkp", (int) Mblk.Size); snprintf(g->Message, sizeof(g->Message), MSG(MEM_ALLOC_ERR), "Blkp", (int) Mblk.Size);
fprintf(stderr, "%s\n", g->Message); fprintf(stderr, "%s\n", g->Message);
return true; return true;
} // endif Blkp } // endif Blkp
@@ -1380,7 +1380,7 @@ PVBLK MBVALS::Allocate(PGLOBAL g, int type, int len, int prec,
Mblk.Size = n * GetTypeSize(type, len); Mblk.Size = n * GetTypeSize(type, len);
if (!PlgDBalloc(g, NULL, Mblk)) { if (!PlgDBalloc(g, NULL, Mblk)) {
sprintf(g->Message, MSG(ALLOC_ERROR), "MBVALS::Allocate"); snprintf(g->Message, sizeof(g->Message), MSG(ALLOC_ERROR), "MBVALS::Allocate");
return NULL; return NULL;
} else } else
Vblk = AllocValBlock(g, Mblk.Memp, type, n, len, prec, Vblk = AllocValBlock(g, Mblk.Memp, type, n, len, prec,
@@ -1395,7 +1395,7 @@ PVBLK MBVALS::Allocate(PGLOBAL g, int type, int len, int prec,
bool MBVALS::ReAllocate(PGLOBAL g, int n) bool MBVALS::ReAllocate(PGLOBAL g, int n)
{ {
if (!PlgDBrealloc(g, NULL, Mblk, n * Vblk->GetVlen())) { if (!PlgDBrealloc(g, NULL, Mblk, n * Vblk->GetVlen())) {
sprintf(g->Message, MSG(ALLOC_ERROR), "MBVALS::ReAllocate"); snprintf(g->Message, sizeof(g->Message), MSG(ALLOC_ERROR), "MBVALS::ReAllocate");
return TRUE; return TRUE;
} else } else
Vblk->ReAlloc(Mblk.Memp, n); Vblk->ReAlloc(Mblk.Memp, n);

View File

@@ -360,7 +360,7 @@ PVAL AllocateValue(PGLOBAL g, void *value, short type, short prec)
valp = new(g) TYPVAL<char>(*(char *)value, TYPE_TINY); valp = new(g) TYPVAL<char>(*(char *)value, TYPE_TINY);
break; break;
default: default:
sprintf(g->Message, MSG(BAD_VALUE_TYPE), type); snprintf(g->Message, sizeof(g->Message), MSG(BAD_VALUE_TYPE), type);
return NULL; return NULL;
} // endswitch Type } // endswitch Type
@@ -421,7 +421,7 @@ PVAL AllocateValue(PGLOBAL g, int type, int len, int prec,
valp = new(g) BINVAL(g, (void*)NULL, len, prec); valp = new(g) BINVAL(g, (void*)NULL, len, prec);
break; break;
default: default:
sprintf(g->Message, MSG(BAD_VALUE_TYPE), type); snprintf(g->Message, sizeof(g->Message), MSG(BAD_VALUE_TYPE), type);
return NULL; return NULL;
} // endswitch type } // endswitch type
@@ -493,7 +493,7 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns)
break; break;
default: default:
sprintf(g->Message, MSG(BAD_VALUE_TYPE), newtype); snprintf(g->Message, sizeof(g->Message), MSG(BAD_VALUE_TYPE), newtype);
return NULL; return NULL;
} // endswitch type } // endswitch type
@@ -1189,7 +1189,7 @@ bool TYPVAL<TYPE>::Compall(PGLOBAL g, PVAL *vp, int np, OPVAL op)
Tval = MY_MAX(val[0], val[1]); Tval = MY_MAX(val[0], val[1]);
break; break;
default: default:
// sprintf(g->Message, MSG(BAD_EXP_OPER), op); // snprintf(g->Message, sizeof(g->Message), MSG(BAD_EXP_OPER), op);
strcpy(g->Message, "Function not supported"); strcpy(g->Message, "Function not supported");
return true; return true;
} // endswitch op } // endswitch op
@@ -1435,7 +1435,7 @@ void TYPVAL<PSZ>::SetValue(int n)
int k = sprintf(buf, "%d", n); int k = sprintf(buf, "%d", n);
if (k > Len) { if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); snprintf(g->Message, sizeof(g->Message), MSG(VALSTR_TOO_LONG), buf, Len);
throw 138; throw 138;
} else } else
SetValue_psz(buf); SetValue_psz(buf);
@@ -1453,7 +1453,7 @@ void TYPVAL<PSZ>::SetValue(uint n)
int k = sprintf(buf, "%u", n); int k = sprintf(buf, "%u", n);
if (k > Len) { if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); snprintf(g->Message, sizeof(g->Message), MSG(VALSTR_TOO_LONG), buf, Len);
throw 138; throw 138;
} else } else
SetValue_psz(buf); SetValue_psz(buf);
@@ -1489,7 +1489,7 @@ void TYPVAL<PSZ>::SetValue(longlong n)
int k = sprintf(buf, "%lld", n); int k = sprintf(buf, "%lld", n);
if (k > Len) { if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); snprintf(g->Message, sizeof(g->Message), MSG(VALSTR_TOO_LONG), buf, Len);
throw 138; throw 138;
} else } else
SetValue_psz(buf); SetValue_psz(buf);
@@ -1507,7 +1507,7 @@ void TYPVAL<PSZ>::SetValue(ulonglong n)
int k = sprintf(buf, "%llu", n); int k = sprintf(buf, "%llu", n);
if (k > Len) { if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); snprintf(g->Message, sizeof(g->Message), MSG(VALSTR_TOO_LONG), buf, Len);
throw 138; throw 138;
} else } else
SetValue_psz(buf); SetValue_psz(buf);
@@ -1532,7 +1532,7 @@ void TYPVAL<PSZ>::SetValue(double f)
break; break;
if (k > Len) { if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); snprintf(g->Message, sizeof(g->Message), MSG(VALSTR_TOO_LONG), buf, Len);
throw 138; throw 138;
} else } else
SetValue_psz(buf); SetValue_psz(buf);
@@ -1700,7 +1700,7 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]); SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]);
break; break;
default: default:
// sprintf(g->Message, MSG(BAD_EXP_OPER), op); // snprintf(g->Message, sizeof(g->Message), MSG(BAD_EXP_OPER), op);
strcpy(g->Message, "Function not supported"); strcpy(g->Message, "Function not supported");
return true; return true;
} // endswitch op } // endswitch op
@@ -2398,7 +2398,7 @@ bool DTVAL::SetFormat(PGLOBAL g, PVAL valp)
DTVAL *vp; DTVAL *vp;
if (valp->GetType() != TYPE_DATE) { if (valp->GetType() != TYPE_DATE) {
sprintf(g->Message, MSG(NO_FORMAT_TYPE), valp->GetType()); snprintf(g->Message, sizeof(g->Message), MSG(NO_FORMAT_TYPE), valp->GetType());
return true; return true;
} else } else
vp = (DTVAL*)valp; vp = (DTVAL*)valp;

View File

@@ -92,7 +92,7 @@ int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add)
if (!(tdbp = cat->GetTable(g, tablep))) if (!(tdbp = cat->GetTable(g, tablep)))
rc = RC_NF; rc = RC_NF;
else if (!tdbp->GetDef()->Indexable()) { else if (!tdbp->GetDef()->Indexable()) {
sprintf(g->Message, MSG(TABLE_NO_INDEX), name); snprintf(g->Message, sizeof(g->Message), MSG(TABLE_NO_INDEX), name);
rc = RC_NF; rc = RC_NF;
} else if ((rc = ((PTDBASE)tdbp)->MakeIndex(g, pxdf, add)) == RC_INFO) } else if ((rc = ((PTDBASE)tdbp)->MakeIndex(g, pxdf, add)) == RC_INFO)
rc = RC_OK; // No or remote index rc = RC_OK; // No or remote index
@@ -351,7 +351,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
Record.Size = n * sizeof(int); Record.Size = n * sizeof(int);
if (!PlgDBalloc(g, NULL, Record)) { if (!PlgDBalloc(g, NULL, Record)) {
sprintf(g->Message, MSG(MEM_ALLOC_ERR), "index", n); snprintf(g->Message, sizeof(g->Message), MSG(MEM_ALLOC_ERR), "index", n);
goto err; // Error goto err; // Error
} // endif } // endif
@@ -362,7 +362,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
colp = To_Cols[k]; colp = To_Cols[k];
if (!kdfp) { if (!kdfp) {
sprintf(g->Message, MSG(INT_COL_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(INT_COL_ERROR),
(colp) ? colp->GetName() : "???"); (colp) ? colp->GetName() : "???");
goto err; // Error goto err; // Error
} // endif kdfp } // endif kdfp
@@ -470,7 +470,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
case RC_EF: case RC_EF:
goto end_of_file; goto end_of_file;
default: default:
sprintf(g->Message, MSG(RC_READING), rc, Tdbp->Name); snprintf(g->Message, sizeof(g->Message), MSG(RC_READING), rc, Tdbp->Name);
goto err; goto err;
} // endswitch rc } // endswitch rc
@@ -479,7 +479,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
/* future direct access. */ /* future direct access. */
/*******************************************************************/ /*******************************************************************/
if (nkey == n) { if (nkey == n) {
sprintf(g->Message, MSG(TOO_MANY_KEYS), nkey); snprintf(g->Message, sizeof(g->Message), MSG(TOO_MANY_KEYS), nkey);
return true; return true;
} else } else
To_Rec[nkey] = Tdbp->GetRecpos(); To_Rec[nkey] = Tdbp->GetRecpos();
@@ -534,14 +534,14 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
Index.Size = Num_K * sizeof(int); Index.Size = Num_K * sizeof(int);
if (!PlgDBalloc(g, NULL, Index)) { if (!PlgDBalloc(g, NULL, Index)) {
sprintf(g->Message, MSG(MEM_ALLOC_ERR), "index", Num_K); snprintf(g->Message, sizeof(g->Message), MSG(MEM_ALLOC_ERR), "index", Num_K);
goto err; // Error goto err; // Error
} // endif alloc } // endif alloc
Offset.Size = (Num_K + 1) * sizeof(int); Offset.Size = (Num_K + 1) * sizeof(int);
if (!PlgDBalloc(g, NULL, Offset)) { if (!PlgDBalloc(g, NULL, Offset)) {
sprintf(g->Message, MSG(MEM_ALLOC_ERR), "offset", Num_K + 1); snprintf(g->Message, sizeof(g->Message), MSG(MEM_ALLOC_ERR), "offset", Num_K + 1);
goto err; // Error goto err; // Error
} // endif alloc } // endif alloc
@@ -840,7 +840,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
case RECFM_CSV: ftype = ".cnx"; break; case RECFM_CSV: ftype = ".cnx"; break;
case RECFM_DBF: ftype = ".dbx"; break; case RECFM_DBF: ftype = ".dbx"; break;
default: default:
sprintf(g->Message, MSG(INVALID_FTYPE), Tdbp->Ftype); snprintf(g->Message, sizeof(g->Message), MSG(INVALID_FTYPE), Tdbp->Ftype);
return true; return true;
} // endswitch Ftype } // endswitch Ftype
@@ -994,7 +994,7 @@ bool XINDEX::Init(PGLOBAL g)
case RECFM_CSV: ftype = ".cnx"; break; case RECFM_CSV: ftype = ".cnx"; break;
case RECFM_DBF: ftype = ".dbx"; break; case RECFM_DBF: ftype = ".dbx"; break;
default: default:
sprintf(g->Message, MSG(INVALID_FTYPE), Tdbp->Ftype); snprintf(g->Message, sizeof(g->Message), MSG(INVALID_FTYPE), Tdbp->Ftype);
return true; return true;
} // endswitch Ftype } // endswitch Ftype
@@ -1048,7 +1048,7 @@ bool XINDEX::Init(PGLOBAL g)
// The test on ID was suppressed because MariaDB can change an index ID // The test on ID was suppressed because MariaDB can change an index ID
// when other indexes are added or deleted // when other indexes are added or deleted
if (/*nv[0] != ID ||*/ nv[1] != Nk) { if (/*nv[0] != ID ||*/ nv[1] != Nk) {
sprintf(g->Message, MSG(BAD_INDEX_FILE), fn); snprintf(g->Message, sizeof(g->Message), MSG(BAD_INDEX_FILE), fn);
if (trace(1)) if (trace(1))
htrc("nv[0]=%d ID=%d nv[1]=%d Nk=%d\n", nv[0], ID, nv[1], Nk); htrc("nv[0]=%d ID=%d nv[1]=%d Nk=%d\n", nv[0], ID, nv[1], Nk);
@@ -1064,7 +1064,7 @@ bool XINDEX::Init(PGLOBAL g)
Offset.Size = Ndif * sizeof(int); Offset.Size = Ndif * sizeof(int);
if (!PlgDBalloc(g, NULL, Offset)) { if (!PlgDBalloc(g, NULL, Offset)) {
sprintf(g->Message, MSG(MEM_ALLOC_ERR), "offset", Ndif); snprintf(g->Message, sizeof(g->Message), MSG(MEM_ALLOC_ERR), "offset", Ndif);
goto err; goto err;
} // endif } // endif
@@ -1081,7 +1081,7 @@ bool XINDEX::Init(PGLOBAL g)
n = nv[3]; // n was just an evaluated max value n = nv[3]; // n was just an evaluated max value
if (nv[3] != n) { if (nv[3] != n) {
sprintf(g->Message, MSG(OPT_NOT_MATCH), fn); snprintf(g->Message, sizeof(g->Message), MSG(OPT_NOT_MATCH), fn);
goto err; goto err;
} // endif } // endif
@@ -1097,7 +1097,7 @@ bool XINDEX::Init(PGLOBAL g)
Record.Size = Num_K * sizeof(int); Record.Size = Num_K * sizeof(int);
if (!PlgDBalloc(g, NULL, Record)) { if (!PlgDBalloc(g, NULL, Record)) {
sprintf(g->Message, MSG(MEM_ALLOC_ERR), "index", Num_K); snprintf(g->Message, sizeof(g->Message), MSG(MEM_ALLOC_ERR), "index", Num_K);
goto err; goto err;
} // endif } // endif
@@ -1121,7 +1121,7 @@ bool XINDEX::Init(PGLOBAL g)
if (nv[4] != colp->GetResultType() || !colp->GetValue() || if (nv[4] != colp->GetResultType() || !colp->GetValue() ||
(nv[3] != colp->GetValue()->GetClen() && nv[4] != TYPE_STRING)) { (nv[3] != colp->GetValue()->GetClen() && nv[4] != TYPE_STRING)) {
sprintf(g->Message, MSG(XCOL_MISMATCH), colp->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(XCOL_MISMATCH), colp->GetName());
goto err; // Error goto err; // Error
} // endif GetKey } // endif GetKey
@@ -1248,7 +1248,7 @@ bool XINDEX::MapInit(PGLOBAL g)
case RECFM_CSV: ftype = ".cnx"; break; case RECFM_CSV: ftype = ".cnx"; break;
case RECFM_DBF: ftype = ".dbx"; break; case RECFM_DBF: ftype = ".dbx"; break;
default: default:
sprintf(g->Message, MSG(INVALID_FTYPE), Tdbp->Ftype); snprintf(g->Message, sizeof(g->Message), MSG(INVALID_FTYPE), Tdbp->Ftype);
return true; return true;
} // endswitch Ftype } // endswitch Ftype
@@ -1311,7 +1311,7 @@ bool XINDEX::MapInit(PGLOBAL g)
// when other indexes are added or deleted // when other indexes are added or deleted
if (/*nv0 != ID ||*/ nv[1] != Nk) { if (/*nv0 != ID ||*/ nv[1] != Nk) {
// Not this index // Not this index
sprintf(g->Message, MSG(BAD_INDEX_FILE), fn); snprintf(g->Message, sizeof(g->Message), MSG(BAD_INDEX_FILE), fn);
if (trace(1)) if (trace(1))
htrc("nv0=%d ID=%d nv[1]=%d Nk=%d\n", nv0, ID, nv[1], Nk); htrc("nv0=%d ID=%d nv[1]=%d Nk=%d\n", nv0, ID, nv[1], Nk);
@@ -1336,7 +1336,7 @@ bool XINDEX::MapInit(PGLOBAL g)
n = nv[3]; // n was just an evaluated max value n = nv[3]; // n was just an evaluated max value
if (nv[3] != n) { if (nv[3] != n) {
sprintf(g->Message, MSG(OPT_NOT_MATCH), fn); snprintf(g->Message, sizeof(g->Message), MSG(OPT_NOT_MATCH), fn);
goto err; goto err;
} // endif } // endif
@@ -1370,7 +1370,7 @@ bool XINDEX::MapInit(PGLOBAL g)
if (nv[4] != colp->GetResultType() || !colp->GetValue() || if (nv[4] != colp->GetResultType() || !colp->GetValue() ||
(nv[3] != colp->GetValue()->GetClen() && nv[4] != TYPE_STRING)) { (nv[3] != colp->GetValue()->GetClen() && nv[4] != TYPE_STRING)) {
sprintf(g->Message, MSG(XCOL_MISMATCH), colp->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(XCOL_MISMATCH), colp->GetName());
goto err; // Error goto err; // Error
} // endif GetKey } // endif GetKey
@@ -1463,7 +1463,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk)
case RECFM_CSV: ftype = ".cnx"; break; case RECFM_CSV: ftype = ".cnx"; break;
case RECFM_DBF: ftype = ".dbx"; break; case RECFM_DBF: ftype = ".dbx"; break;
default: default:
sprintf(g->Message, MSG(INVALID_FTYPE), Tdbp->Ftype); snprintf(g->Message, sizeof(g->Message), MSG(INVALID_FTYPE), Tdbp->Ftype);
return true; return true;
} // endswitch Ftype } // endswitch Ftype
@@ -1510,7 +1510,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk)
// The test on ID was suppressed because MariaDB can change an index ID // The test on ID was suppressed because MariaDB can change an index ID
// when other indexes are added or deleted // when other indexes are added or deleted
if (/*nv[0] != ID ||*/ nv[1] != Nk) { if (/*nv[0] != ID ||*/ nv[1] != Nk) {
sprintf(g->Message, MSG(BAD_INDEX_FILE), fn); snprintf(g->Message, sizeof(g->Message), MSG(BAD_INDEX_FILE), fn);
if (trace(1)) if (trace(1))
htrc("nv[0]=%d ID=%d nv[1]=%d Nk=%d\n", nv[0], ID, nv[1], Nk); htrc("nv[0]=%d ID=%d nv[1]=%d Nk=%d\n", nv[0], ID, nv[1], Nk);
@@ -1531,7 +1531,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk)
n = nv[3]; // n was just an evaluated max value n = nv[3]; // n was just an evaluated max value
if (nv[3] != n) { if (nv[3] != n) {
sprintf(g->Message, MSG(OPT_NOT_MATCH), fn); snprintf(g->Message, sizeof(g->Message), MSG(OPT_NOT_MATCH), fn);
goto err; goto err;
} // endif } // endif
#endif // 0 #endif // 0
@@ -1553,7 +1553,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk)
if (nv[4] != colp->GetResultType() || if (nv[4] != colp->GetResultType() ||
(nv[3] != colp->GetValue()->GetClen() && nv[4] != TYPE_STRING)) { (nv[3] != colp->GetValue()->GetClen() && nv[4] != TYPE_STRING)) {
sprintf(g->Message, MSG(XCOL_MISMATCH), colp->GetName()); snprintf(g->Message, sizeof(g->Message), MSG(XCOL_MISMATCH), colp->GetName());
goto err; // Error goto err; // Error
} // endif GetKey } // endif GetKey
@@ -2336,7 +2336,7 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
case MODE_WRITE: pmod = "wb"; break; case MODE_WRITE: pmod = "wb"; break;
case MODE_INSERT: pmod = "ab"; break; case MODE_INSERT: pmod = "ab"; break;
default: default:
sprintf(g->Message, MSG(BAD_FUNC_MODE), "Xopen", mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FUNC_MODE), "Xopen", mode);
return true; return true;
} // endswitch mode } // endswitch mode
@@ -2352,7 +2352,7 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
/* Position the cursor at end of file so ftell returns file size. */ /* Position the cursor at end of file so ftell returns file size. */
/*******************************************************************/ /*******************************************************************/
if (fseek(Xfile, 0, SEEK_END)) { if (fseek(Xfile, 0, SEEK_END)) {
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek"); snprintf(g->Message, sizeof(g->Message), MSG(FUNC_ERRNO), errno, "Xseek");
return true; return true;
} // endif } // endif
@@ -2377,7 +2377,7 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
} else if (mode == MODE_READ && id >= 0) { } else if (mode == MODE_READ && id >= 0) {
// Get offset from the header // Get offset from the header
if (fread(noff, sizeof(IOFF), MAX_INDX, Xfile) != MAX_INDX) { if (fread(noff, sizeof(IOFF), MAX_INDX, Xfile) != MAX_INDX) {
sprintf(g->Message, MSG(XFILE_READERR), errno); snprintf(g->Message, sizeof(g->Message), MSG(XFILE_READERR), errno);
return true; return true;
} // endif MAX_INDX } // endif MAX_INDX
@@ -2386,7 +2386,7 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
// Position the cursor at the offset of this index // Position the cursor at the offset of this index
if (fseek(Xfile, noff[id].v.Low, SEEK_SET)) { if (fseek(Xfile, noff[id].v.Low, SEEK_SET)) {
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek"); snprintf(g->Message, sizeof(g->Message), MSG(FUNC_ERRNO), errno, "Xseek");
return true; return true;
} // endif } // endif
@@ -2406,7 +2406,7 @@ bool XFILE::Seek(PGLOBAL g, int low, int high __attribute__((unused)),
#endif // !_DEBUG #endif // !_DEBUG
if (fseek(Xfile, low, origin)) { if (fseek(Xfile, low, origin)) {
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek"); snprintf(g->Message, sizeof(g->Message), MSG(FUNC_ERRNO), errno, "Xseek");
return true; return true;
} // endif } // endif
@@ -2419,7 +2419,7 @@ bool XFILE::Seek(PGLOBAL g, int low, int high __attribute__((unused)),
bool XFILE::Read(PGLOBAL g, void *buf, int n, int size) bool XFILE::Read(PGLOBAL g, void *buf, int n, int size)
{ {
if (fread(buf, size, n, Xfile) != (size_t)n) { if (fread(buf, size, n, Xfile) != (size_t)n) {
sprintf(g->Message, MSG(XFILE_READERR), errno); snprintf(g->Message, sizeof(g->Message), MSG(XFILE_READERR), errno);
return true; return true;
} // endif size } // endif size
@@ -2434,7 +2434,7 @@ int XFILE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc)
int niw = (int)fwrite(buf, size, n, Xfile); int niw = (int)fwrite(buf, size, n, Xfile);
if (niw != n) { if (niw != n) {
sprintf(g->Message, MSG(XFILE_WRITERR), strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(XFILE_WRITERR), strerror(errno));
rc = true; rc = true;
} // endif size } // endif size
@@ -2510,7 +2510,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
IOFF noff[MAX_INDX]; IOFF noff[MAX_INDX];
if (Hfile != INVALID_HANDLE_VALUE) { if (Hfile != INVALID_HANDLE_VALUE) {
sprintf(g->Message, MSG(FILE_OPEN_YET), filename); snprintf(g->Message, sizeof(g->Message), MSG(FILE_OPEN_YET), filename);
return true; return true;
} // endif } // endif
@@ -2541,7 +2541,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
creation = OPEN_EXISTING; creation = OPEN_EXISTING;
break; break;
default: default:
sprintf(g->Message, MSG(BAD_FUNC_MODE), "Xopen", mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FUNC_MODE), "Xopen", mode);
return true; return true;
} // endswitch } // endswitch
@@ -2550,7 +2550,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
if (Hfile == INVALID_HANDLE_VALUE) { if (Hfile == INVALID_HANDLE_VALUE) {
rc = GetLastError(); rc = GetLastError();
sprintf(g->Message, MSG(OPEN_ERROR), rc, mode, filename); snprintf(g->Message, sizeof(g->Message), MSG(OPEN_ERROR), rc, mode, filename);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)filename, sizeof(filename), NULL); (LPTSTR)filename, sizeof(filename), NULL);
@@ -2569,7 +2569,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
rc = SetFilePointer(Hfile, 0, &high, FILE_END); rc = SetFilePointer(Hfile, 0, &high, FILE_END);
if (rc == INVALID_SET_FILE_POINTER && (drc = GetLastError()) != NO_ERROR) { if (rc == INVALID_SET_FILE_POINTER && (drc = GetLastError()) != NO_ERROR) {
sprintf(g->Message, MSG(ERROR_IN_SFP), drc); snprintf(g->Message, sizeof(g->Message), MSG(ERROR_IN_SFP), drc);
CloseHandle(Hfile); CloseHandle(Hfile);
Hfile = INVALID_HANDLE_VALUE; Hfile = INVALID_HANDLE_VALUE;
return true; return true;
@@ -2590,7 +2590,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
rc = ReadFile(Hfile, noff, sizeof(noff), &drc, NULL); rc = ReadFile(Hfile, noff, sizeof(noff), &drc, NULL);
if (!rc) { if (!rc) {
sprintf(g->Message, MSG(XFILE_READERR), GetLastError()); snprintf(g->Message, sizeof(g->Message), MSG(XFILE_READERR), GetLastError());
return true; return true;
} // endif rc } // endif rc
@@ -2599,7 +2599,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
(PLONG)&noff[id].v.High, FILE_BEGIN); (PLONG)&noff[id].v.High, FILE_BEGIN);
if (rc == INVALID_SET_FILE_POINTER) { if (rc == INVALID_SET_FILE_POINTER) {
sprintf(g->Message, MSG(FUNC_ERRNO), GetLastError(), "SetFilePointer"); snprintf(g->Message, sizeof(g->Message), MSG(FUNC_ERRNO), GetLastError(), "SetFilePointer");
return true; return true;
} // endif } // endif
@@ -2624,7 +2624,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
oflag |= (O_WRONLY | O_APPEND); oflag |= (O_WRONLY | O_APPEND);
break; break;
default: default:
sprintf(g->Message, MSG(BAD_FUNC_MODE), "Xopen", mode); snprintf(g->Message, sizeof(g->Message), MSG(BAD_FUNC_MODE), "Xopen", mode);
return true; return true;
} // endswitch } // endswitch
@@ -2647,7 +2647,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
/* Position the cursor at end of file so ftell returns file size. */ /* Position the cursor at end of file so ftell returns file size. */
/*******************************************************************/ /*******************************************************************/
if (!(NewOff.Val = (longlong)lseek64(Hfile, 0LL, SEEK_END))) { if (!(NewOff.Val = (longlong)lseek64(Hfile, 0LL, SEEK_END))) {
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Seek"); snprintf(g->Message, sizeof(g->Message), MSG(FUNC_ERRNO), errno, "Seek");
return true; return true;
} // endif } // endif
@@ -2667,7 +2667,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
} else if (mode == MODE_READ && id >= 0) { } else if (mode == MODE_READ && id >= 0) {
// Get offset from the header // Get offset from the header
if (read(Hfile, noff, sizeof(noff)) != sizeof(noff)) { if (read(Hfile, noff, sizeof(noff)) != sizeof(noff)) {
sprintf(g->Message, MSG(READ_ERROR), "Index file", strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), "Index file", strerror(errno));
return true; return true;
} // endif read } // endif read
@@ -2676,9 +2676,9 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
// Position the cursor at the offset of this index // Position the cursor at the offset of this index
if (lseek64(Hfile, noff[id].Val, SEEK_SET) < 0) { if (lseek64(Hfile, noff[id].Val, SEEK_SET) < 0) {
sprintf(g->Message, "(XHUGE)lseek64: %s (%lld)", strerror(errno), noff[id].Val); snprintf(g->Message, sizeof(g->Message), "(XHUGE)lseek64: %s (%lld)", strerror(errno), noff[id].Val);
printf("%s\n", g->Message); printf("%s\n", g->Message);
// sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Hseek"); // snprintf(g->Message, sizeof(g->Message), MSG(FUNC_ERRNO), errno, "Hseek");
return true; return true;
} // endif lseek64 } // endif lseek64
@@ -2698,7 +2698,7 @@ bool XHUGE::Seek(PGLOBAL g, int low, int high, int origin)
DWORD rc = SetFilePointer(Hfile, low, &hi, origin); DWORD rc = SetFilePointer(Hfile, low, &hi, origin);
if (rc == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) { if (rc == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) {
sprintf(g->Message, MSG(FUNC_ERROR), "Xseek"); snprintf(g->Message, sizeof(g->Message), MSG(FUNC_ERROR), "Xseek");
return true; return true;
} // endif } // endif
@@ -2707,7 +2707,7 @@ bool XHUGE::Seek(PGLOBAL g, int low, int high, int origin)
+ (off64_t)high * ((off64_t)0x100 * (off64_t)0x1000000); + (off64_t)high * ((off64_t)0x100 * (off64_t)0x1000000);
if (lseek64(Hfile, pos, origin) < 0) { if (lseek64(Hfile, pos, origin) < 0) {
sprintf(g->Message, MSG(ERROR_IN_LSK), errno); snprintf(g->Message, sizeof(g->Message), MSG(ERROR_IN_LSK), errno);
if (trace(1)) if (trace(1))
htrc("lseek64 error %d\n", errno); htrc("lseek64 error %d\n", errno);
@@ -2748,7 +2748,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
sprintf(g->Message, MSG(READ_ERROR), "index file", buf); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), "index file", buf);
rc = true; rc = true;
} // endif brc } // endif brc
#else // UNIX #else // UNIX
@@ -2758,7 +2758,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size)
htrc("Hfile=%d n=%d size=%d count=%d\n", Hfile, n, size, count); htrc("Hfile=%d n=%d size=%d count=%d\n", Hfile, n, size, count);
if (read(Hfile, buf, count) != count) { if (read(Hfile, buf, count) != count) {
sprintf(g->Message, MSG(READ_ERROR), "Index file", strerror(errno)); snprintf(g->Message, sizeof(g->Message), MSG(READ_ERROR), "Index file", strerror(errno));
if (trace(1)) if (trace(1))
htrc("read error %d\n", errno); htrc("read error %d\n", errno);
@@ -2788,7 +2788,7 @@ int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0,
(LPTSTR)msg, sizeof(msg), NULL); (LPTSTR)msg, sizeof(msg), NULL);
sprintf(g->Message, MSG(WRITING_ERROR), "index file", msg); snprintf(g->Message, sizeof(g->Message), MSG(WRITING_ERROR), "index file", msg);
rc = true; rc = true;
} // endif size } // endif size
@@ -2800,7 +2800,7 @@ int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc)
nbw = write(Hfile, buf, count); nbw = write(Hfile, buf, count);
if (nbw != (signed)count) { if (nbw != (signed)count) {
sprintf(g->Message, MSG(WRITING_ERROR), snprintf(g->Message, sizeof(g->Message), MSG(WRITING_ERROR),
"index file", strerror(errno)); "index file", strerror(errno));
rc = true; rc = true;
} // endif nbw } // endif nbw
@@ -3017,7 +3017,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
// Currently no indexing on NULL columns // Currently no indexing on NULL columns
if (colp->IsNullable() && kln) { if (colp->IsNullable() && kln) {
sprintf(g->Message, "Cannot index nullable column %s", colp->GetName()); snprintf(g->Message, sizeof(g->Message), "Cannot index nullable column %s", colp->GetName());
return true; return true;
} // endif nullable } // endif nullable
@@ -3040,7 +3040,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
Keys.Size = (size_t)n * (size_t)Klen; Keys.Size = (size_t)n * (size_t)Klen;
if (!PlgDBalloc(g, NULL, Keys)) { if (!PlgDBalloc(g, NULL, Keys)) {
sprintf(g->Message, MSG(KEY_ALLOC_ERROR), Klen, n); snprintf(g->Message, sizeof(g->Message), MSG(KEY_ALLOC_ERROR), Klen, n);
return true; // Error return true; // Error
} // endif } // endif
@@ -3158,7 +3158,7 @@ bool KXYCOL::MakeBlockArray(PGLOBAL g, int nb, int size)
// Allocate the required memory // Allocate the required memory
if (!PlgDBalloc(g, NULL, Bkeys)) { if (!PlgDBalloc(g, NULL, Bkeys)) {
sprintf(g->Message, MSG(KEY_ALLOC_ERROR), Klen, nb); snprintf(g->Message, sizeof(g->Message), MSG(KEY_ALLOC_ERROR), Klen, nb);
return true; // Error return true; // Error
} // endif } // endif

View File

@@ -162,7 +162,7 @@ bool CONSTANT::Rephrase(PGLOBAL g, PSZ work)
sprintf(work + strlen(work), "%d", Value->GetTinyValue()); sprintf(work + strlen(work), "%d", Value->GetTinyValue());
break; break;
default: default:
sprintf(g->Message, MSG(BAD_CONST_TYPE), Value->GetType()); snprintf(g->Message, sizeof(g->Message), MSG(BAD_CONST_TYPE), Value->GetType());
return false; return false;
} // endswitch } // endswitch