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/xlator.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libglusterfs/src/xlator.c') diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 351e2434467..a3f8ea8fc2e 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -679,6 +679,7 @@ int32_t xlator_set_type (xlator_t *xl, const char *type) { + int ret = 0; char *name = NULL; void *handle = NULL; volume_opt_list_t *vol_opt = NULL; @@ -690,7 +691,11 @@ xlator_set_type (xlator_t *xl, xl->type = strdup (type); - asprintf (&name, "%s/%s.so", XLATORDIR, type); + ret = asprintf (&name, "%s/%s.so", XLATORDIR, type); + if (-1 == ret) { + gf_log ("xlator", GF_LOG_ERROR, "asprintf failed"); + return -1; + } gf_log ("xlator", GF_LOG_TRACE, "attempt to load file %s", name); -- cgit