summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2000-09-18 20:39:11 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2000-09-18 20:39:11 +0000
commit2744daecbaa978ec9a381a67b39c07a48cd9adaf (patch)
treeccb93e7c47ac8f292943be2ffe51e6bf44505cca
parent27e1ab8fdca440bc69feb01de7b665881f17b23f (diff)
downloadATCD-2744daecbaa978ec9a381a67b39c07a48cd9adaf.tar.gz
ChangeLogTag:Mon Sep 18 12:39:39 2000 Ossama Othman <ossama@uci.edu>
-rw-r--r--ChangeLog11
-rw-r--r--ChangeLogs/ChangeLog-02a11
-rw-r--r--ChangeLogs/ChangeLog-03a11
-rw-r--r--ace/OS.i46
4 files changed, 74 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 212bf242cb3..29d04acbb67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Mon Sep 18 12:39:39 2000 Ossama Othman <ossama@uci.edu>
+
+ * ace/OS.i (cuserid):
+
+ When using ACE's alternate cuserid() implementation:
+ - ensure that the maximum length argument is non-zero
+ since it doesn't make sense to have a zero length user ID.
+ - Return a static buffer if the buffer argument is zero. This
+ is not reentrant but nothing else can be done in such a case.
+ [Bug 619]
+
Mon Sep 18 11:22:02 2000 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu>
* ace/SUN_Proactor.cpp (handle_events): Fixed a problem arising
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index 212bf242cb3..29d04acbb67 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,14 @@
+Mon Sep 18 12:39:39 2000 Ossama Othman <ossama@uci.edu>
+
+ * ace/OS.i (cuserid):
+
+ When using ACE's alternate cuserid() implementation:
+ - ensure that the maximum length argument is non-zero
+ since it doesn't make sense to have a zero length user ID.
+ - Return a static buffer if the buffer argument is zero. This
+ is not reentrant but nothing else can be done in such a case.
+ [Bug 619]
+
Mon Sep 18 11:22:02 2000 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu>
* ace/SUN_Proactor.cpp (handle_events): Fixed a problem arising
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 212bf242cb3..29d04acbb67 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,14 @@
+Mon Sep 18 12:39:39 2000 Ossama Othman <ossama@uci.edu>
+
+ * ace/OS.i (cuserid):
+
+ When using ACE's alternate cuserid() implementation:
+ - ensure that the maximum length argument is non-zero
+ since it doesn't make sense to have a zero length user ID.
+ - Return a static buffer if the buffer argument is zero. This
+ is not reentrant but nothing else can be done in such a case.
+ [Bug 619]
+
Mon Sep 18 11:22:02 2000 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu>
* ace/SUN_Proactor.cpp (handle_events): Fixed a problem arising
diff --git a/ace/OS.i b/ace/OS.i
index 67fe60f5368..f201a5c5c85 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -1341,7 +1341,14 @@ ACE_OS::cuserid (ACE_TCHAR *user, size_t maxlen)
// POSIX.1 dropped the cuserid() function.
// GNU GLIBC and other platforms correctly deprecate the cuserid()
- // function.
+ // function.
+
+ if (maxlen == 0)
+ {
+ // It doesn't make sense to have a zero length user ID.
+ errno = EINVAL;
+ return 0;
+ }
struct passwd *pw = 0;
@@ -1356,15 +1363,44 @@ ACE_OS::cuserid (ACE_TCHAR *user, size_t maxlen)
// Make sure the password file is closed.
::endpwent ();
+ size_t max_length = 0;
+ ACE_TCHAR *userid = 0;
+
+ if (user == 0)
+ {
+ // Not reentrant/thread-safe, but nothing else can be done if a
+ // zero pointer was passed in as the destination.
+
+#if defined (_POSIX_SOURCE)
+ static ACE_TCHAR tmp[L_cuserid];
+#else
+ static ACE_TCHAR tmp[9]; // 8 character user ID + NULL
+#endif /* _POSIX_SOURCE */
+
+ max_length = sizeof(tmp) / sizeof(ACE_TCHAR);
+
+ userid = tmp;
+ }
+ else
+ {
+ max_length = maxlen;
+ userid = user;
+ }
+
// Extract the user name from the passwd structure.
- if (::strlen (pw->pw_name) <= maxlen)
- return ::strcpy (user, pw->pw_name);
+ if (ACE_OS_String::strlen (pw->pw_name) <= max_length)
+ {
+ return ACE_OS_String::strcpy (userid, pw->pw_name);
+ }
else
- return 0;
+ {
+ errno = ENOSPC; // Buffer is not large enough.
+ return 0;
+ }
#else
// Hackish because of missing buffer size!
ACE_UNUSED_ARG (maxlen);
- ACE_OSCALL_RETURN (::cuserid (user), char *, 0);
+ ACE_OSCALL_RETURN (::cuserid (user), ACE_TCHAR *, 0);
#endif /* VXWORKS */
}