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: call to localtime needs return value check

Spotted by Coverity Scan

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

diff --git a/common/liblogthread/liblogthread.c b/common/liblogthread/liblogthread.c
index ba96a2a..4f8354a 100644
--- a/common/liblogthread/liblogthread.c
+++ b/common/liblogthread/liblogthread.c
@@ -42,8 +42,15 @@ static FILE *logt_logfile_fp;
static char *_time(time_t *t)
{
static char buf[64];
+ struct tm *tm;
+
+ tm = localtime(t);
+ if (!tm) {
+ strncpy(buf, "unknown time", sizeof(buf) - 1);
+ } else {
+ strftime(buf, sizeof(buf), "%b %d %T", tm);
+ }

- strftime(buf, sizeof(buf), "%b %d %T", localtime(t));
return buf;
}

--
1.7.4.4
 
Old 10-10-2011, 08:45 AM
"Fabio M. Di Nitto"
 
Default liblogthread: call to localtime needs return value check

Spotted by Coverity Scan

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

diff --git a/common/liblogthread/liblogthread.c b/common/liblogthread/liblogthread.c
index ba96a2a..4f8354a 100644
--- a/common/liblogthread/liblogthread.c
+++ b/common/liblogthread/liblogthread.c
@@ -42,8 +42,15 @@ static FILE *logt_logfile_fp;
static char *_time(time_t *t)
{
static char buf[64];
+ struct tm *tm;
+
+ tm = localtime(t);
+ if (!tm) {
+ strncpy(buf, "unknown time", sizeof(buf) - 1);
+ } else {
+ strftime(buf, sizeof(buf), "%b %d %T", tm);
+ }

- strftime(buf, sizeof(buf), "%b %d %T", localtime(t));
return buf;
}

--
1.7.4.4
 

Thread Tools




All times are GMT. The time now is 04:33 AM.

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