Skip to content

Commit

Permalink
aplay/mixer: restricting senders - check err
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinPulec committed Dec 4, 2024
1 parent e62773d commit 96b43dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
24 changes: 16 additions & 8 deletions src/audio/playback/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,22 @@ state_audio_mixer::check_messages()
MSG(INFO, "flushing the address restriction (defaulting to mix all)\n");
only_sender.ss_family = AF_UNSPEC;
} else {
MSG(INFO, "restricting mixer to: %s\n", val);
only_sender = get_sockaddr(val, 0);
if (participants.find(only_sender) ==
participants.end()) {
MSG(WARNING,
"The requested participant %s is not yet "
"present...\n",
val);
struct sockaddr_storage ss = get_sockaddr(val, 0);
if (ss.ss_family != AF_UNSPEC) {
MSG(INFO, "restricting mixer to: %s\n", val);
only_sender = ss;
if (participants.find(only_sender) ==
participants.end()) {
MSG(WARNING,
"The requested participant %s is "
"not yet present...\n", val);
}
} else {
MSG(ERROR, "Wrong addr spec: %s\n", val);
free_message(msg,
new_response(RESPONSE_BAD_REQUEST,
nullptr));
continue;
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/utils/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,10 @@ get_sockaddr_str(const struct sockaddr *sa, unsigned sa_len, char *buf,
struct sockaddr_storage
get_sockaddr(const char *hostport, int mode)
{
struct sockaddr_storage ret;
struct sockaddr_storage ret = { .ss_family = AF_UNSPEC };
socklen_t socklen_unused = 0;
char host[STR_LEN];

ret.ss_family = AF_UNSPEC;
const char *const rightmost_colon = strrchr(hostport, ':');
if (rightmost_colon == NULL) {
MSG(ERROR, "Address %s not in format host:port!\n", hostport);
Expand Down

0 comments on commit 96b43dd

Please sign in to comment.