svn rev #21988: trunk/src/util/support/

raeburn@MIT.EDU raeburn at MIT.EDU
Thu Feb 12 15:35:16 EST 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=21988
Commit By: raeburn
Log Message:
Don't pass negative numbers to strerror.


Changed Files:
U   trunk/src/util/support/errors.c
Modified: trunk/src/util/support/errors.c
===================================================================
--- trunk/src/util/support/errors.c	2009-02-12 20:19:21 UTC (rev 21987)
+++ trunk/src/util/support/errors.c	2009-02-12 20:35:15 UTC (rev 21988)
@@ -113,6 +113,20 @@
     if (fptr == NULL) {
 	unlock();
     no_fptr:
+	/* Theoretically, according to ISO C, strerror should be able
+	   to give us a message back for any int value.  However, on
+	   UNIX at least, the errno codes strerror will actually be
+	   useful for are positive, so a negative value here would be
+	   kind of weird.
+
+	   Coverity Prevent thinks we shouldn't be passing negative
+	   values to strerror, and it's not likely to be useful, so
+	   let's not do it.
+
+	   Besides, normally we shouldn't get here; fptr should take
+	   us to a callback function in the com_err library.  */
+	if (code < 0)
+	    goto format_number;
 #ifdef HAVE_STRERROR_R
 	if (strerror_r (code, ep->scratch_buf, sizeof(ep->scratch_buf)) == 0) {
 	    char *p = strdup(ep->scratch_buf);




More information about the cvs-krb5 mailing list