]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
EAP-SIM DB: Remove client socket file on connect() error
authorJouni Malinen <j@w1.fi>
Sat, 15 Feb 2014 14:45:57 +0000 (16:45 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 15 Feb 2014 19:39:31 +0000 (21:39 +0200)
If the connection from hostapd authentication server to hlr_auc_gw fails
due to hlr_auc_gw not running yet, the local socket file was left
behind. Delete the socket file on connect() failure path.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/eap_server/eap_sim_db.c

index 45660ed7d25c0fb9745365a873425ca187aa12f2..bc2cbe5bce803bed4fe79c617cb0b8d8693ad4e8 100644 (file)
@@ -639,6 +639,11 @@ static int eap_sim_db_open_socket(struct eap_sim_db_data *data)
                    "/tmp/eap_sim_db_%d-%d", getpid(), counter++);
        os_free(data->local_sock);
        data->local_sock = os_strdup(addr.sun_path);
+       if (data->local_sock == NULL) {
+               close(data->sock);
+               data->sock = -1;
+               return -1;
+       }
        if (bind(data->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
                wpa_printf(MSG_INFO, "bind(eap_sim_db): %s", strerror(errno));
                close(data->sock);
@@ -657,6 +662,9 @@ static int eap_sim_db_open_socket(struct eap_sim_db_data *data)
                                  os_strlen(addr.sun_path));
                close(data->sock);
                data->sock = -1;
+               unlink(data->local_sock);
+               os_free(data->local_sock);
+               data->local_sock = NULL;
                return -1;
        }