why is this causing connecting errors?
nt accept_connection(int fd, struct sockname *users) {
    int user_index = 0;
    while (user_index < MAX_CONNECTIONS && users[user_index].sock_fd != -1) {
        user_index++;
    }

    if (user_index == MAX_CONNECTIONS) {
        fprintf(stderr, "server: max concurrent connections\n");
        return -1;
    }

    int client_fd = accept(fd, NULL, NULL);
    if (client_fd < 0) {
        perror("server: accept");
        close(fd);
        exit(1);
    }

    char name[BUF_SIZE + 1];
    int num_read;

    if ((num_read = read(client_fd, &name, BUF_SIZE)) == -1) {
        perror("read");
        exit(1);
    }

    name[num_read] = '\0';

    users[user_index].sock_fd = client_fd;

    if ((users[user_index].username = malloc(strlen(name) * sizeof(char))) == NULL) {
        perror("malloc");
        exit(1);
    }

    strcpy(users[user_index].username, name);

    return client_fd;
}