From 632cce5e720acaa28ab680a6850f2aa8289d4628 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 17 Jul 2009 22:41:44 +0000 Subject: 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 BUG: 130 (build warnings) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=130 --- libglusterfs/src/authenticate.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'libglusterfs/src/authenticate.c') diff --git a/libglusterfs/src/authenticate.c b/libglusterfs/src/authenticate.c index 3587a41d7..24c840b5e 100644 --- a/libglusterfs/src/authenticate.c +++ b/libglusterfs/src/authenticate.c @@ -42,7 +42,8 @@ init (dict_t *this, auth_handle_t *auth_handle = NULL; auth_fn_t authenticate = NULL; int *error = NULL; - + int ret = 0; + /* It gets over written */ error = data; @@ -57,7 +58,14 @@ init (dict_t *this, key = "addr"; } - asprintf (&auth_file, "%s/%s.so", LIBDIR, key); + ret = asprintf (&auth_file, "%s/%s.so", LIBDIR, key); + if (-1 == ret) { + gf_log ("authenticate", GF_LOG_ERROR, "asprintf failed"); + dict_set (this, key, data_from_dynptr (NULL, 0)); + *error = -1; + return; + } + handle = dlopen (auth_file, RTLD_LAZY); if (!handle) { gf_log ("authenticate", GF_LOG_ERROR, "dlopen(%s): %s\n", -- cgit