Skip to content

unix: handle invalid _SC_GETPW_R_SIZE_MAX values#389

Closed
cjihrig wants to merge 1 commit intolibuv:v1.xfrom
cjihrig:homedir-patch
Closed

unix: handle invalid _SC_GETPW_R_SIZE_MAX values#389
cjihrig wants to merge 1 commit intolibuv:v1.xfrom
cjihrig:homedir-patch

Conversation

@cjihrig
Copy link
Copy Markdown
Contributor

@cjihrig cjihrig commented Jun 4, 2015

Some systems, FreeBSD for example, may return negative values. sysconf() returns a long, which was being converted to a size_t. This conversion lead to large allocations, and subsequent out of memory failures. This commit checks the long value returned by sysconf() properly, and uses a default value of 4096 if a negative number is returned.

Related to nodejs/node#1791
R=@bnoordhuis

Some systems, FreeBSD for example, may return negative values.
sysconf() returns a long, which was being converted to a size_t.
This conversion lead to large allocations, and subsequent out of
memory failures. This commit checks the long value returned by
sysconf() properly, and uses a default value of 4096 if a negative
number is returned.
@saghul
Copy link
Copy Markdown
Member

saghul commented Jun 5, 2015

Ups. I guess we should do a patch release once this lands.

@bnoordhuis
Copy link
Copy Markdown
Member

LGTM FWIW.

saghul pushed a commit that referenced this pull request Jun 5, 2015
Some systems, FreeBSD for example, may return negative values.
sysconf() returns a long, which was being converted to a size_t.
This conversion lead to large allocations, and subsequent out of
memory failures. This commit checks the long value returned by
sysconf() properly, and uses a default value of 4096 if a negative
number is returned.

PR-URL: #389
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
@saghul
Copy link
Copy Markdown
Member

saghul commented Jun 5, 2015

Cheers, Colin, landed in d82e47a.

@saghul saghul closed this Jun 5, 2015
guworks pushed a commit to guworks/libuv that referenced this pull request Jul 9, 2015
Some systems, FreeBSD for example, may return negative values.
sysconf() returns a long, which was being converted to a size_t.
This conversion lead to large allocations, and subsequent out of
memory failures. This commit checks the long value returned by
sysconf() properly, and uses a default value of 4096 if a negative
number is returned.

PR-URL: libuv#389
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
skomski pushed a commit to skomski/libuv that referenced this pull request Aug 5, 2015
Some systems, FreeBSD for example, may return negative values.
sysconf() returns a long, which was being converted to a size_t.
This conversion lead to large allocations, and subsequent out of
memory failures. This commit checks the long value returned by
sysconf() properly, and uses a default value of 4096 if a negative
number is returned.

PR-URL: libuv#389
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
skomski pushed a commit to skomski/libuv that referenced this pull request Aug 5, 2015
Some systems, FreeBSD for example, may return negative values.
sysconf() returns a long, which was being converted to a size_t.
This conversion lead to large allocations, and subsequent out of
memory failures. This commit checks the long value returned by
sysconf() properly, and uses a default value of 4096 if a negative
number is returned.

PR-URL: libuv#389
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants