dmsetup: check errors
PATCH 1/1 dmsetup: check errors
dmsetup: check errors
atoll doesn't check for errors, so invalid sector numbers were silently accepted in the "dmsetup message" command.
Signed-off-by Mikulas Patocka <[email protected]>
--- tools/dmsetup.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/dmsetup.c +8 -1
@@ -770,6 +770,8 @@ static int _message(CMD_ARGS)size_t sz =1 ;struct dm_task *dmt;char *str; +uint64_t sector; +char *endptr;if (!(dmt =dm_task_create (DM_DEVICE_TARGET_MSG )))return 0 ;
@@ -784,7 +786,12 @@ static int _message(CMD_ARGS) argv++; } -if (!dm_task_set_sector (dmt, (uint64_t )atoll (argv[1 ]))) + sector =strtoull (argv[1 ], &endptr,10 ); +if (*endptr || endptr == argv[1 ]) { +err ("invalid sector" ); + goto out; + } +if (!dm_task_set_sector (dmt, sector)) goto out; argc -=2 ;