This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] cuserid



Hi,

The Single UNIX Specification V2 (SUSv2) says about cuserid:
 
     If s is not a null pointer, s is returned. If s is not a null
     pointer and the login name cannot be found, the null byte '\0'
     will be placed at *s.


If the login name cannot be found, we always return NULL, even if
the user supplied an own buffer. Here is a patch to fix this
(passes now the LSB.os tests for cuserid)

  Thorsten

2001-12-13  Thorsten Kukuk  <kukuk@suse.de>

	* sysdeps/posix/cuserid.c(cuserid): If we don't find the UID,
	but have a user supplied buffer, return the empty buffer, not NULL.

--- glibc-2.2/sysdeps/posix/cuserid.c	2001/12/10 16:39:59	1.1
+++ glibc-2.2/sysdeps/posix/cuserid.c	2001/12/10 16:41:08
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1998, 1999, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -38,8 +38,12 @@
       || pwptr == NULL)
     {
       if (s != NULL)
-	s[0] = '\0';
-      return NULL;
+	{
+	  s[0] = '\0';
+	  return s;
+	}
+      else
+	return NULL;
     }
 
   if (s == NULL)

-- 
Thorsten Kukuk       http://www.suse.de/~kukuk/        kukuk@suse.de
SuSE GmbH            Deutschherrenstr. 15-19       D-90429 Nuernberg
--------------------------------------------------------------------    
Key fingerprint = A368 676B 5E1B 3E46 CFCE  2D97 F8FD 4E23 56C6 FB4B


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]