]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
When ldap sync callback returns < 0, avoid path that frees msg
authorNick Porter <nick@portercomputing.co.uk>
Thu, 23 May 2024 17:17:23 +0000 (18:17 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Thu, 23 May 2024 17:18:27 +0000 (18:18 +0100)
The callback has already freed the msg

src/listen/ldap_sync/proto_ldap_sync_ldap.c

index 34e0e4df14a640702ee27f339e127f1eb75b5717..5595dfa7bf5d9e66087dd18a7c7457030c49d895 100644 (file)
@@ -718,7 +718,6 @@ static ssize_t proto_ldap_child_mod_read(fr_listen_t *li, UNUSED void **packet_c
                goto free_msg;
 
        default:
-       sync_error:
                PERROR("Sync error");
                ret = -1;
                goto free_msg;
@@ -745,6 +744,7 @@ static ssize_t proto_ldap_child_mod_read(fr_listen_t *li, UNUSED void **packet_c
 
        if (callback) {
                ret = callback(sync, msg, ctrls);
+               if (ret < 0) PERROR("Sync callback error");
        } else {
        /*
         *      Callbacks are responsible for freeing the msg
@@ -752,11 +752,10 @@ static ssize_t proto_ldap_child_mod_read(fr_listen_t *li, UNUSED void **packet_c
         */
                ldap_msgfree(msg);
        }
-       if (ret < 0) goto sync_error;
 
        ldap_controls_free(ctrls);
 
-       return 0;
+       return ret;
 }
 
 /** Send a fake packet to run the "load Cookie" section