mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fixing wrong sprintf() calls.
modified: storage/connect/filamap.cpp storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamtxt.cpp storage/connect/filamvct.cpp storage/connect/ha_connect.cc storage/connect/osutil.c storage/connect/plgdbutl.cpp storage/connect/plugutil.c storage/connect/tabfix.cpp storage/connect/tabxml.cpp storage/connect/user_connect.cc storage/connect/value.cpp storage/connect/xindex.cpp
This commit is contained in:
@@ -164,7 +164,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
|
|||||||
|
|
||||||
if (!(*g->Message))
|
if (!(*g->Message))
|
||||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||||
"map", rc, filename);
|
"map", (int) rc, filename);
|
||||||
|
|
||||||
#ifdef DEBTRACE
|
#ifdef DEBTRACE
|
||||||
htrc("%s\n", g->Message);
|
htrc("%s\n", g->Message);
|
||||||
|
@@ -731,7 +731,7 @@ 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), n, To_File);
|
sprintf(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
|
sprintf(g->Message, MSG(WRITE_STRERROR), To_Fbt->Fname
|
||||||
, strerror(errno));
|
, strerror(errno));
|
||||||
|
@@ -308,6 +308,7 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
|
|||||||
} else { // Mode == MODE_UPDATE
|
} else { // Mode == MODE_UPDATE
|
||||||
// T_Stream is the temporary stream or the table file stream itself
|
// T_Stream is the temporary stream or the table file stream itself
|
||||||
if (!T_Stream)
|
if (!T_Stream)
|
||||||
|
{
|
||||||
if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) {
|
if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) {
|
||||||
if (OpenTempFile(g))
|
if (OpenTempFile(g))
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
@@ -317,7 +318,7 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
T_Stream = Stream;
|
T_Stream = Stream;
|
||||||
|
}
|
||||||
Modif++; // Modified line in Update mode
|
Modif++; // Modified line in Update mode
|
||||||
} // endif Mode
|
} // endif Mode
|
||||||
|
|
||||||
@@ -488,7 +489,7 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (len != req) {
|
if (len != req) {
|
||||||
sprintf(g->Message, MSG(DEL_READ_ERROR), req, len);
|
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
|
||||||
return true;
|
return true;
|
||||||
} // endif len
|
} // endif len
|
||||||
|
|
||||||
@@ -1135,13 +1136,14 @@ int BGXFAM::WriteBuffer(PGLOBAL g)
|
|||||||
} else { // Mode == MODE_UPDATE
|
} else { // Mode == MODE_UPDATE
|
||||||
// Tfile is the temporary file or the table file handle itself
|
// Tfile is the temporary file or the table file handle itself
|
||||||
if (Tfile == INVALID_HANDLE_VALUE)
|
if (Tfile == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) {
|
if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) {
|
||||||
if (OpenTempFile(g))
|
if (OpenTempFile(g))
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
Tfile = Hfile;
|
Tfile = Hfile;
|
||||||
|
}
|
||||||
Modif++; // Modified line in Update mode
|
Modif++; // Modified line in Update mode
|
||||||
} // endif Mode
|
} // endif Mode
|
||||||
|
|
||||||
|
@@ -871,7 +871,7 @@ 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), req, len);
|
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
|
||||||
return true;
|
return true;
|
||||||
} // endif len
|
} // endif len
|
||||||
|
|
||||||
|
@@ -899,7 +899,7 @@ bool VCTFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (len != req) {
|
if (len != req) {
|
||||||
sprintf(g->Message, MSG(DEL_READ_ERROR), req, len);
|
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
|
||||||
return true;
|
return true;
|
||||||
} // endif len
|
} // endif len
|
||||||
|
|
||||||
@@ -1179,7 +1179,7 @@ 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), n, To_File);
|
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, To_File);
|
||||||
else
|
else
|
||||||
sprintf(g->Message, MSG(READ_ERROR),
|
sprintf(g->Message, MSG(READ_ERROR),
|
||||||
To_File, strerror(errno));
|
To_File, strerror(errno));
|
||||||
@@ -1362,7 +1362,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g)
|
|||||||
|
|
||||||
if (!(*g->Message))
|
if (!(*g->Message))
|
||||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||||
"map", rc, filename);
|
"map", (int) rc, filename);
|
||||||
|
|
||||||
#ifdef DEBTRACE
|
#ifdef DEBTRACE
|
||||||
htrc("%s\n", g->Message);
|
htrc("%s\n", g->Message);
|
||||||
@@ -2348,7 +2348,7 @@ bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *bn)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (len != req) {
|
if (len != req) {
|
||||||
sprintf(g->Message, MSG(DEL_READ_ERROR), req, len);
|
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
|
||||||
return true;
|
return true;
|
||||||
} // endif len
|
} // endif len
|
||||||
|
|
||||||
@@ -2533,7 +2533,7 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
|
|||||||
#else // !WIN32
|
#else // !WIN32
|
||||||
if (errno == NO_ERROR)
|
if (errno == NO_ERROR)
|
||||||
#endif // !WIN32
|
#endif // !WIN32
|
||||||
sprintf(g->Message, MSG(BAD_READ_NUMBER), n, fn);
|
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn);
|
||||||
else
|
else
|
||||||
sprintf(g->Message, MSG(READ_ERROR),
|
sprintf(g->Message, MSG(READ_ERROR),
|
||||||
fn, strerror(errno));
|
fn, strerror(errno));
|
||||||
@@ -2759,7 +2759,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i)
|
|||||||
|
|
||||||
if (!(*g->Message))
|
if (!(*g->Message))
|
||||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||||
"map", rc, filename);
|
"map", (int) rc, filename);
|
||||||
#ifdef DEBTRACE
|
#ifdef DEBTRACE
|
||||||
htrc("%s\n", g->Message);
|
htrc("%s\n", g->Message);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -2547,7 +2547,8 @@ int ha_connect::rnd_next(uchar *buf)
|
|||||||
ulonglong tb2= my_interval_timer();
|
ulonglong tb2= my_interval_timer();
|
||||||
double elapsed= (double) (tb2 - xp->tb1) / 1000000000ULL;
|
double elapsed= (double) (tb2 - xp->tb1) / 1000000000ULL;
|
||||||
DBUG_PRINT("rnd_next", ("rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n",
|
DBUG_PRINT("rnd_next", ("rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n",
|
||||||
rc, xp->nrd, xp->fnd, xp->nfd, elapsed));
|
rc, (uint) xp->nrd, (uint) xp->fnd,
|
||||||
|
(uint) xp->nfd, elapsed));
|
||||||
xp->tb1= tb2;
|
xp->tb1= tb2;
|
||||||
xp->fnd= xp->nfd= 0;
|
xp->fnd= xp->nfd= 0;
|
||||||
} // endif nrd
|
} // endif nrd
|
||||||
@@ -2887,7 +2888,8 @@ int ha_connect::external_lock(THD *thd, int lock_type)
|
|||||||
|
|
||||||
if (xtrace) {
|
if (xtrace) {
|
||||||
printf("%p external_lock: cmdtype=%d\n", this, thd->lex->sql_command);
|
printf("%p external_lock: cmdtype=%d\n", this, thd->lex->sql_command);
|
||||||
printf("Cmd=%s\n", thd->query_string);
|
printf("Cmd=%.*s\n", (int) thd->query_string.length(),
|
||||||
|
thd->query_string.str());
|
||||||
} // endif xtrace
|
} // endif xtrace
|
||||||
|
|
||||||
// Next code is temporarily replaced until sql_command is set
|
// Next code is temporarily replaced until sql_command is set
|
||||||
|
@@ -14,7 +14,7 @@ my_bool CloseFileHandle(HANDLE h)
|
|||||||
/* code to handle Linux and Solaris */
|
/* code to handle Linux and Solaris */
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
//#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
extern FILE *debug;
|
extern FILE *debug;
|
||||||
@@ -223,7 +223,7 @@ DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId,
|
|||||||
//if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER)
|
//if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER)
|
||||||
// return 0; /* means error */
|
// return 0; /* means error */
|
||||||
|
|
||||||
n = sprintf(buff, "Error code: %d", dwMessageId);
|
n = sprintf(buff, "Error code: %d", (int) dwMessageId);
|
||||||
strncpy(lpBuffer, buff, nSize);
|
strncpy(lpBuffer, buff, nSize);
|
||||||
return min(n, nSize);
|
return min(n, nSize);
|
||||||
} /* end of FormatMessage */
|
} /* end of FormatMessage */
|
||||||
|
@@ -164,7 +164,9 @@ global_open_error_msg(GLOBAL *g, int msgid, const char *path, const char *mode)
|
|||||||
|
|
||||||
case MSGID_OPEN_ERROR_AND_STRERROR:
|
case MSGID_OPEN_ERROR_AND_STRERROR:
|
||||||
len= snprintf(g->Message, sizeof(g->Message) - 1,
|
len= snprintf(g->Message, sizeof(g->Message) - 1,
|
||||||
MSG(OPEN_ERROR) "%s",// "Open error %d in mode %d on %s: %s"
|
//OPEN_ERROR does not work, as it wants mode %d (not %s)
|
||||||
|
//MSG(OPEN_ERROR) "%s",// "Open error %d in mode %d on %s: %s"
|
||||||
|
"Open error %d in mode %s on %s: %s",
|
||||||
errno, mode, path, strerror(errno));
|
errno, mode, path, strerror(errno));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1472,6 +1474,7 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!t->P1 || t->P1->Num == 50)
|
if (!t->P1 || t->P1->Num == 50)
|
||||||
|
{
|
||||||
if (!(tp = new TABPTR)) {
|
if (!(tp = new TABPTR)) {
|
||||||
PGLOBAL g = t->G;
|
PGLOBAL g = t->G;
|
||||||
|
|
||||||
@@ -1482,6 +1485,7 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
|
|||||||
tp->Num = 0;
|
tp->Num = 0;
|
||||||
t->P1 = tp;
|
t->P1 = tp;
|
||||||
} /* endif tp */
|
} /* endif tp */
|
||||||
|
}
|
||||||
|
|
||||||
t->P1->Old[t->P1->Num] = oldv;
|
t->P1->Old[t->P1->Num] = oldv;
|
||||||
t->P1->New[t->P1->Num++] = newv;
|
t->P1->New[t->P1->Num++] = newv;
|
||||||
|
@@ -459,7 +459,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
|||||||
|
|
||||||
sprintf(g->Message,
|
sprintf(g->Message,
|
||||||
"Not enough memory in %s area for request of %u (used=%d free=%d)",
|
"Not enough memory in %s area for request of %u (used=%d free=%d)",
|
||||||
pname, size, pph->To_Free, pph->FreeBlk);
|
pname, (uint) size, pph->To_Free, pph->FreeBlk);
|
||||||
|
|
||||||
#if defined(DEBUG2) || defined(DEBUG3)
|
#if defined(DEBUG2) || defined(DEBUG3)
|
||||||
htrc("%s\n", g->Message);
|
htrc("%s\n", g->Message);
|
||||||
|
@@ -471,7 +471,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, n, Long);
|
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
} // endif n
|
} // endif n
|
||||||
|
|
||||||
|
@@ -1199,7 +1199,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), Name, ValNode->GetType());
|
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
} // endif type
|
} // endif type
|
||||||
|
|
||||||
@@ -1392,7 +1392,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), Name, ValNode->GetType());
|
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
} // endif type
|
} // endif type
|
||||||
|
|
||||||
|
@@ -144,7 +144,7 @@ bool user_connect::CheckCleanup(void)
|
|||||||
last_query_id= thdp->query_id;
|
last_query_id= thdp->query_id;
|
||||||
|
|
||||||
if (xtrace)
|
if (xtrace)
|
||||||
printf("=====> Begin new query %d\n", last_query_id);
|
printf("=====> Begin new query %llu\n", last_query_id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // endif query_id
|
} // endif query_id
|
||||||
|
@@ -705,7 +705,7 @@ char *STRING::GetShortString(char *p, int n)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
char *STRING::GetIntString(char *p, int n)
|
char *STRING::GetIntString(char *p, int n)
|
||||||
{
|
{
|
||||||
sprintf(p, "%*d", n, atol(Strp));
|
sprintf(p, "%*ld", n, atol(Strp));
|
||||||
return p;
|
return p;
|
||||||
} // end of GetIntString
|
} // end of GetIntString
|
||||||
|
|
||||||
@@ -4336,7 +4336,7 @@ char *DFVAL::GetShortString(char *p, int n)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
char *DFVAL::GetIntString(char *p, int n)
|
char *DFVAL::GetIntString(char *p, int n)
|
||||||
{
|
{
|
||||||
sprintf(p, "%*ld", n, (int)Fval);
|
sprintf(p, "%*ld", n, (long) Fval);
|
||||||
return p;
|
return p;
|
||||||
} // end of GetIntString
|
} // end of GetIntString
|
||||||
|
|
||||||
|
@@ -2109,7 +2109,7 @@ bool XFILE::Open(PGLOBAL g, char *filename, 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), "Xseek", errno);
|
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek");
|
||||||
return true;
|
return true;
|
||||||
} // endif
|
} // endif
|
||||||
|
|
||||||
@@ -2140,7 +2140,7 @@ bool XFILE::Seek(PGLOBAL g, int low, int high, int origin)
|
|||||||
#endif // !_DEBUG
|
#endif // !_DEBUG
|
||||||
|
|
||||||
if (fseek(Xfile, low, origin)) {
|
if (fseek(Xfile, low, origin)) {
|
||||||
sprintf(g->Message, MSG(FUNC_ERRNO), "Xseek", errno);
|
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek");
|
||||||
return true;
|
return true;
|
||||||
} // endif
|
} // endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user