FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 10-10-2011, 08:45 AM
"Fabio M. Di Nitto"
 
Default liblogthread: make sure there is space for end string

Spotted by Coverity Scan

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
:100644 100644 4f8354a... 384f042... M common/liblogthread/liblogthread.c
common/liblogthread/liblogthread.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/liblogthread/liblogthread.c b/common/liblogthread/liblogthread.c
index 4f8354a..384f042 100644
--- a/common/liblogthread/liblogthread.c
+++ b/common/liblogthread/liblogthread.c
@@ -128,7 +128,7 @@ static void _logt_print(int level, char *buf)
head_ent = head_ent % num_ents;
pending_ents++;

- strncpy(e->str, buf, ENTRY_STR_LEN);
+ strncpy(e->str, buf, ENTRY_STR_LEN - 1);
e->level = level;
e->time = time(NULL);
out:
@@ -172,9 +172,9 @@ static void _conf(const char *name, int mode, int syslog_facility,
logt_syslog_priority = syslog_priority;
logt_logfile_priority = logfile_priority;
if (name)
- strncpy(logt_name, name, PATH_MAX);
+ strncpy(logt_name, name, PATH_MAX - 1);
if (logfile)
- strncpy(logt_logfile, logfile, PATH_MAX);
+ strncpy(logt_logfile, logfile, PATH_MAX - 1);

if (logt_mode & LOG_MODE_OUTPUT_FILE && logt_logfile[0]) {
if (logt_logfile_fp) {
@@ -255,11 +255,11 @@ int logt_reinit(void)
memset(name_tmp, 0, sizeof(name_tmp));
memset(file_tmp, 0, sizeof(file_tmp));

- strncpy(name_tmp, logt_name, sizeof(name_tmp));
+ strncpy(name_tmp, logt_name, sizeof(name_tmp) - 1);
if (!strlen(name_tmp))
return -1;
if (strlen(logt_logfile))
- strncpy(file_tmp, logt_logfile, sizeof(file_tmp));
+ strncpy(file_tmp, logt_logfile, sizeof(file_tmp) - 1);

return logt_init(name_tmp, logt_mode, logt_syslog_facility,
logt_syslog_priority, logt_logfile_priority,
--
1.7.4.4
 
Old 10-10-2011, 08:45 AM
"Fabio M. Di Nitto"
 
Default liblogthread: make sure there is space for end string

Spotted by Coverity Scan

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
:100644 100644 4f8354a... 384f042... M common/liblogthread/liblogthread.c
common/liblogthread/liblogthread.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/liblogthread/liblogthread.c b/common/liblogthread/liblogthread.c
index 4f8354a..384f042 100644
--- a/common/liblogthread/liblogthread.c
+++ b/common/liblogthread/liblogthread.c
@@ -128,7 +128,7 @@ static void _logt_print(int level, char *buf)
head_ent = head_ent % num_ents;
pending_ents++;

- strncpy(e->str, buf, ENTRY_STR_LEN);
+ strncpy(e->str, buf, ENTRY_STR_LEN - 1);
e->level = level;
e->time = time(NULL);
out:
@@ -172,9 +172,9 @@ static void _conf(const char *name, int mode, int syslog_facility,
logt_syslog_priority = syslog_priority;
logt_logfile_priority = logfile_priority;
if (name)
- strncpy(logt_name, name, PATH_MAX);
+ strncpy(logt_name, name, PATH_MAX - 1);
if (logfile)
- strncpy(logt_logfile, logfile, PATH_MAX);
+ strncpy(logt_logfile, logfile, PATH_MAX - 1);

if (logt_mode & LOG_MODE_OUTPUT_FILE && logt_logfile[0]) {
if (logt_logfile_fp) {
@@ -255,11 +255,11 @@ int logt_reinit(void)
memset(name_tmp, 0, sizeof(name_tmp));
memset(file_tmp, 0, sizeof(file_tmp));

- strncpy(name_tmp, logt_name, sizeof(name_tmp));
+ strncpy(name_tmp, logt_name, sizeof(name_tmp) - 1);
if (!strlen(name_tmp))
return -1;
if (strlen(logt_logfile))
- strncpy(file_tmp, logt_logfile, sizeof(file_tmp));
+ strncpy(file_tmp, logt_logfile, sizeof(file_tmp) - 1);

return logt_init(name_tmp, logt_mode, logt_syslog_facility,
logt_syslog_priority, logt_logfile_priority,
--
1.7.4.4
 

Thread Tools




All times are GMT. The time now is 07:48 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org