diff options
author | Amar Tumballi <amar@gluster.com> | 2009-07-17 22:41:44 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-07-20 14:28:53 -0700 |
commit | 632cce5e720acaa28ab680a6850f2aa8289d4628 (patch) | |
tree | 8cdc8afe41411ecde9c7a80b49162088bb09e08e /libglusterfs/src/authenticate.c | |
parent | 5be3c142978257032bd11ad420382859fc204702 (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/authenticate.c')
-rw-r--r-- | libglusterfs/src/authenticate.c | 12 |
1 files changed, 10 insertions, 2 deletions
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", |