summaryrefslogtreecommitdiff
path: root/ext/etc/etc.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-21 05:12:57 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-21 05:12:57 +0000
commitc35290824a75b8edfffc6d809873d4f2cbd38bd1 (patch)
tree52f0d02b13d710be8e355387f05c700021b98a8b /ext/etc/etc.c
parent77fef79f107679eadb10cafb3ed22f6732825115 (diff)
* ext/etc/etc.c (etc_getpwuid): uid integer should be wraped in
uid_t value. [ruby-core:08897] * ext/etc/etc.c (etc_getpwuid): uid_t may be bigger than plain 'int' type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/etc/etc.c')
-rw-r--r--ext/etc/etc.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 65a2963..1bd767d 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -120,12 +120,21 @@ etc_getpwuid(int argc, VALUE *argv, VALUE obj)
{
#if defined(HAVE_GETPWENT)
VALUE id;
- int uid;
+ uid_t uid;
struct passwd *pwd;
rb_secure(4);
if (rb_scan_args(argc, argv, "01", &id) == 1) {
- uid = NUM2INT(id);
+#if HAVE_LONG_LONG && HAVE_TYPE_UID_T
+ if (sizeof(uid_t) > sizeof(int)) {
+ uid = NUM2ULL(id);
+ }
+ else {
+ uid = NUM2UINT(id);
+ }
+#else
+ uid = NUM2UINT(id);
+#endif
}
else {
uid = getuid();