Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1040)

Side by Side Diff: net/dns/dns_config_service_win.cc

Issue 539313002: ReadIpHelper: Zero out before calling GetAdaptersAddresses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/dns/dns_config_service_win.h" 5 #include "net/dns/dns_config_service_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 scoped_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> ReadIpHelper(ULONG flags) { 116 scoped_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> ReadIpHelper(ULONG flags) {
117 base::ThreadRestrictions::AssertIOAllowed(); 117 base::ThreadRestrictions::AssertIOAllowed();
118 118
119 scoped_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> out; 119 scoped_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> out;
120 ULONG len = 15000; // As recommended by MSDN for GetAdaptersAddresses. 120 ULONG len = 15000; // As recommended by MSDN for GetAdaptersAddresses.
121 UINT rv = ERROR_BUFFER_OVERFLOW; 121 UINT rv = ERROR_BUFFER_OVERFLOW;
122 // Try up to three times. 122 // Try up to three times.
123 for (unsigned tries = 0; (tries < 3) && (rv == ERROR_BUFFER_OVERFLOW); 123 for (unsigned tries = 0; (tries < 3) && (rv == ERROR_BUFFER_OVERFLOW);
124 tries++) { 124 tries++) {
125 out.reset(static_cast<PIP_ADAPTER_ADDRESSES>(malloc(len))); 125 out.reset(static_cast<PIP_ADAPTER_ADDRESSES>(malloc(len)));
126 memset(out.get(), 0, len);
126 rv = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, out.get(), &len); 127 rv = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, out.get(), &len);
127 } 128 }
128 if (rv != NO_ERROR) 129 if (rv != NO_ERROR)
129 out.reset(); 130 out.reset();
130 return out.Pass(); 131 return out.Pass();
131 } 132 }
132 133
133 // Converts a base::string16 domain name to ASCII, possibly using punycode. 134 // Converts a base::string16 domain name to ASCII, possibly using punycode.
134 // Returns true if the conversion succeeds and output is not empty. In case of 135 // Returns true if the conversion succeeds and output is not empty. In case of
135 // failure, |domain| might become dirty. 136 // failure, |domain| might become dirty.
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 } 759 }
759 760
760 } // namespace internal 761 } // namespace internal
761 762
762 // static 763 // static
763 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { 764 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() {
764 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServiceWin()); 765 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServiceWin());
765 } 766 }
766 767
767 } // namespace net 768 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698