From: Nick Porter Date: Thu, 23 May 2024 17:17:23 +0000 (+0100) Subject: When ldap sync callback returns < 0, avoid path that frees msg X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=187efa2180aab6c08e19f3b4e2511035f8e4f7d2;p=thirdparty%2Ffreeradius-server.git When ldap sync callback returns < 0, avoid path that frees msg The callback has already freed the msg --- diff --git a/src/listen/ldap_sync/proto_ldap_sync_ldap.c b/src/listen/ldap_sync/proto_ldap_sync_ldap.c index 34e0e4df14a..5595dfa7bf5 100644 --- a/src/listen/ldap_sync/proto_ldap_sync_ldap.c +++ b/src/listen/ldap_sync/proto_ldap_sync_ldap.c @@ -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