summaryrefslogtreecommitdiff
path: root/storage/connect
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-06-13 19:46:16 +0300
committerMonty <monty@mariadb.org>2021-06-14 20:37:34 +0300
commit6653206467b746e9743e50c55b8db8ca7462ce4f (patch)
tree9ad47f6d1669477d63cb56a86f3af509e612b01d /storage/connect
parent6e282e7efc0be5cb3b08c42a653a46a2a4a91edf (diff)
downloadmariadb-git-6653206467b746e9743e50c55b8db8ca7462ce4f.tar.gz
Fixed compiler warnings
- Replace strncpy() with strmake() to ensure things are \0 terminated - Initialized some variables that caused compiler warnings - Increased buffer that caused warnings from strncpy One warning from InnoDB, others from Connect.
Diffstat (limited to 'storage/connect')
-rw-r--r--storage/connect/filamdbf.cpp3
-rw-r--r--storage/connect/jsonudf.cpp18
-rw-r--r--storage/connect/tabxml.cpp18
3 files changed, 21 insertions, 18 deletions
diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp
index c8571cea559..9654c59f0fe 100644
--- a/storage/connect/filamdbf.cpp
+++ b/storage/connect/filamdbf.cpp
@@ -55,6 +55,7 @@
#define NO_FUNC
#include "plgcnx.h" // For DB types
#include "resource.h"
+#include "m_string.h" // For strmake
/****************************************************************************/
/* Definitions. */
@@ -732,7 +733,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
return true;
} // endswitch c
- strncpy(descp->Name, cdp->GetName(), 11);
+ strmake(descp->Name, cdp->GetName(), sizeof(descp->Name)-1);
descp->Type = c;
descp->Length = (uchar)cdp->GetLong();
} // endif Flags
diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp
index c633993863c..af12f42f1d4 100644
--- a/storage/connect/jsonudf.cpp
+++ b/storage/connect/jsonudf.cpp
@@ -11,7 +11,7 @@
#include <mysqld.h>
#include <mysql.h>
#include <sql_error.h>
-#include <stdio.h>
+#include <m_string.h>
#include "jsonudf.h"
@@ -1475,16 +1475,16 @@ static PBSON MakeBinResult(PGLOBAL g, UDF_ARGS *args, PJSON top, ulong len, int
if ((bsnp->Filename = (char*)args->args[0])) {
bsnp->Filename = MakePSZ(g, args, 0);
- strncpy(bsnp->Msg, bsnp->Filename, BMX);
+ strmake(bsnp->Msg, bsnp->Filename, BMX-1);
} else
- strncpy(bsnp->Msg, "null filename", BMX);
+ strmake(bsnp->Msg, "null filename", BMX-1);
} else if (IsJson(args, 0) == 3) {
PBSON bsp = (PBSON)args->args[0];
if (bsp->Filename) {
bsnp->Filename = bsp->Filename;
- strncpy(bsnp->Msg, bsp->Filename, BMX);
+ strmake(bsnp->Msg, bsp->Filename, BMX-1);
bsnp->Pretty = bsp->Pretty;
} else
strcpy(bsnp->Msg, "Json Binary item");
@@ -4758,7 +4758,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
bsp = NULL;
if (!bsp && (bsp = JbinAlloc(g, args, initid->max_length, NULL)))
- strncpy(bsp->Msg, g->Message, BMX);
+ strmake(bsp->Msg, g->Message, BMX-1);
// Keep result of constant function
g->Xchk = (initid->const_item) ? bsp : NULL;
@@ -4829,7 +4829,7 @@ char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else
if ((bsp = JbinAlloc(g, args, initid->max_length, NULL)))
- strncpy(bsp->Msg, g->Message, BMX);
+ strmake(bsp->Msg, g->Message, BMX-1);
// Keep result of constant function
g->Xchk = (initid->const_item) ? bsp : NULL;
@@ -5051,7 +5051,7 @@ char *jbin_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else
if ((bsp = JbinAlloc(g, args, initid->max_length, NULL)))
- strncpy(bsp->Msg, g->Message, BMX);
+ strmake(bsp->Msg, g->Message, BMX-1);
// Keep result of constant function
g->Xchk = (initid->const_item) ? bsp : NULL;
@@ -5107,7 +5107,7 @@ char *jbin_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else
if ((bsp = JbinAlloc(g, args, initid->max_length, NULL)))
- strncpy(bsp->Msg, g->Message, BMX);
+ strmake(bsp->Msg, g->Message, BMX-1);
// Keep result of constant function
g->Xchk = (initid->const_item) ? bsp : NULL;
@@ -5166,7 +5166,7 @@ char *jbin_object_key(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else
if ((bsp = JbinAlloc(g, args, initid->max_length, NULL)))
- strncpy(bsp->Msg, g->Message, BMX);
+ strmake(bsp->Msg, g->Message, BMX-1);
// Keep result of constant function
g->Xchk = (initid->const_item) ? bsp : NULL;
diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp
index dcebe18dd36..9575d917dd4 100644
--- a/storage/connect/tabxml.cpp
+++ b/storage/connect/tabxml.cpp
@@ -12,9 +12,8 @@
/* Include required compiler header files. */
/***********************************************************************/
#include "my_global.h"
-#include <stdio.h>
+#include <m_string.h>
#include <fcntl.h>
-#include <errno.h>
#if defined(__WIN__)
#include <io.h>
#include <winsock2.h>
@@ -252,10 +251,11 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
more:
if (vp->atp) {
- size_t z = sizeof(colname) - 1;
- strncpy(colname, vp->atp->GetName(g), z);
- colname[z] = 0;
- strncat(xcol->Name, colname, XLEN(xcol->Name));
+ size_t z = sizeof(colname) - 1;
+ size_t xlen= strlen(xcol->Name);
+ strmake(colname, vp->atp->GetName(g), z);
+ strmake(xcol->Name + xlen, colname,
+ sizeof(xcol->Name) - 1 - xlen);
switch (vp->atp->GetText(g, buf, sizeof(buf))) {
case RC_INFO:
@@ -272,11 +272,13 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
strncat(fmt, colname, XLEN(fmt));
} else {
+ size_t xlen;
if (tdp->Usedom && node->GetType() != 1)
continue;
- strncpy(colname, node->GetName(g), sizeof(colname));
- strncat(xcol->Name, colname, XLEN(xcol->Name));
+ xlen= strlen(xcol->Name);
+ strmake(colname, node->GetName(g), sizeof(colname)-1);
+ strmake(xcol->Name + xlen, colname, sizeof(xcol->Name) - 1 - xlen);
if (j)
strncat(fmt, colname, XLEN(fmt));