summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/hostinfo.cc2
-rw-r--r--base/inifile.cc5
-rw-r--r--base/stats/events.cc11
3 files changed, 10 insertions, 8 deletions
diff --git a/base/hostinfo.cc b/base/hostinfo.cc
index cb5c04efc..6d07c957e 100644
--- a/base/hostinfo.cc
+++ b/base/hostinfo.cc
@@ -70,7 +70,7 @@ procInfo(char *filename, char *target)
while (fp && !feof(fp) && !done) {
if (fgets(line, 80, fp)) {
if (strncmp(line, target, strlen(target)) == 0) {
- sprintf(format, "%s %%lld", target);
+ snprintf(format, sizeof(format), "%s %%lld", target);
sscanf(line, format, &usage);
fclose(fp);
diff --git a/base/inifile.cc b/base/inifile.cc
index 862e4082f..cbb506c8b 100644
--- a/base/inifile.cc
+++ b/base/inifile.cc
@@ -79,7 +79,8 @@ IniFile::loadCPP(const string &file, vector<char *> &cppArgs)
tmpf.close();
- char *cfile = strcpy(new char[file.size() + 1], file.c_str());
+ char *cfile = strncpy(new char[file.size() + 1], file.c_str(),
+ file.size());
char *dir = dirname(cfile);
char *dir_arg = NULL;
if (*dir != '.') {
@@ -87,7 +88,7 @@ IniFile::loadCPP(const string &file, vector<char *> &cppArgs)
arg += dir;
dir_arg = new char[arg.size() + 1];
- strcpy(dir_arg, arg.c_str());
+ strncpy(dir_arg, arg.c_str(), arg.size());
}
delete [] cfile;
diff --git a/base/stats/events.cc b/base/stats/events.cc
index dd7ec2ccf..e083cf0da 100644
--- a/base/stats/events.cc
+++ b/base/stats/events.cc
@@ -140,6 +140,10 @@ InsertEvent::insert(const string &stat)
void
InsertEvent::flush()
{
+ static const char query_header[] = "INSERT INTO "
+ "events(ev_event, ev_run, ev_tick)"
+ "values";
+
if (size) {
MySQL::Connection &mysql = MySqlDB.conn();
assert(mysql.connected());
@@ -147,12 +151,9 @@ InsertEvent::flush()
}
query[0] = '\0';
- size = 0;
+ size = sizeof(query_header);
first = true;
- strcpy(query, "INSERT INTO "
- "events(ev_event, ev_run, ev_tick)"
- "values");
- size = strlen(query);
+ memcpy(query, query_header, size);
}
void