OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef __STDC_LIMIT_MACROS |
| 6 #define __STDC_LIMIT_MACROS |
| 7 #endif |
| 8 |
5 #include "nacl_io/host_resolver.h" | 9 #include "nacl_io/host_resolver.h" |
6 | 10 |
7 #include <assert.h> | 11 #include <assert.h> |
| 12 #include <stdint.h> |
8 #include <stdlib.h> | 13 #include <stdlib.h> |
9 #include <string.h> | 14 #include <string.h> |
10 | 15 |
11 #include "nacl_io/kernel_proxy.h" | 16 #include "nacl_io/kernel_proxy.h" |
12 #include "nacl_io/ossocket.h" | 17 #include "nacl_io/ossocket.h" |
13 #include "nacl_io/pepper_interface.h" | 18 #include "nacl_io/pepper_interface.h" |
14 | 19 |
15 #ifdef PROVIDES_SOCKET_API | 20 #ifdef PROVIDES_SOCKET_API |
16 | 21 |
17 namespace { | 22 namespace { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 229 |
225 if (node == NULL && service == NULL) | 230 if (node == NULL && service == NULL) |
226 return EAI_NONAME; | 231 return EAI_NONAME; |
227 | 232 |
228 // Check the service name (port). Currently we only handle numeric | 233 // Check the service name (port). Currently we only handle numeric |
229 // services. | 234 // services. |
230 long port = 0; | 235 long port = 0; |
231 if (service != NULL) { | 236 if (service != NULL) { |
232 char* cp; | 237 char* cp; |
233 port = strtol(service, &cp, 10); | 238 port = strtol(service, &cp, 10); |
234 if (port > 0 && port <= 65535 && *cp == '\0') { | 239 if (port >= 0 && port <= UINT16_MAX && *cp == '\0') { |
235 port = htons(port); | 240 port = htons(port); |
236 } else { | 241 } else { |
237 return EAI_SERVICE; | 242 return EAI_SERVICE; |
238 } | 243 } |
239 } | 244 } |
240 | 245 |
241 struct addrinfo default_hints; | 246 struct addrinfo default_hints; |
242 memset(&default_hints, 0, sizeof(default_hints)); | 247 memset(&default_hints, 0, sizeof(default_hints)); |
243 const struct addrinfo* hints = hints_in ? hints_in : &default_hints; | 248 const struct addrinfo* hints = hints_in ? hints_in : &default_hints; |
244 | 249 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 hostent_.h_addr_list = NULL; | 429 hostent_.h_addr_list = NULL; |
425 #if !defined(h_addr) | 430 #if !defined(h_addr) |
426 // Initialize h_addr separately in the case where it is not a macro. | 431 // Initialize h_addr separately in the case where it is not a macro. |
427 hostent_.h_addr = NULL; | 432 hostent_.h_addr = NULL; |
428 #endif | 433 #endif |
429 } | 434 } |
430 | 435 |
431 } // namespace nacl_io | 436 } // namespace nacl_io |
432 | 437 |
433 #endif // PROVIDES_SOCKET_API | 438 #endif // PROVIDES_SOCKET_API |
OLD | NEW |