Skip to content

Commit

Permalink
[NETSHELL] Remove erroneous DNS Server line and fix date/time format (#…
Browse files Browse the repository at this point in the history
…2655)

CORE-16947
  • Loading branch information
Kyle Katarn committed Apr 26, 2020
1 parent e152a79 commit 522e140
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions dll/shellext/netshell/lanstatusui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,23 +356,23 @@ InsertItemToListView(

BOOL tmToStr(
IN struct tm *pTM,
IN SYSTEMTIME *pST,
OUT WCHAR *szBuffer)
{
SYSTEMTIME st;
WCHAR szBufferDate[100];
WCHAR szBufferTime[100];

st.wYear = pTM->tm_year + 1900;
st.wMonth = pTM->tm_mon + 1;
st.wDay = pTM->tm_mday;
st.wHour = pTM->tm_hour;
st.wMinute = pTM->tm_min;
st.wSecond = pTM->tm_sec;
pST->wYear = pTM->tm_year + 1900;
pST->wMonth = pTM->tm_mon + 1;
pST->wDay = pTM->tm_mday;
pST->wHour = pTM->tm_hour;
pST->wMinute = pTM->tm_min;
pST->wSecond = pTM->tm_sec;

if (GetDateFormatW(LOCALE_USER_DEFAULT, 0, &st, nullptr, szBufferDate, _countof(szBufferDate)) &&
GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, nullptr, szBufferTime, _countof(szBufferTime)))
if (GetDateFormatW(LOCALE_USER_DEFAULT, 0, pST, nullptr, szBufferDate, sizeof(tm) / sizeof(WCHAR)) &&
GetTimeFormatW(LOCALE_USER_DEFAULT, 0, pST, nullptr, szBufferTime, sizeof(tm) / sizeof(WCHAR)))
{
wcsncpy(szBuffer, szBufferDate, 100);
wcscpy(szBuffer, szBufferDate);
wcsncat(szBuffer, L" ", 1);
wcsncat(szBuffer, szBufferTime, 24);
return TRUE;
Expand All @@ -397,6 +397,7 @@ LANStatusUiDetailsDlg(
DWORD dwSize;
HWND hDlgCtrl;
RECT rect;
SYSTEMTIME leaseST;

switch (uMsg)
{
Expand Down Expand Up @@ -479,7 +480,7 @@ LANStatusUiDetailsDlg(

leaseOptained = localtime(&pCurAdapter->LeaseObtained);

if (tmToStr(leaseOptained, szBuffer))
if (tmToStr(leaseOptained, &leaseST, szBuffer))
SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
}

Expand All @@ -490,20 +491,20 @@ LANStatusUiDetailsDlg(

leaseExpire = localtime(&pCurAdapter->LeaseExpires);

if (tmToStr(leaseExpire, szBuffer))
if (tmToStr(leaseExpire, &leaseST, szBuffer))
SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
}
}

dwSize = 0;
li.iItem = InsertItemToListView(hDlgCtrl, IDS_DNS_SERVERS);
if (GetPerAdapterInfo(pContext->dwAdapterIndex, NULL, &dwSize) == ERROR_BUFFER_OVERFLOW)
{
pPerAdapter = static_cast<PIP_PER_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
if (pPerAdapter)
{
if (GetPerAdapterInfo(pContext->dwAdapterIndex, pPerAdapter, &dwSize) == ERROR_SUCCESS)
{
li.iItem = InsertItemToListView(hDlgCtrl, IDS_DNS_SERVERS);
if (li.iItem >= 0)
AddIPAddressToListView(hDlgCtrl, &pPerAdapter->DnsServerList, li.iItem);
}
Expand Down

0 comments on commit 522e140

Please sign in to comment.