summaryrefslogtreecommitdiff
path: root/bin/bbackupd/BackupDaemon.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-12-22 23:09:31 +0000
committerChris Wilson <chris+github@qwirx.com>2014-12-22 23:09:31 +0000
commit6622bfe4eb59a2f38f7012349525ec64f0368118 (patch)
treeb116a1ec4a429ad3ecf0d8817488557f196782b1 /bin/bbackupd/BackupDaemon.cpp
parente88418c0145ddeba97116e49074dd8e2e9edea7a (diff)
Replace sprintf() with snprintf(), fixes compile warnings on OpenBSD.
And compile errors on recent MinGW.
Diffstat (limited to 'bin/bbackupd/BackupDaemon.cpp')
-rw-r--r--bin/bbackupd/BackupDaemon.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp
index 32b7b2d6..bd2c179b 100644
--- a/bin/bbackupd/BackupDaemon.cpp
+++ b/bin/bbackupd/BackupDaemon.cpp
@@ -2047,14 +2047,18 @@ void BackupDaemon::WaitOnCommandSocket(box_time_t RequiredDelay, bool &DoSyncFla
// Send a header line summarising the configuration and current state
const Configuration &conf(GetConfiguration());
- char summary[256];
- int summarySize = sprintf(summary, "bbackupd: %d %d %d %d\nstate %d\n",
- conf.GetKeyValueBool("AutomaticBackup"),
- conf.GetKeyValueInt("UpdateStoreInterval"),
- conf.GetKeyValueInt("MinimumFileAge"),
- conf.GetKeyValueInt("MaxUploadWait"),
- mState);
- mapCommandSocketInfo->mpConnectedSocket->Write(summary, summarySize);
+ std::ostringstream hello;
+ hello << "bbackupd: " <<
+ (conf.GetKeyValueBool("AutomaticBackup") ? 1 : 0)
+ << " " <<
+ conf.GetKeyValueInt("UpdateStoreInterval")
+ << " " <<
+ conf.GetKeyValueInt("MinimumFileAge")
+ << " " <<
+ conf.GetKeyValueInt("MaxUploadWait")
+ << "\nstate " << mState << "\n";
+ mapCommandSocketInfo->mpConnectedSocket->Write(
+ hello.str());
// Set the timeout to something very small, so we don't wait too long on waiting
// for any incoming data
@@ -2965,11 +2969,8 @@ void BackupDaemon::SetState(int State)
// If there's a command socket connected, then inform it -- disconnecting from the
// command socket if there's an error
- char newState[64];
- sprintf(newState, "state %d", State);
- std::string message = newState;
-
- message += "\n";
+ std::ostringstream msg;
+ msg << "state " << State << "\n";
if(!mapCommandSocketInfo.get())
{
@@ -2984,8 +2985,7 @@ void BackupDaemon::SetState(int State)
// Something connected to the command socket, tell it about the new state
try
{
- mapCommandSocketInfo->mpConnectedSocket->Write(message.c_str(),
- message.length());
+ mapCommandSocketInfo->mpConnectedSocket->Write(msg.str());
}
catch(ConnectionException &ce)
{