]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Remove strerror() calls from k5_get_error() 943/head
authorGreg Hudson <ghudson@mit.edu>
Thu, 6 Jun 2019 15:46:58 +0000 (11:46 -0400)
committerGreg Hudson <ghudson@mit.edu>
Mon, 10 Jun 2019 14:55:59 +0000 (10:55 -0400)
Coverity models strerror() as a function which cannot accept negative
values, even though it has defined behavior on all integers.
k5_get_error() contains code to call strerror_r() and strerror() if
its fptr global is unset, which isn't an expected case in practice.
To silence a large number of Coverity false positives, just return a
fixed string if fptr is null.

src/util/support/errors.c

index 70e1d59d095b45a9f43f4cbf79b5fb99a4aee2bd..f8bea07a35c1a8b2aae86502b4e5c91c3fd87ccc 100644 (file)
@@ -78,10 +78,9 @@ k5_get_error(struct errinfo *ep, long code)
 
     lock();
     if (fptr == NULL) {
+        /* Should be rare; fptr should be set whenever libkrb5 is loaded. */
         unlock();
-        if (strerror_r(code, buf, sizeof(buf)) == 0)
-            return oom_check(strdup(buf));
-        return oom_check(strdup(strerror(code)));
+        return oom_check(strdup(_("Error code translation unavailable")));
     }
     r = fptr(code);
 #ifndef HAVE_COM_ERR_INTL