summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorHumble Devassy Chirammal <hchiramm@redhat.com>2015-04-07 18:43:30 +0530
committerNiels de Vos <ndevos@redhat.com>2015-06-19 04:07:24 -0700
commitce04ac4f21c59a24e251c66657c9721f80a8494a (patch)
tree4add68d61dc1c89894eab6d0a1208526d5edd7d4 /libglusterfs
parent08086c1c631bc8c1336452c9cd270f1191721b18 (diff)
libglusterfs: avoid crash due to ctx being NULL
>Reviewed-on: http://review.gluster.org/10155 >Tested-by: Gluster Build System <jenkins@build.gluster.com> >Reviewed-by: Niels de Vos <ndevos@redhat.com> >Reviewed-by: Vijay Bellur <vbellur@redhat.com> >(cherry picked from commit b855aa062927ea4845f56d2d1a1a2a8af3dc4192) BUG : 1233559 Change-Id: Ib667ed42f0b598baddb829b448d6efc3d8e044f1 Signed-off-by: Humble Devassy Chirammal <hchiramm@redhat.com> Reviewed-on: http://review.gluster.org/10969 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/logging.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index 774dd092660..e8fca2db916 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -125,7 +125,7 @@ gf_log_get_loglevel (void)
if (ctx)
return ctx->log.loglevel;
else
- /* return global defaluts (see gf_log_globals_init) */
+ /* return global defaults (see gf_log_globals_init) */
return GF_LOG_INFO;
}
@@ -689,6 +689,10 @@ gf_log_init (void *data, const char *file, const char *ident)
ctx = data;
+ if (ctx == NULL) {
+ fprintf (stderr, "ERROR: ctx is NULL\n");
+ return -1;
+ }
if (ident) {
ctx->log.ident = gf_strdup (ident);
}
@@ -798,6 +802,9 @@ _gf_log_callingfn (const char *domain, const char *file, const char *function,
this = THIS;
ctx = this->ctx;
+ if (!ctx)
+ goto out;
+
if (ctx->log.gf_log_xl_log_set) {
if (this->loglevel && (level > this->loglevel))
goto out;
@@ -1517,6 +1524,9 @@ gf_glusterlog_log_repetitions (glusterfs_ctx_t *ctx, const char *domain,
char *footer = NULL;
char *msg = NULL;
+ if (!ctx)
+ goto err;
+
gf_log_rotate (ctx);
gf_time_fmt (timestr_latest, sizeof timestr_latest, latest.tv_sec,
@@ -1776,6 +1786,9 @@ __gf_log_inject_timer_event (glusterfs_ctx_t *ctx)
int ret = -1;
struct timespec timeout = {0,};
+ if (!ctx)
+ goto out;
+
if (ctx->log.log_flush_timer) {
gf_timer_call_cancel (ctx, ctx->log.log_flush_timer);
ctx->log.log_flush_timer = NULL;
@@ -1853,6 +1866,9 @@ _gf_msg_internal (const char *domain, const char *file, const char *function,
this = THIS;
ctx = this->ctx;
+ if (!ctx)
+ goto out;
+
GET_FILE_NAME_TO_LOG (file, basename);
ret = gettimeofday (&tv, NULL);
@@ -2112,6 +2128,9 @@ _gf_log (const char *domain, const char *file, const char *function, int line,
this = THIS;
ctx = this->ctx;
+ if (!ctx)
+ goto out;
+
if (ctx->log.gf_log_xl_log_set) {
if (this->loglevel && (level > this->loglevel))
goto out;
@@ -2322,6 +2341,9 @@ gf_cmd_log_init (const char *filename)
this = THIS;
ctx = this->ctx;
+ if (!ctx)
+ return -1;
+
if (!filename){
gf_log (this->name, GF_LOG_CRITICAL, "gf_cmd_log_init: no "
"filename specified\n");
@@ -2373,6 +2395,10 @@ gf_cmd_log (const char *domain, const char *fmt, ...)
glusterfs_ctx_t *ctx = NULL;
ctx = THIS->ctx;
+
+ if (!ctx)
+ return -1;
+
if (!ctx->log.cmdlogfile)
return -1;