]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Fix memory leaks on radius_client_send error paths
authorJouni Malinen <j@w1.fi>
Sun, 1 Apr 2012 14:55:20 +0000 (17:55 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 1 Apr 2012 14:55:20 +0000 (17:55 +0300)
In case this function returns an error, the RADIUS message needs to
freed in the caller.

Signed-hostap: Jouni Malinen <j@w1.fi>

radius_example/radius_example.c
src/ap/accounting.c
src/ap/ieee802_11_auth.c
wpa_supplicant/eapol_test.c

index 066707f535a6de720fc21d6c02d5bc1ba6474cb5..cb0e154301ce354963042ecf058a9e41d0a62b36 100644 (file)
@@ -88,7 +88,8 @@ static void start_example(void *eloop_ctx, void *timeout_ctx)
                return;
        }
 
-       radius_client_send(ctx->radius, msg, RADIUS_AUTH, NULL);
+       if (radius_client_send(ctx->radius, msg, RADIUS_AUTH, NULL) < 0)
+               radius_msg_free(msg);
 }
 
 
index 2a04560660a112dbaa600d7395547bf4c14899c6..edda88b531f90f52f28f223ad2b0598e29369dc4 100644 (file)
@@ -259,8 +259,9 @@ void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta)
                               hapd, sta);
 
        msg = accounting_msg(hapd, sta, RADIUS_ACCT_STATUS_TYPE_START);
-       if (msg)
-               radius_client_send(hapd->radius, msg, RADIUS_ACCT, sta->addr);
+       if (msg &&
+           radius_client_send(hapd->radius, msg, RADIUS_ACCT, sta->addr) < 0)
+               radius_msg_free(msg);
 
        sta->acct_session_started = 1;
 }
@@ -358,9 +359,10 @@ static void accounting_sta_report(struct hostapd_data *hapd,
                goto fail;
        }
 
-       radius_client_send(hapd->radius, msg,
-                          stop ? RADIUS_ACCT : RADIUS_ACCT_INTERIM,
-                          sta->addr);
+       if (radius_client_send(hapd->radius, msg,
+                              stop ? RADIUS_ACCT : RADIUS_ACCT_INTERIM,
+                              sta->addr) < 0)
+               goto fail;
        return;
 
  fail:
@@ -463,7 +465,8 @@ static void accounting_report_state(struct hostapd_data *hapd, int on)
                return;
        }
 
-       radius_client_send(hapd->radius, msg, RADIUS_ACCT, NULL);
+       if (radius_client_send(hapd->radius, msg, RADIUS_ACCT, NULL) < 0)
+               radius_msg_free(msg);
 }
 
 
index 109c4bc44c1b556cd1012b9565ecf2f2377915e0..27b0789286acb94cc77847f4b6fa29b150fdf04b 100644 (file)
@@ -193,7 +193,8 @@ static int hostapd_radius_acl_query(struct hostapd_data *hapd, const u8 *addr,
                goto fail;
        }
 
-       radius_client_send(hapd->radius, msg, RADIUS_AUTH, addr);
+       if (radius_client_send(hapd->radius, msg, RADIUS_AUTH, addr) < 0)
+               goto fail;
        return 0;
 
  fail:
index e92dc12f9e07285b5f823bf08296d69dac4b06db..e53e15634dfa1da0e421ed9d85c232549745d526 100644 (file)
@@ -278,7 +278,9 @@ static void ieee802_1x_encapsulate_radius(struct eapol_test_data *e,
                }
        }
 
-       radius_client_send(e->radius, msg, RADIUS_AUTH, e->wpa_s->own_addr);
+       if (radius_client_send(e->radius, msg, RADIUS_AUTH, e->wpa_s->own_addr)
+           < 0)
+               goto fail;
        return;
 
  fail: