[sheepdog] [PATCH] dog:fix dog command misinterpretation when characters are mixed in a -p option
Hitoshi Mitake
mitake.hitoshi at gmail.com
Mon Apr 21 04:36:05 CEST 2014
On Mon, Apr 21, 2014 at 10:57 AM, Yuichi Bando
<bando.yuichi at lab.ntt.co.jp> wrote:
> This bug is reported in https://bugs.launchpad.net/sheepdog-project/+bug/1309301
> I added a check code if the port number (specified in -p option) is numeric or not.
>
> === Bug Description ===
> I found that dog command misinterprets when characters are mixed in a numeric option.
>
> Here's the example.
>
> $dog vdi list -p 7X000
> Name Id Size Used Shared Creation time VDI id Copies Tag
> failed to connect to 127.0.0.1:7: Connection refused
> failed to connect to 127.0.0.1:7: Connection refused
>
> dog interpreted "7X000" as "7".
> I think that dog should output error message " Invalid port number '7X000' ".
>
> === After modified ===
> $dog vdi list -p 7X000
> Invalid port number '7X000'
>
> Thanks
> Yuichi Bando
>
> Signed-off-by: Yuichi Bando <bando.yuichi at lab.ntt.co.jp>
> ---
> dog/dog.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/dog/dog.c b/dog/dog.c
> index fbedd6d..e12f73d 100644
> --- a/dog/dog.c
> +++ b/dog/dog.c
> @@ -467,8 +467,7 @@ int main(int argc, char **argv)
> break;
> case 'p':
> sdport = strtol(optarg, &p, 10);
> - if (optarg == p || sdport < 1 || sdport > UINT16_MAX) {
> + if (optarg == p || sdport < 1 || sdport > UINT16_MAX || !is_numeric(optarg)) {
The line exceeds 80 characters. Please check the patch with
script/checkpatch.pl like below:
$ script/checkpatch.pl <patch file>
Thanks,
Hitoshi
More information about the sheepdog
mailing list