RT RT/krbdev.mit.edu: Ticket #2760 fopen(3) returning NULL and errno==0 Signed in as guest.
[Logout]

[Home] [Search] [Configuration]

[Display] [History] [Basics] [Dates] [People] [Links] [Jumbo]

 
 

 The Basics  
Id
2760
Status
resolved
Worked
0 min
Priority
0/0
Queue
krb5
 

 Keyword Selections  
Component
  • krb5-libs
Tags
Version_reported
  • 1.3.1
Version_Fixed
  • 1.4
Target_Version
  • 1.4
 

 Relationships  
Depends on:
Depended on by:
Parents:
Children:

Refers to:
Referred to by:
  • 2780: (tlyu) set errno=0 prior to fopen in kt_file [resolved]
 
 Dates  
Created: Tue Nov 2 16:12:46 2004
Starts: Not set
Started: Fri Nov 19 17:12:34 2004
Last Contact: Not set
Due: Not set
Updated: Wed Dec 16 18:02:43 2015 by tlyu
 

 People  
Owner
 tlyu
Requestors
 tlyu@mit.edu, elric@imrryr.org
Cc
 
AdminCc
 
 

 More about Taylor Yu  
Comments about this user:
No comment entered about this user
This user's 25 highest priority tickets:
 
 More about Roland C. Dowdeswell  
Comments about this user:
No comment entered about this user
This user's 25 highest priority tickets:
 

History   Display mode: [Brief headers] [Full headers]
      Tue Nov  2 16:12:47 2004  tlyu - Ticket created    
     
To: krb5-bugs@mit.edu
From: Tom Yu <tlyu@mit.edu>
Date: Tue, 02 Nov 2004 16:10:59 -0500
Subject: [Roland C. Dowdeswell] fopen(3) returning NULL and errno==0


-------------------- Start of forwarded message --------------------
To: krbdev@mit.edu
Date: Tue, 26 Oct 2004 18:54:07 -0400
From: "Roland C. Dowdeswell" <elric@imrryr.org>
Message-Id: <20041026225407.6098E174F8@arioch.imrryr.org>
Subject: fopen(3) returning NULL (with workaround.)

So, I've experienced a few core dumps with the kerberos libraries
on Solaris 7.  After a bit of examination, I determined that on
Solaris 7 [and I presume earlier versions as well], it is possible
for fopen(3) to return NULL yet set errno to zero[1].  In
krb5_ktfileint_open(), if fopen(3) returns NULL, the function will
return errno.  This has the unfortunate effect of seeming like
success to callers who later try to use the NULL FILE *.

Anyway, here's a small patch which just returns ENFILE if errno == 0.

[1]	Solaris 7's fopen(3) returns with errno == 0, if it can't
	get a fd < 256.  In the same situation Solaris 8 sets errno
	to ENFILE.

--
    Roland Dowdeswell                      http://www.Imrryr.ORG/~elric/

===================================================================
RCS file: /ms/dev/sec/mitkrb5/cvs-dirs/mitkrb5-
1.3.1/mitkrb5/src/lib/krb5/keytab/kt_file.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- src/lib/krb5/keytab/kt_file.c	29 Mar 2004 19:57:38 -0000	1.1
+++ src/lib/krb5/keytab/kt_file.c	23 Sep 2004 04:24:22 -0000	1.2
@@ -1008,10 +1008,10 @@
             krb5_create_secure_file(context, KTFILENAME(id));
 	    KTFILEP(id) = fopen(KTFILENAME(id), fopen_mode_rbplus);
 	    if (!KTFILEP(id))
-		return errno;
+		return errno?errno:ENFILE;
 	    writevno = 1;
 	} else				/* some other error */
-	    return errno;
+	    return errno?errno:ENFILE;
     }
     if ((kerror = krb5_lock_file(context, fileno(KTFILEP(id)), mode))) {
 	(void) fclose(KTFILEP(id));
_______________________________________________
krbdev mailing list             krbdev@mit.edu
https://mailman.mit.edu/mailman/listinfo/krbdev

-------------------- End of forwarded message --------------------


Download (untitled) 1.9k
      Tue Nov  2 16:29:00 2004  tlyu - Requestor "Roland C. Dowdeswell" <elric@imrryr.org> added    
      Tue Nov  2 16:34:43 2004  tlyu - Subject changed from [Roland C. Dowdeswell] fopen(3) returning NULL and errno==0 to fopen(3) returning NULL and errno==0    
      Tue Nov  2 16:34:43 2004  tlyu - Component krb5-libs added    
      Tue Nov  2 16:34:44 2004  tlyu - Version_reported 1.3.1 added    
      Fri Nov 19 17:12:35 2004  tlyu - Status changed from new to resolved    
      Fri Nov 19 17:12:35 2004  tlyu - Tags pullup added    
      Fri Nov 19 17:12:36 2004  tlyu - Target_Version 1.4 added    
      Fri Nov 19 17:12:36 2004  tlyu - Given to tlyu    
      Fri Nov 19 17:12:36 2004  tlyu - Correspondence added    
     
From: tlyu@mit.edu
Subject: CVS Commit

	* kt_file.c (krb5_ktfileint_open): Patch from Roland Dowdeswell to
	return ENFILE when fopen() returns NULL but doesn't set errno.


To generate a diff of this commit:



	cvs diff -r5.70 -r5.71 krb5/src/lib/krb5/keytab/ChangeLog
	cvs diff -r5.10 -r5.11 krb5/src/lib/krb5/keytab/kt_file.c


Download (untitled) 290b
      Fri Nov 19 17:17:21 2004  tlyu - Version_Fixed 1.4 added    
      Fri Nov 19 17:17:21 2004  tlyu - Correspondence added    
     
From: tlyu@mit.edu
Subject: CVS Commit

pullup from trunk


To generate a diff of this commit:



	cvs diff -r5.70 -r5.70.4.1 krb5/src/lib/krb5/keytab/ChangeLog
	cvs diff -r5.10 -r5.10.4.1 krb5/src/lib/krb5/keytab/kt_file.c


Download (untitled) 184b
      Wed Dec 16 18:02:43 2015  tlyu - Keyword pullup deleted