diff options
author | Atin Mukherjee <amukherj@redhat.com> | 2014-04-08 17:10:25 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-05-03 08:20:06 -0700 |
commit | e73fc9939aecfa9f7955653d02f12243aba02fc6 (patch) | |
tree | f170c95f3b6622aa9fb2937dfef7742ea579a711 /cli/src | |
parent | c6f4504c12d35359986a08da222193057946570a (diff) |
glusterd : Volname, brickpath & volfpath length validation
While creating a volume and adding a brick validation for _POSIX_PATH_MAX is
done on absolute pathname instead of relative pathname due to which a brickpath
having less than _POSIX_PATH_MAX may also fail the validation if the directory
length is greater than (_POSIX_PATH_MAX -strlen(brickpath/volume name).
Also this fix addresses one cli response message correction which says the
volume file is too long instead of brick path is too long (when brickpath
length validation doesn't fail and vol file length validation fails.)
It is also important to note that with the current design of volfile naming, it
can not be guranteed that volname and brickpath can have max of _POSIX_PATH_MAX
characters.
Change-Id: I1283d1f9dea96ae797620002c8723719f26a866d
BUG: 1085330
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: http://review.gluster.org/7420
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 10 | ||||
-rw-r--r-- | cli/src/cli-cmd-volume.c | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index e7f41fa7203..a41c0800ac1 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -236,8 +236,11 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options if (strchr (volname, '/')) goto out; - if (strlen (volname) > 512) + if (strlen (volname) > GD_VOLUME_NAME_MAX) { + cli_err("Volume name exceeds %d characters.", + GD_VOLUME_NAME_MAX); goto out; + } for (i = 0; i < strlen (volname); i++) if (!isalnum (volname[i]) && (volname[i] != '_') && @@ -561,8 +564,11 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) if (strchr (volname, '/')) goto out; - if (strlen (volname) > 512) + if (strlen (volname) > GD_VOLUME_NAME_MAX) { + cli_err("Volname can not exceed %d characters.", + GD_VOLUME_NAME_MAX); goto out; + } for (i = 0; i < strlen (volname); i++) if (!isalnum (volname[i]) && (volname[i] != '_') && diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 83b923e360a..6072fcc5193 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -65,7 +65,7 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word, } else if (wordcount == 3) { ctx.flags = GF_CLI_GET_VOLUME; ctx.volname = (char *)words[2]; - if (strlen (ctx.volname) > 1024) { + if (strlen (ctx.volname) > GD_VOLUME_NAME_MAX) { cli_out ("Invalid volume name"); goto out; } |