Check device name length given to argv. If the length of device name is shorter than 4, that's an error. --- tools/hciconfig.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/hciconfig.c b/tools/hciconfig.c index ddc17c4b5..aad37dd56 100644 --- a/tools/hciconfig.c +++ b/tools/hciconfig.c @@ -2027,7 +2027,13 @@ int main(int argc, char *argv[]) exit(0); } - di.dev_id = atoi(argv[0] + 3); + if (strlen(argv[0]) > 3) { + di.dev_id = atoi(argv[0] + 3); + } else { + fprintf(stderr, "Invalid device name: %s\n", argv[0]); + exit(1); + } + argc--; argv++; if (ioctl(ctl, HCIGETDEVINFO, (void *) &di)) { -- 2.17.1