Skip to content

Commit 023a0d5

Browse files
committed
[IEDriver] Fix potential null pointer access in CookieManager
1 parent 0f8e018 commit 023a0d5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cpp/iedriver/CookieManager.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,21 @@ LRESULT CALLBACK CookieWndProc(int nCode, WPARAM wParam, LPARAM lParam) {
522522
all_cookies.append(L"\n*\n");
523523
}
524524
INTERNETCOOKIE2* current_cookie = cookie_pointer + cookie_index;
525-
std::wstring cookie_name = current_cookie->pwszName;
525+
std::wstring cookie_name = L"";
526+
if (current_cookie->pwszName) {
527+
// Note that the spec appears to allow "nameless" cookies,
528+
// which clients like Selenium may not support.
529+
cookie_name = current_cookie->pwszName;
530+
}
526531
std::wstring cookie_value = L"";
527532
if (current_cookie->pwszValue) {
528533
cookie_value = current_cookie->pwszValue;
529534
}
535+
536+
// TODO: The spec does not allow a cookie with an empty name
537+
// and value. It's unclear what the driver could do in this
538+
// case, but we should probably handle it somehow in the off
539+
// chance it ever comes up.
530540
std::wstring cookie_domain = L"";
531541
if (current_cookie->pwszDomain) {
532542
cookie_domain = current_cookie->pwszDomain;

0 commit comments

Comments
 (0)