From ec03c47c192c9198a135acf51b114f43086b17c3 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 26 Sep 2012 01:20:08 +0200 Subject: [PATCH] fs: fix stat() reporting for large files Use Number::New(), not Integer::New(). Large values won't fit in an Integer. Apply to the size, ino and blocks fields. --- src/node_file.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 89a786b17e..59ff414c69 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -321,15 +321,25 @@ Local BuildStatsObject(const uv_statbuf_t* s) { stats->Set(name##_symbol, val); \ } X(dev) - X(ino) X(mode) X(nlink) X(uid) X(gid) X(rdev) - X(size) # if defined(__POSIX__) X(blksize) +# endif +#undef X + +#define X(name) \ + { \ + Local val = Number::New(static_cast(s->st_##name)); \ + if (val.IsEmpty()) return Local(); \ + stats->Set(name##_symbol, val); \ + } + X(ino) + X(size) +# if defined(__POSIX__) X(blocks) # endif #undef X