diff options
author | Michal Čihař <nijel@debian.org> | 2016-12-12 14:52:14 +0100 |
---|---|---|
committer | Michal Čihař <nijel@debian.org> | 2016-12-12 14:52:14 +0100 |
commit | 403eca6af192d9a1e57d7c8ea1181b3c6137bc4e (patch) | |
tree | 247e0730e4e15428cbe0113d1fcecae996eb8f79 /smsd | |
parent | 4293c6165a17103edbdacb9971a8724bba275d32 (diff) |
New upstream version 1.38.0
Diffstat (limited to 'smsd')
-rw-r--r-- | smsd/core.c | 11 | ||||
-rw-r--r-- | smsd/core.h | 2 | ||||
-rw-r--r-- | smsd/services/files.c | 8 | ||||
-rw-r--r-- | smsd/services/sql.c | 3 |
4 files changed, 19 insertions, 5 deletions
diff --git a/smsd/core.c b/smsd/core.c index 4d3641b..9700b65 100644 --- a/smsd/core.c +++ b/smsd/core.c @@ -707,6 +707,10 @@ GSM_Error SMSD_ReadConfig(const char *filename, GSM_SMSDConfig *Config, gboolean fullpath[PATH_MAX] = 0; } Config->shm_key = ftok(fullpath, SMSD_SHM_KEY); + if (Config->shm_key < 0) { + fprintf(stderr, "Failed to generate SHM key!\n"); + return FALSE; + } #endif #ifdef WIN32 if (filename == NULL) { @@ -1164,7 +1168,9 @@ gboolean SMSD_RunOn(const char *command, GSM_MultiSMSMessage *sms, GSM_SMSDConfi /* Close write end of pipe */ close(pipefd[1]); - fcntl(pipefd[0], F_SETFL, O_NONBLOCK); + if (fcntl(pipefd[0], F_SETFL, O_NONBLOCK) != 0) { + SMSD_Log(DEBUG_ERROR, Config, "Failed to set nonblocking pipe to child!"); + } i = 0; do { @@ -1853,7 +1859,8 @@ GSM_Error SMSD_InitSharedMemory(GSM_SMSDConfig *Config, gboolean writable) /* Initial shared memory content */ if (writable) { Config->Status->Version = SMSD_SHM_VERSION; - strcpy(Config->Status->PhoneID, Config->PhoneID); + strncpy(Config->Status->PhoneID, Config->PhoneID, sizeof(Config->Status->PhoneID)); + Config->Status->PhoneID[sizeof(Config->Status->PhoneID) - 1] = 0; sprintf(Config->Status->Client, "Gammu %s on %s compiler %s", GAMMU_VERSION, GetOS(), diff --git a/smsd/core.h b/smsd/core.h index 31a0a98..0ac45b7 100644 --- a/smsd/core.h +++ b/smsd/core.h @@ -15,8 +15,8 @@ #include "services/sql-core.h" #endif -#define SMSD_SHM_KEY (0xface) #define SMSD_SHM_VERSION (2) +#define SMSD_SHM_KEY (0xfa << 16 || SMSD_SHM_VERSION) #define SMSD_DB_VERSION (16) #include "log.h" diff --git a/smsd/services/files.c b/smsd/services/files.c index 6001755..574c162 100644 --- a/smsd/services/files.c +++ b/smsd/services/files.c @@ -416,7 +416,13 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage * sms, GSM_SMSDConf } else if (i == 4) { /* OUT<priority>_<phone number>_<serialno>.txt */ pos1 = strchr(FileName, '_'); + if (pos1 == NULL) { + return ERR_BUG; + } pos2 = strchr(++pos1, '_'); + if (pos2 == NULL) { + return ERR_BUG; + } phlen = strlen(pos1) - strlen(pos2); } else { /* something wrong */ @@ -564,7 +570,7 @@ static GSM_Error SMSDFiles_CreateOutboxSMS(GSM_MultiSMSMessage * sms, GSM_SMSDCo 1900 + timeinfo->tm_year, timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, buffer2, j, ext); strcpy(FullName, Config->outboxpath); strcat(FullName, FileName); - fd = open(FileName, O_CREAT | O_EXCL, 0644); + fd = open(FullName, O_CREAT | O_EXCL, 0644); if (fd >= 0) { close(fd); break; diff --git a/smsd/services/sql.c b/smsd/services/sql.c index d3a0191..543f145 100644 --- a/smsd/services/sql.c +++ b/smsd/services/sql.c @@ -1001,7 +1001,8 @@ static GSM_Error SMSDSQL_FindOutboxSMS(GSM_MultiSMSMessage * sms, GSM_SMSDConfig sms->Number++; if (i == 1) { - strcpy(Config->CreatorID, db->GetString(Config, &res, 10)); + strncpy(Config->CreatorID, db->GetString(Config, &res, 10), sizeof(Config->CreatorID)); + Config->CreatorID[sizeof(Config->CreatorID) - 1] = 0; Config->relativevalidity = (int)db->GetNumber(Config, &res, 8); Config->currdeliveryreport = db->GetBool(Config, &res, 9); |