Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Nov 2000 18:30:03 -0800 (PST)
From:      Garance A Drosehn <gad@eclipse.acs.rpi.edu>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/22965: [PATCH] fix for minor bug in libc/gen/getcap.c
Message-ID:  <200011210230.SAA91302@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/22965; it has been noted by GNATS.

From: Garance A Drosehn <gad@eclipse.acs.rpi.edu>
To: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/22965: [PATCH] fix for minor bug in libc/gen/getcap.c
Date: Mon, 20 Nov 2000 21:19:44 -0500

 Here is an improved version of the patch.  Note that I have tested
 this on a private copy of 'getcap.c' that I use in a project of
 mine (which is compiled on multiple platforms), so I know it compiles
 and it works fine in that project.  However, I haven't figured out
 how to build a new libc on freebsd, so I can't say I've tested this
 patch installed into freebsd's libc...
 
 Index: getcap.c
 ===================================================================
 RCS file: /home/ncvs/src/lib/libc/gen/getcap.c,v
 retrieving revision 1.12
 diff -u -r1.12 getcap.c
 --- getcap.c	2000/05/21 02:55:09	1.12
 +++ getcap.c	2000/11/21 02:14:10
 @@ -647,7 +647,7 @@
  	char **db_array;
  {
  	size_t len;
 -	int status, i, done;
 +	int done, hadreaderr, i, savederrno, status;
  	char *cp, *line, *rp, *np, buf[BSIZE], nbuf[BSIZE];
  	u_int dummy;
 
 @@ -665,9 +665,14 @@
  		} else {
  			line = fgetln(pfp, &len);
  			if (line == NULL && pfp) {
 -				(void)fclose(pfp);
 -				if (ferror(pfp)) {
 -					(void)cgetclose();
 +				hadreaderr = ferror(pfp);
 +				if (hadreaderr)
 +					savederrno = errno;
 +				fclose(pfp);
 +				pfp = NULL;
 +				if (hadreaderr) {
 +					cgetclose();
 +					errno = savederrno;
  					return (-1);
  				} else {
  					if (*++dbp == NULL) {
 @@ -724,9 +729,18 @@
  			} else { /* name field extends beyond the line */
  				line = fgetln(pfp, &len);
  				if (line == NULL && pfp) {
 -					(void)fclose(pfp);
 -					if (ferror(pfp)) {
 -						(void)cgetclose();
 +					/* Name extends beyond the EOF! */
 +					hadreaderr = ferror(pfp);
 +					if (hadreaderr)
 +						savederrno = errno;
 +					fclose(pfp);
 +					pfp = NULL;
 +					if (hadreaderr) {
 +						cgetclose();
 +						errno = savederrno;
 +						return (-1);
 +					} else {
 +						cgetclose();
  						return (-1);
  					}
  				} else
 
 
 ---
 Garance Alistair Drosehn     =     gad@eclipse.acs.rpi.edu
 Senior Systems Programmer        (MIME & NeXTmail capable)
 Rensselaer Polytechnic Institute;           Troy NY    USA
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011210230.SAA91302>