summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2009-02-12 20:35:15 +0000
committerKen Raeburn <raeburn@mit.edu>2009-02-12 20:35:15 +0000
commitb2c96206c3d6c8d253cc8ed2f4cc859e9c61c217 (patch)
tree9568d4f9ca835d4967b1182b1a747817f456c460 /src/util
parent083688a5b5940ef7c3ca39183cb878038de116ca (diff)
downloadkrb5-b2c96206c3d6c8d253cc8ed2f4cc859e9c61c217.tar.gz
krb5-b2c96206c3d6c8d253cc8ed2f4cc859e9c61c217.tar.xz
krb5-b2c96206c3d6c8d253cc8ed2f4cc859e9c61c217.zip
Don't pass negative numbers to strerror
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21988 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util')
-rw-r--r--src/util/support/errors.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/support/errors.c b/src/util/support/errors.c
index d85ba4244..4111ed478 100644
--- a/src/util/support/errors.c
+++ b/src/util/support/errors.c
@@ -113,6 +113,20 @@ krb5int_get_error (struct errinfo *ep, long code)
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);