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]

[PATCH] Put workaround in catclose too


Hi!

tcsh is broken and I'm afraid many other apps are too in that they don't
bother checking whether catopen returned -1. Previously, it would return -1
only if memory allocation failed and those programs probably simply believe
they have enough memory.
As catgets is liberal and accepts (nl_catd) -1, I think catclose should be
too, instead of crashing it should just flag error. I assume that
application which cannot be bothered to check return value from catopen will
not be bothered to check return value from catclose, otherwise they'll get
what they desire.

2001-08-09  Jakub Jelinek  <jakub@redhat.com>

	* catgets/catgets.c (catclose): Be liberal about catalog_desc in
	catclose too.

--- catgets/catgets.c.jj	Thu Aug  9 04:45:11 2001
+++ catgets/catgets.c	Thu Aug  9 17:34:06 2001
@@ -114,6 +114,13 @@ catclose (nl_catd catalog_desc)
 {
   __nl_catd catalog;
 
+  /* Be generous if catalog which failed to be open is used.  */
+  if (catalog_desc == (nl_catd) -1)
+    {
+      __set_errno (EBADF);
+      return -1;
+    }
+
   catalog = (__nl_catd) catalog_desc;
 
 #ifdef _POSIX_MAPPED_FILES

	Jakub


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