summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/logging.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2009-07-17 22:41:44 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-07-20 14:28:53 -0700
commit632cce5e720acaa28ab680a6850f2aa8289d4628 (patch)
tree8cdc8afe41411ecde9c7a80b49162088bb09e08e /libglusterfs/src/logging.c
parent5be3c142978257032bd11ad420382859fc204702 (diff)
fix build warnings in 'libglusterfs/'
return value of 'asprintf' was not checked, and the flow was continuing without returning error, which could cause potential segfaults in code (mostly possible during ENOMEM case). Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 130 (build warnings) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=130
Diffstat (limited to 'libglusterfs/src/logging.c')
-rw-r--r--libglusterfs/src/logging.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index c345faf03..7e1e56f87 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -430,7 +430,8 @@ _gf_log (const char *domain, const char *file, const char *function, int line,
char timestr[256];
char *str1, *str2, *msg;
- size_t len = 0;
+ size_t len = 0;
+ int ret = 0;
static char *level_strings[] = {"", /* NONE */
"C", /* CRITICAL */
@@ -488,12 +489,18 @@ log:
else
basename = file;
- asprintf (&str1, "[%s] %s [%s:%d:%s] %s: ",
- timestr, level_strings[level],
- basename, line, function,
- domain);
+ ret = asprintf (&str1, "[%s] %s [%s:%d:%s] %s: ",
+ timestr, level_strings[level],
+ basename, line, function,
+ domain);
+ if (-1 == ret) {
+ goto out;
+ }
- vasprintf (&str2, fmt, ap);
+ ret = vasprintf (&str2, fmt, ap);
+ if (-1 == ret) {
+ goto out;
+ }
va_end (ap);
@@ -540,11 +547,15 @@ struct _client_log *client_logs = NULL;
static void
client_log_init (struct _client_log *cl, char *identifier)
{
+ int ret = 0;
char *path = NULL;
cl->identifier = identifier;
- asprintf (&path, "%s.client-%s", filename, identifier);
+ ret = asprintf (&path, "%s.client-%s", filename, identifier);
+ if (-1 == ret) {
+ return;
+ }
cl->file = fopen (path, "a");
FREE (path);