Add error-check when mapping socket to fd
The call to fdopen can fail in several ways. The fprintf on the next line will then dereference a NULL-pointer FILE*. Added a NULL-check, closed the socket, returned system error and added a comment about it. Change-Id: I7a6b26aa3c79452b1fdd76af12dfa75da88cbad7
This commit is contained in:
parent
4614032705
commit
3638a83657
@ -463,6 +463,15 @@ android_getaddrinfo_proxy(
|
|||||||
|
|
||||||
// Send the request.
|
// Send the request.
|
||||||
proxy = fdopen(sock, "r+");
|
proxy = fdopen(sock, "r+");
|
||||||
|
if (proxy == NULL) {
|
||||||
|
// Failed to map sock to FILE*. Check errno for the cause.
|
||||||
|
// @sonymobile.com saw failures in automated testing, but
|
||||||
|
// couldn't reproduce it for debugging.
|
||||||
|
// Fail with EAI_SYSTEM and let callers handle the failure.
|
||||||
|
close(sock);
|
||||||
|
return EAI_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
if (fprintf(proxy, "getaddrinfo %s %s %d %d %d %d %u",
|
if (fprintf(proxy, "getaddrinfo %s %s %d %d %d %d %u",
|
||||||
hostname == NULL ? "^" : hostname,
|
hostname == NULL ? "^" : hostname,
|
||||||
servname == NULL ? "^" : servname,
|
servname == NULL ? "^" : servname,
|
||||||
|
Loading…
Reference in New Issue
Block a user