From: Razvan Cojocaru <[email protected]> "tapctl list --hwid" without a value crashed in wcslen(), and a value too long for the hardware ID buffer made memcpy_s() fail.
Warn and ignore --hwid in both cases, as the create command does. Change-Id: I21c051e6fa7b89904da2d4d6ec4770c94bc44af7 Signed-off-by: Razvan Cojocaru <[email protected]> Acked-by: Frank Lichtenheld <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2376 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2376 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld <[email protected]> diff --git a/src/tapctl/main.c b/src/tapctl/main.c index 6697d14..12ab270 100644 --- a/src/tapctl/main.c +++ b/src/tapctl/main.c @@ -512,11 +512,20 @@ { if (wcsicmp(argv[i], L"--hwid") == 0) { + if (++i >= argc) + { + fwprintf(stderr, L"--hwid option requires a value. Ignored.\n"); + break; + } + /* leave room for the two terminating zeros */ + size_t len = wcslen(argv[i]); + if (len > _countof(szzHwId) - 2) + { + fwprintf(stderr, L"--hwid value is too long. Ignored.\n"); + continue; + } memset(szzHwId, 0, sizeof(szzHwId)); - ++i; - memcpy_s(szzHwId, - sizeof(szzHwId) - 2 * sizeof(WCHAR), - argv[i], wcslen(argv[i]) * sizeof(WCHAR)); + wmemcpy(szzHwId, argv[i], len); } else { _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
