diff options
author | Russ Allbery <rra@stanford.edu> | 2013-03-15 11:31:37 -0700 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2013-03-15 11:57:29 -0700 |
commit | d5853241c9562fa51cdb990028642bf87a46fbea (patch) | |
tree | d2512f3d9f514b4c9c0bebdc012bdb66a187ce43 /client | |
parent | 6842b0544c02fef5da3a550afdebd66e6a1a1c2b (diff) |
Diagnose empty commands in remctl_command
Return an error if an empty command is passed into remctl_command
rather than attempting to malloc zero bytes.
Change-Id: I92c52be3ae737cc906acc3385c2b4b9d6474f7a4
Reviewed-on: https://gerrit.stanford.edu/948
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Diffstat (limited to 'client')
-rw-r--r-- | client/api.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/client/api.c b/client/api.c index 27ae7b8..5eb2b78 100644 --- a/client/api.c +++ b/client/api.c @@ -503,6 +503,10 @@ remctl_command(struct remctl *r, const char **command) for (count = 0; command[count] != NULL; count++) ; + if (count == 0) { + internal_set_error(r, "cannot send empty command"); + return 0; + } vector = malloc(sizeof(struct iovec) * count); if (vector == NULL) { internal_set_error(r, "cannot allocate memory: %s", strerror(errno)); |