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

Side by Side Diff: third_party/libjingle/overrides/talk/base/win32.cc

Issue 9455070: Remove the dependency to ws2_32.dll from talk_base::ThreadManager and talk_base::Thread. (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 9 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004--2005, Google Inc. 3 * Copyright 2004--2005, Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 *cursor++ = ':'; 165 *cursor++ = ':';
166 *cursor++ = ':'; 166 *cursor++ = ':';
167 i += (max - 1); 167 i += (max - 1);
168 } 168 }
169 } 169 }
170 } 170 }
171 return dst; 171 return dst;
172 } 172 }
173 173
174 // Helper function for inet_pton for IPv4 addresses. 174 // Helper function for inet_pton for IPv4 addresses.
175 // Uses win32's inet_addr. 175 // |src| points to a character string containing an IPv4 network address in
176 // dotted-decimal format, "ddd.ddd.ddd.ddd", where ddd is a decimal number
177 // of up to three digits in the range 0 to 255.
178 // The address is converted and copied to dst,
179 // which must be sizeof(struct in_addr) (4) bytes (32 bits) long.
176 int inet_pton_v4(const char* src, void* dst) { 180 int inet_pton_v4(const char* src, void* dst) {
177 uint32 ip = inet_addr(src); 181 int num_dot = 0;
178 if (ip == 0xFFFFFFFF && strcmp(src, "255.255.255.255") != 0) { 182 const char* src_pos = src;
183 unsigned char result[4];
184 memset(result, 0, sizeof(result));
185
186 while (*src_pos != 0) {
187 char* end_pos;
188 long int value = strtol(src_pos, &end_pos, 10);
Sergey Ulanov 2012/02/29 00:09:52 I think that we need to verify that the string sta
Ronghua Wu (Left Chromium) 2012/02/29 04:31:22 Right. Added a check before strtol I think that sh
189 if (value < 0 || value > 255 ||
190 src_pos == end_pos)
191 return 0;
192 result[num_dot] = value;
193 if (*end_pos == 0)
194 break;
195 src_pos = end_pos;
196 if (*src_pos == '.') {
197 if (++num_dot > 3)
198 return 0;
199 }
200 ++src_pos;
201 }
202 if (num_dot != 3) {
179 return 0; 203 return 0;
180 } 204 }
181 struct in_addr* dst_as_in_addr = reinterpret_cast<struct in_addr*>(dst); 205 memcpy(dst, result, 4);
182 dst_as_in_addr->s_addr = ip;
183 return 1; 206 return 1;
184 } 207 }
185 208
186 // Helper function for inet_pton for IPv6 addresses. 209 // Helper function for inet_pton for IPv6 addresses.
187 int inet_pton_v6(const char* src, void* dst) { 210 int inet_pton_v6(const char* src, void* dst) {
188 // sscanf will pick any other invalid chars up, but it parses 0xnnnn as hex. 211 // sscanf will pick any other invalid chars up, but it parses 0xnnnn as hex.
189 // Check for literal x in the input string. 212 // Check for literal x in the input string.
190 const char* readcursor = src; 213 const char* readcursor = src;
191 char c = *readcursor++; 214 char c = *readcursor++;
192 while (c) { 215 while (c) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 DWORD count = *GetSidSubAuthorityCount(til->Label.Sid); 454 DWORD count = *GetSidSubAuthorityCount(til->Label.Sid);
432 *level = *GetSidSubAuthority(til->Label.Sid, count - 1); 455 *level = *GetSidSubAuthority(til->Label.Sid, count - 1);
433 ret = true; 456 ret = true;
434 } 457 }
435 } 458 }
436 CloseHandle(token); 459 CloseHandle(token);
437 } 460 }
438 return ret; 461 return ret;
439 } 462 }
440 } // namespace talk_base 463 } // namespace talk_base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698