confstr() should return 0, not -1, on errors

Thomas E. Spanjaard tgen at netphreax.net
Tue Dec 5 14:25:10 PST 2006


Thomas E. Spanjaard wrote:
See attached patch.
And the next attached patch fixes the only consumer of confstr(3) in our 
tree (something the other BSDs don't appear to have done).

Cheers,
--
        Thomas E. Spanjaard
        tgen at netphreax.net
Index: getconf.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/getconf/getconf.c,v
retrieving revision 1.3
diff -u -r1.3 getconf.c
--- getconf.c	4 Nov 2003 20:25:45 -0000	1.3
+++ getconf.c	5 Dec 2006 22:21:43 -0000
@@ -141,8 +141,9 @@
 	char *buf;
 	size_t len;
 
+	errno = 0;
 	len = confstr(key, 0, 0);
-	if (len == (size_t)-1)
+	if (len == 0 && errno != 0)
 		err(EX_OSERR, "confstr: %s", name);
 	
 	if (len == 0) {
Attachment:
signature.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00001.pgp
Type: application/octet-stream
Size: 186 bytes
Desc: "Description: OpenPGP digital signature"
URL: <http://lists.dragonflybsd.org/pipermail/bugs/attachments/20061205/00313efe/attachment-0016.obj>


More information about the Bugs mailing list