Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac9e4ff

Browse filesBrowse files
Junliang YanFishrock123
authored andcommitted
dns: prevent undefined values in results
When getaddrinfo linked-list results contain entries other than AF_INET and AF_INET6, the resulting v8::Array will contain undefined values. That's because initialization of v8::Array pre-allocates entries for all linked-list nodes, but not all of them will be in the final results. This commit ensures that the array only contains valid results. PR-URL: #3696 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 1c8a7c6 commit ac9e4ff
Copy full SHA for ac9e4ff

File tree

Expand file treeCollapse file tree

1 file changed

+1
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+1
-8
lines changed
Open diff view settings
Collapse file

‎src/cares_wrap.cc‎

Copy file name to clipboardExpand all lines: src/cares_wrap.cc
+1-8Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -922,19 +922,12 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
922922
struct addrinfo *address;
923923
int n = 0;
924924

925-
// Count the number of responses.
926-
for (address = res; address; address = address->ai_next) {
927-
n++;
928-
}
929-
930925
// Create the response array.
931-
Local<Array> results = Array::New(env->isolate(), n);
926+
Local<Array> results = Array::New(env->isolate());
932927

933928
char ip[INET6_ADDRSTRLEN];
934929
const char *addr;
935930

936-
n = 0;
937-
938931
// Iterate over the IPv4 responses again this time creating javascript
939932
// strings for each IP and filling the results array.
940933
address = res;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.