[sheepdog] [PATCH stable-0.7] dog: allow snapshot tags which begin with decimal number

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Thu Mar 6 07:17:31 CET 2014


Current dog command doesn't accept snapshot tags which begin with
decimal number, e.g. 123abc. This behavior comes from invalid usage of
strtol(). This patch fixes this problem.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 dog/vdi.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dog/vdi.c b/dog/vdi.c
index 6c1a10d..06342c3 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -2209,7 +2209,7 @@ static int vdi_parser(int ch, char *opt)
 		break;
 	case 's':
 		vdi_cmd_data.snapshot_id = strtol(opt, &p, 10);
-		if (opt == p) {
+		if (opt == p || *p != '\0') {
 			vdi_cmd_data.snapshot_id = 0;
 			pstrcpy(vdi_cmd_data.snapshot_tag,
 				sizeof(vdi_cmd_data.snapshot_tag), opt);
@@ -2244,7 +2244,7 @@ static int vdi_parser(int ch, char *opt)
 		break;
 	case 'F':
 		vdi_cmd_data.from_snapshot_id = strtol(opt, &p, 10);
-		if (opt == p) {
+		if (opt == p || *p != '\0') {
 			vdi_cmd_data.from_snapshot_id = 0;
 			pstrcpy(vdi_cmd_data.from_snapshot_tag,
 				sizeof(vdi_cmd_data.from_snapshot_tag), opt);
-- 
1.7.10.4




More information about the sheepdog mailing list