summaryrefslogtreecommitdiffstats
path: root/booster
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-05-24 23:05:26 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-06-02 23:36:31 -0700
commit86a428263aaf15b8b98f29a9d959fef3de6caa6b (patch)
treea74e94de1692d2bfcd71c38909d7a729a0e6ac7f /booster
parent66ba0e8e885f21adf0259ac61629efb8df747d37 (diff)
booster: Clean-up handling of log/fstab env variables
Handle two cases when deciding log/fstab file: 1. It turns out that that strdup or strlen doesnt actually check for NULL before trying to do its thing with the string so it seg-faults on seeing a NULL char pointer. 2. getenv can return an empty string if the env var was exported as: $ export GLUSTEFS_BOOSTER_LOG= Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'booster')
-rw-r--r--booster/src/booster.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/booster/src/booster.c b/booster/src/booster.c
index b51cc25..cb35be5 100644
--- a/booster/src/booster.c
+++ b/booster/src/booster.c
@@ -376,6 +376,7 @@ mbp_open (int fd, dev_t file_devno)
FILE *specfp = NULL;
int32_t file_size = -1;
int ret = -1;
+ char *logfile = NULL;
glusterfs_handle_t handle = NULL;
glusterfs_init_params_t ctx = {
@@ -409,8 +410,13 @@ mbp_open (int fd, dev_t file_devno)
goto out;
fseek (specfp, 0L, SEEK_SET);
- ctx.logfile = strdup (getenv (BOOSTER_LOG_ENV_VAR));
- if (!ctx.logfile)
+ logfile = getenv (BOOSTER_LOG_ENV_VAR);
+ if (logfile) {
+ if (strlen (logfile) > 0)
+ ctx.logfile = strdup (logfile);
+ else
+ ctx.logfile = strdup (BOOSTER_DEFAULT_LOG);
+ } else
ctx.logfile = strdup (BOOSTER_DEFAULT_LOG);
ctx.specfp = specfp;
@@ -1178,10 +1184,13 @@ booster_init (void)
* socket calls will fall-back to the real API.
*/
booster_conf_path = getenv (BOOSTER_CONF_ENV_VAR);
- if (booster_conf_path == NULL)
+ if (booster_conf_path != NULL) {
+ if (strlen (booster_conf_path) > 0)
+ ret = booster_configure (booster_conf_path);
+ else
+ ret = booster_configure (DEFAULT_BOOSTER_CONF);
+ } else
ret = booster_configure (DEFAULT_BOOSTER_CONF);
- else
- ret = booster_configure (booster_conf_path);
if (ret == 0)
gf_log ("booster", GF_LOG_DEBUG, "booster is inited");