Permalink
Browse files

linux: fix race in uv_resident_set_memory()

uv_resident_set_memory() used a global buffer to read data into, which
is a decidedly unsafe thing to do in a multi-threaded environment.
  • Loading branch information...
1 parent 5b63285 commit fa9c577e55d7c845d0134acf13b10035b8e2b492 @bnoordhuis bnoordhuis committed Jan 6, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/unix/linux/linux-core.c
@@ -57,7 +57,6 @@
# define CLOCK_BOOTTIME 7
#endif
-static char buf[MAXPATHLEN + 1];
static void* args_mem;
static struct {
@@ -382,6 +381,7 @@ uv_err_t uv_resident_set_memory(size_t* rss) {
size_t page_size = getpagesize();
char *cbuf;
int foundExeEnd;
+ char buf[PATH_MAX + 1];
f = fopen("/proc/self/stat", "r");
if (!f) return uv__new_sys_error(errno);

0 comments on commit fa9c577

Please sign in to comment.