diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-06-06 07:34:09 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-06-06 07:34:09 +0000 |
commit | 41debb52b9d719dbb6f3ee7963de8913eff0c13d (patch) | |
tree | f16694ac9eeffb16833140c7635fd9378a3b0219 | |
parent | cd76457a8eec40a0de8cb2bc779c5bfb08b9d7b3 (diff) | |
download | clogger-41debb52b9d719dbb6f3ee7963de8913eff0c13d.tar.gz |
There's no way in hell a valid file descriptor can have a negative number attached to it.
-rw-r--r-- | ext/clogger_ext/clogger.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c index 834debe..cc08fac 100644 --- a/ext/clogger_ext/clogger.c +++ b/ext/clogger_ext/clogger.c @@ -806,6 +806,7 @@ static VALUE to_path(VALUE self) VALUE path = rb_funcall(c->body, to_path_id, 0); struct stat sb; int rv; + unsigned devfd; const char *cpath; Check_Type(path, T_STRING); @@ -815,11 +816,11 @@ static VALUE to_path(VALUE self) if (rb_respond_to(c->body, to_io_id)) rv = fstat(my_fileno(c->body), &sb); /* - * Rainbows! can use "/dev/fd/%d" in to_path output to avoid + * Rainbows! can use "/dev/fd/%u" in to_path output to avoid * extra open() syscalls, too. */ - else if (sscanf(cpath, "/dev/fd/%d", &rv) == 1) - rv = fstat(rv, &sb); + else if (sscanf(cpath, "/dev/fd/%u", &devfd) == 1) + rv = fstat((int)devfd, &sb); else rv = stat(cpath, &sb); |