diff options
| -rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 43 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-protocol.c | 30 | 
2 files changed, 47 insertions, 26 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 759a9ec82c0..03a3598dfb7 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -123,6 +123,7 @@ out:  char *  stat_to_str (struct stat *stbuf)  { +        int   ret = 0;  	char *tmp_buf = NULL;  	uint64_t dev = stbuf->st_dev; @@ -144,25 +145,29 @@ stat_to_str (struct stat *stbuf)  	uint32_t ctime_nsec = ST_CTIM_NSEC(stbuf); -	asprintf (&tmp_buf, -		  GF_STAT_PRINT_FMT_STR, -		  dev, -		  ino, -		  mode, -		  nlink, -		  uid, -		  gid, -		  rdev, -		  size, -		  blksize, -		  blocks, -		  atime, -		  atime_nsec, -		  mtime, -		  mtime_nsec, -		  ctime, -		  ctime_nsec); - +	ret = asprintf (&tmp_buf, +                        GF_STAT_PRINT_FMT_STR, +                        dev, +                        ino, +                        mode, +                        nlink, +                        uid, +                        gid, +                        rdev, +                        size, +                        blksize, +                        blocks, +                        atime, +                        atime_nsec, +                        mtime, +                        mtime_nsec, +                        ctime, +                        ctime_nsec); +        if (-1 == ret) { +                gf_log ("protocol/server", GF_LOG_DEBUG,  +                        "asprintf failed while setting up stat buffer string"); +                return NULL; +        }  	return tmp_buf;  } diff --git a/xlators/protocol/server/src/server-protocol.c b/xlators/protocol/server/src/server-protocol.c index 7862ea47be7..00964698b7e 100644 --- a/xlators/protocol/server/src/server-protocol.c +++ b/xlators/protocol/server/src/server-protocol.c @@ -6520,9 +6520,15 @@ build_volfile_path (xlator_t *this, const char *key, char *path,                           * "../" in path                            */                          if (!strstr (key, "../")) { -                                asprintf (&filename, "%s/%s.vol",  -                                          CONFDIR, key); -                                free_filename = 1; +                                ret = asprintf (&filename, "%s/%s.vol",  +                                                CONFDIR, key); +                                if (-1 == ret) { +                                        gf_log (this->name, GF_LOG_ERROR, +                                                "asprintf failed to get " +                                                "volume file path"); +                                } else { +                                        free_filename = 1; +                                }                          } else {                                  gf_log (this->name, GF_LOG_DEBUG,                                          "%s: invalid key", key); @@ -6901,9 +6907,13 @@ mop_setvolume (call_frame_t *frame, xlator_t *bound_xl,  	ret = strcmp (version, GF_PROTOCOL_VERSION);  	if (ret != 0) { -		asprintf (&msg, -			  "protocol version mismatch: client(%s) - server(%s)", -			  version, GF_PROTOCOL_VERSION); +		ret = asprintf (&msg, "protocol version mismatch: client(%s) " +                                "- server(%s)", version, GF_PROTOCOL_VERSION); +                if (-1 == ret) { +                        gf_log (trans->xl->name, GF_LOG_ERROR, +                                "asprintf failed while setting up error msg"); +                        goto fail; +                }  		ret = dict_set_dynstr (reply, "ERROR", msg);  		if (ret < 0)  			gf_log (trans->xl->name, GF_LOG_DEBUG, @@ -6930,7 +6940,13 @@ mop_setvolume (call_frame_t *frame, xlator_t *bound_xl,  	xl = get_xlator_by_name (frame->this, name);  	if (xl == NULL) { -		asprintf (&msg, "remote-subvolume \"%s\" is not found", name); +		ret = asprintf (&msg, "remote-subvolume \"%s\" is not found",  +                                name); +                if (-1 == ret) { +                        gf_log (trans->xl->name, GF_LOG_ERROR, +                                "asprintf failed while setting error msg"); +                        goto fail; +                }  		ret = dict_set_dynstr (reply, "ERROR", msg);  		if (ret < 0)  			gf_log (trans->xl->name, GF_LOG_DEBUG,  | 
