[PATCH] Put workaround in catclose too
Jakub Jelinek
jakub@redhat.com
Thu Aug 9 14:49:00 GMT 2001
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
More information about the Libc-hacker
mailing list