cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Fabio M. Di Nitto <fdinitto@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/4] liblogthread: make sure there is space for \0 end string
Date: Mon, 10 Oct 2011 10:45:19 +0200	[thread overview]
Message-ID: <299a950519a4cd1f983f1e383cf5b072bcbf9745.1318236099.git.fdinitto@redhat.com> (raw)
In-Reply-To: <1318236321-21955-1-git-send-email-fdinitto@redhat.com>

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



  parent reply	other threads:[~2011-10-10  8:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10  8:45 [Cluster-devel] [coverity] liblogthread Fabio M. Di Nitto
2011-10-10  8:45 ` [Cluster-devel] [PATCH 1/4] liblogthread: call to localtime needs return value check Fabio M. Di Nitto
2011-10-10  8:56   ` Steven Whitehouse
2011-10-10  8:45 ` Fabio M. Di Nitto [this message]
2011-10-10  8:45 ` [Cluster-devel] [PATCH 3/4] liblogthread: use snprintf as it is considered safer Fabio M. Di Nitto
2011-10-10  8:45 ` [Cluster-devel] [PATCH 4/4] liblogthread: make library thread safer Fabio M. Di Nitto
2011-10-10 14:54 ` [Cluster-devel] [coverity] liblogthread David Teigland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=299a950519a4cd1f983f1e383cf5b072bcbf9745.1318236099.git.fdinitto@redhat.com \
    --to=fdinitto@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).