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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/libjingle/overrides/talk/base/win32.cc
===================================================================
--- third_party/libjingle/overrides/talk/base/win32.cc (revision 124023)
+++ third_party/libjingle/overrides/talk/base/win32.cc (working copy)
@@ -172,14 +172,37 @@
}
// Helper function for inet_pton for IPv4 addresses.
-// Uses win32's inet_addr.
+// |src| points to a character string containing an IPv4 network address in
+// dotted-decimal format, "ddd.ddd.ddd.ddd", where ddd is a decimal number
+// of up to three digits in the range 0 to 255.
+// The address is converted and copied to dst,
+// which must be sizeof(struct in_addr) (4) bytes (32 bits) long.
int inet_pton_v4(const char* src, void* dst) {
- uint32 ip = inet_addr(src);
- if (ip == 0xFFFFFFFF && strcmp(src, "255.255.255.255") != 0) {
+ int num_dot = 0;
+ const char* src_pos = src;
+ unsigned char result[4];
+ memset(result, 0, sizeof(result));
+
+ while (*src_pos != 0) {
+ char* end_pos;
+ 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
+ if (value < 0 || value > 255 ||
+ src_pos == end_pos)
+ return 0;
+ result[num_dot] = value;
+ if (*end_pos == 0)
+ break;
+ src_pos = end_pos;
+ if (*src_pos == '.') {
+ if (++num_dot > 3)
+ return 0;
+ }
+ ++src_pos;
+ }
+ if (num_dot != 3) {
return 0;
}
- struct in_addr* dst_as_in_addr = reinterpret_cast<struct in_addr*>(dst);
- dst_as_in_addr->s_addr = ip;
+ memcpy(dst, result, 4);
return 1;
}

Powered by Google App Engine
This is Rietveld 408576698