diff options
Diffstat (limited to 'storage/connect/tabbson.cpp')
-rw-r--r-- | storage/connect/tabbson.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/storage/connect/tabbson.cpp b/storage/connect/tabbson.cpp index 4cbb0e44e19..dfaf2284a72 100644 --- a/storage/connect/tabbson.cpp +++ b/storage/connect/tabbson.cpp @@ -39,6 +39,7 @@ #include "checklvl.h" #include "resource.h" #include "mycat.h" // for FNC_COL +#include "m_string.h" /***********************************************************************/ /* This should be an option. */ @@ -80,7 +81,7 @@ PQRYRES BSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) } // endif info if (GetIntegerTableOption(g, topt, "Multiple", 0)) { - strcpy(g->Message, "Cannot find column definition for multiple table"); + safe_strcpy(g->Message, sizeof(g->Message), "Cannot find column definition for multiple table"); return NULL; } // endif Multiple @@ -206,7 +207,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt) tdp->Uri = (dsn && *dsn ? dsn : NULL); if (!tdp->Fn && !tdp->Uri) { - strcpy(g->Message, MSG(MISSING_FNAME)); + safe_strcpy(g->Message, sizeof(g->Message), MSG(MISSING_FNAME)); return 0; } else topt->subtype = NULL; @@ -318,7 +319,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt) switch (tjnp->ReadDB(g)) { case RC_EF: - strcpy(g->Message, "Void json table"); + safe_strcpy(g->Message, sizeof(g->Message), "Void json table"); case RC_FX: goto err; default: @@ -328,7 +329,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt) } // endif pretty if (!(row = (jsp) ? bp->GetObject(jsp) : NULL)) { - strcpy(g->Message, "Can only retrieve columns from object rows"); + safe_strcpy(g->Message, sizeof(g->Message), "Can only retrieve columns from object rows"); goto err; } // endif row @@ -405,7 +406,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j) if (jvp && !bp->IsJson(jvp)) { if (JsonAllPath() && !fmt[bf]) - strcat(fmt, colname); + safe_strcat(fmt, sizeof(fmt), colname); jcol.Type = (JTYP)jvp->Type; @@ -439,7 +440,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j) jcol.Cbn = true; } else if (j < lvl && !Stringified(strfy, colname)) { if (!fmt[bf]) - strcat(fmt, colname); + safe_strcat(fmt, sizeof(fmt), colname); p = fmt + strlen(fmt); jsp = jvp; @@ -510,11 +511,11 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j) } else if (lvl >= 0) { if (Stringified(strfy, colname)) { if (!fmt[bf]) - strcat(fmt, colname); + safe_strcat(fmt, sizeof(fmt), colname); - strcat(fmt, ".*"); + safe_strcat(fmt, sizeof(fmt), ".*"); } else if (JsonAllPath() && !fmt[bf]) - strcat(fmt, colname); + safe_strcat(fmt, sizeof(fmt), colname); jcol.Type = TYPE_STRG; jcol.Len = sz; @@ -961,7 +962,7 @@ PVAL BCUTIL::ExpandArray(PGLOBAL g, PBVAL arp, int n) } // endif ars if (!(bvp = GetArrayValue(arp, (nodes[n].Rx = nodes[n].Nx)))) { - strcpy(g->Message, "Logical error expanding array"); + safe_strcpy(g->Message, sizeof(g->Message), "Logical error expanding array"); throw 666; } // endif jvp @@ -1146,7 +1147,7 @@ PBVAL BCUTIL::GetRow(PGLOBAL g) } else if (row->Type == TYPE_JAR) { AddArrayValue(row, (nwr = NewVal(type))); } else { - strcpy(g->Message, "Wrong type when writing new row"); + safe_strcpy(g->Message, sizeof(g->Message), "Wrong type when writing new row"); nwr = NULL; } // endif's @@ -1255,7 +1256,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m) // Allocate the parse work memory G = PlugInit(NULL, (size_t)Lrecl * (Pretty < 0 ? 3 : 5)); } else { - strcpy(g->Message, "LRECL is not defined"); + safe_strcpy(g->Message, sizeof(g->Message), "LRECL is not defined"); return NULL; } // endif Lrecl @@ -1295,7 +1296,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m) } else if (m == MODE_INSERT) { txfp = new(g) ZIPFAM(this); } else { - strcpy(g->Message, "UPDATE/DELETE not supported for ZIP"); + safe_strcpy(g->Message, sizeof(g->Message), "UPDATE/DELETE not supported for ZIP"); return NULL; } // endif's m #else // !ZIP_SUPPORT @@ -1325,10 +1326,10 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m) if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) { txfp = new(g) UNZFAM(this); } else if (m == MODE_INSERT) { - strcpy(g->Message, "INSERT supported only for zipped JSON when pretty=0"); + safe_strcpy(g->Message, sizeof(g->Message), "INSERT supported only for zipped JSON when pretty=0"); return NULL; } else { - strcpy(g->Message, "UPDATE/DELETE not supported for ZIP"); + safe_strcpy(g->Message, sizeof(g->Message), "UPDATE/DELETE not supported for ZIP"); return NULL; } // endif's m #else // !ZIP_SUPPORT @@ -1661,7 +1662,7 @@ bool TDBBSN::PrepareWriting(PGLOBAL g) strcat(s, ","); if ((signed)strlen(s) > Lrecl) { - strncpy(To_Line, s, Lrecl); + safe_strcpy(To_Line, Lrecl, s); snprintf(g->Message, sizeof(g->Message), "Line truncated (lrecl=%d)", Lrecl); return PushWarning(g, this); } else @@ -1764,7 +1765,7 @@ bool BSONCOL::CheckExpand(PGLOBAL g, int i, PSZ nm, bool b) Xpd = true; // Expandable object Nodes[i].Op = OP_EXP; } else if (b) { - strcpy(g->Message, "Cannot expand more than one branch"); + safe_strcpy(g->Message, sizeof(g->Message), "Cannot expand more than one branch"); return true; } // endif Xcol @@ -1975,7 +1976,7 @@ bool BSONCOL::ParseJpath(PGLOBAL g) if (SetArrayOptions(g, p, i, Nodes[i - 1].Key)) return true; else if (Xpd && Tbp->Mode == MODE_DELETE) { - strcpy(g->Message, "Cannot delete expanded columns"); + safe_strcpy(g->Message, sizeof(g->Message), "Cannot delete expanded columns"); return true; } // endif Xpd @@ -2098,7 +2099,7 @@ void BSONCOL::ReadColumn(PGLOBAL g) void BSONCOL::WriteColumn(PGLOBAL g) { if (Xpd && Tbp->Pretty < 2) { - strcpy(g->Message, "Cannot write expanded column when Pretty is not 2"); + safe_strcpy(g->Message, sizeof(g->Message), "Cannot write expanded column when Pretty is not 2"); throw 666; } // endif Xpd @@ -2128,7 +2129,7 @@ void BSONCOL::WriteColumn(PGLOBAL g) char *s = Value->GetCharValue(); if (!(jsp = Cp->ParseJson(g, s, strlen(s)))) { - strcpy(g->Message, s); + safe_strcpy(g->Message, sizeof(g->Message), s); throw 666; } // endif jsp @@ -2314,7 +2315,7 @@ int TDBBSON::MakeDocument(PGLOBAL g) if (!a && *p && *p != '[' && !IsNum(p)) { // obj is a key if (jsp->Type != TYPE_JOB) { - strcpy(g->Message, "Table path does not match the json file"); + safe_strcpy(g->Message, sizeof(g->Message), "Table path does not match the json file"); return RC_FX; } // endif Type @@ -2340,7 +2341,7 @@ int TDBBSON::MakeDocument(PGLOBAL g) } // endif p if (jsp->Type != TYPE_JAR) { - strcpy(g->Message, "Table path does not match the json file"); + safe_strcpy(g->Message, sizeof(g->Message), "Table path does not match the json file"); return RC_FX; } // endif Type @@ -2434,7 +2435,7 @@ void TDBBSON::ResetSize(void) int TDBBSON::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool) { if (pxdf) { - strcpy(g->Message, "JSON not indexable when pretty = 2"); + safe_strcpy(g->Message, sizeof(g->Message), "JSON not indexable when pretty = 2"); return RC_FX; } else return RC_OK; |