summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-21 05:07:50 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-21 05:07:50 +0000
commite44f1a5a50565fafc45fec1184e5018ce6dfc357 (patch)
tree6bc0fa884256e7fd04189e53296bcf4253c23e51
parentdbde67b2d535100c62d9eb99b0261a6e64424a1b (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/branches/ruby_1_8@10979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--ext/etc/etc.c13
2 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2cb5415..22d23f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Sep 21 13:55:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * 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.
+
Wed Sep 20 23:17:41 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (pre-install-doc): create data directory before install.
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index c79640d..c9ed3d5 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -126,12 +126,21 @@ etc_getpwuid(argc, argv, 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();