aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-07-05 14:46:40 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2013-07-05 14:46:40 +0300
commit8ec38bfb766d2c0fb53b9fbb6888592837c1ac15 (patch)
tree13ab33516670fe2324e125e2cc9557fef606b220 /lib
parent52ea4d55b798b3ade185193f6d404f2076424b4b (diff)
downloadeclat-8ec38bfb766d2c0fb53b9fbb6888592837c1ac15.tar.gz
eclat-8ec38bfb766d2c0fb53b9fbb6888592837c1ac15.tar.bz2
Bugfix
* lib/envmap.c (eclat_encode_devmap): Fix recognition of optional parts.
Diffstat (limited to 'lib')
-rw-r--r--lib/envmap.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/lib/envmap.c b/lib/envmap.c
index 2e3f8aa..2e0cff4 100644
--- a/lib/envmap.c
+++ b/lib/envmap.c
@@ -94,8 +94,12 @@ eclat_encode_devmap(struct ec2_query *q, struct grecs_list *list)
ws.ws_wordv[0]);
eclat_query_add_param(q, bufptr,
ws.ws_wordv[0]);
+ } else if (ws.ws_wordc < 2) {
+ die(EX_USAGE,
+ "not enough parts in device mapping \"%s\"",
+ p);
} else {
- if (ws.ws_wordv[0]) {
+ if (ws.ws_wordv[0][0]) {
grecs_asprintf(&bufptr, &bufsize,
"BlockDeviceMapping.%d."
"Ebs.SnapshotId",
@@ -104,7 +108,7 @@ eclat_encode_devmap(struct ec2_query *q, struct grecs_list *list)
ws.ws_wordv[0]);
}
- if (ws.ws_wordv[1]) {
+ if (ws.ws_wordv[1][0]) {
grecs_asprintf(&bufptr, &bufsize,
"BlockDeviceMapping.%d."
"Ebs.VolumeSize",
@@ -120,32 +124,38 @@ eclat_encode_devmap(struct ec2_query *q, struct grecs_list *list)
"too many parts in device mapping \"%s\"",
p);
case 5:
- grecs_asprintf(&bufptr, &bufsize,
+ if (ws.ws_wordv[4][0]) {
+ grecs_asprintf(&bufptr, &bufsize,
"BlockDeviceMapping.%d.Ebs.Iops",
- i);
- eclat_query_add_param(q, bufptr,
- ws.ws_wordv[4]);
+ i);
+ eclat_query_add_param(q, bufptr,
+ ws.ws_wordv[4]);
+ }
/* fall through */
case 4:
- grecs_asprintf(&bufptr, &bufsize,
+ if (ws.ws_wordv[3][0]) {
+ grecs_asprintf(&bufptr, &bufsize,
"BlockDeviceMapping.%d.Ebs.VolumeType",
- i);
- eclat_query_add_param(q, bufptr,
- ws.ws_wordv[3]);
+ i);
+ eclat_query_add_param(q, bufptr,
+ ws.ws_wordv[3]);
+ }
/* fall through */
case 3:
- if (strcmp(ws.ws_wordv[2], "false") &&
- strcmp(ws.ws_wordv[2], "true"))
- die(EX_USAGE,
+ if (ws.ws_wordv[2][0]) {
+ if (strcmp(ws.ws_wordv[2], "false") &&
+ strcmp(ws.ws_wordv[2], "true"))
+ die(EX_USAGE,
"expected \"true\" or \"false\", "
"but found \"%s\"",
- ws.ws_wordv[2]);
- grecs_asprintf(&bufptr, &bufsize,
+ ws.ws_wordv[2]);
+ grecs_asprintf(&bufptr, &bufsize,
"BlockDeviceMapping.%d."
"Ebs.DeleteOnTermination",
- i);
- eclat_query_add_param(q, bufptr,
- ws.ws_wordv[2]);
+ i);
+ eclat_query_add_param(q, bufptr,
+ ws.ws_wordv[2]);
+ }
}
wordsplit_free(&ws);
}

Return to:

Send suggestions and report system problems to the System administrator.