krb5 commit: Fix type violation in libkrad

ghudson at mit.edu ghudson at mit.edu
Tue Nov 5 11:18:54 EST 2024


https://github.com/krb5/krb5/commit/aac785e5e050415f8b8cb29059d2f658f755e7e7
commit aac785e5e050415f8b8cb29059d2f658f755e7e7
Author: Greg Hudson <ghudson at mit.edu>
Date:   Mon Oct 28 11:51:54 2024 -0400

    Fix type violation in libkrad
    
    remote.c uses casts to cover up a signature difference between
    iterator() and krad_packet_iter_cb.  The difference is unimportant in
    typical platform ABIs, but calling the function this way is undefined
    behavior (C99 6.3.2.8).  Fix iterator() to conform to
    krad_packet_iter_cb and remove the casts.

 src/lib/krad/remote.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/lib/krad/remote.c b/src/lib/krad/remote.c
index 06ae751bc..28f2e83d0 100644
--- a/src/lib/krad/remote.c
+++ b/src/lib/krad/remote.c
@@ -76,15 +76,15 @@ on_timeout(verto_ctx *ctx, verto_ev *ev);
 
 /* Iterate over the set of outstanding packets. */
 static const krad_packet *
-iterator(request **out)
+iterator(void *data, krb5_boolean cancel)
 {
-    request *tmp = *out;
+    request **rptr = data, *req = *rptr;
 
-    if (tmp == NULL)
+    if (cancel || req == NULL)
         return NULL;
 
-    *out = K5_TAILQ_NEXT(tmp, list);
-    return tmp->request;
+    *rptr = K5_TAILQ_NEXT(req, list);
+    return req->request;
 }
 
 /* Create a new request. */
@@ -349,8 +349,7 @@ on_io_read(krad_remote *rr)
     /* Decode the packet. */
     tmp = K5_TAILQ_FIRST(&rr->list);
     retval = krad_packet_decode_response(rr->kctx, rr->secret, &rr->buffer,
-                                         (krad_packet_iter_cb)iterator, &tmp,
-                                         &req, &rsp);
+                                         iterator, &tmp, &req, &rsp);
     rr->buffer.length = 0;
     if (retval != 0)
         return;
@@ -457,7 +456,7 @@ kr_remote_send(krad_remote *rr, krad_code code, krad_attrset *attrs,
 
     r = K5_TAILQ_FIRST(&rr->list);
     retval = krad_packet_new_request(rr->kctx, rr->secret, code, attrs,
-                                     (krad_packet_iter_cb)iterator, &r, &tmp);
+                                     iterator, &r, &tmp);
     if (retval != 0)
         goto error;
 


More information about the cvs-krb5 mailing list