Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
htsp/access: more empty username checks
  • Loading branch information
perexg committed May 27, 2015
1 parent b5f23b3 commit 7478260
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/access.c
Expand Up @@ -475,7 +475,7 @@ access_get(const char *username, const char *password, struct sockaddr *src)
access_t *a = calloc(1, sizeof(*a));
access_entry_t *ae;

if (username) {
if (username && username[0]) {
a->aa_username = strdup(username);
a->aa_representative = strdup(username);
} else {
Expand Down Expand Up @@ -545,7 +545,7 @@ access_get_hashed(const char *username, const uint8_t digest[20],
SHA_CTX shactx;
uint8_t d[20];

if (username) {
if (username && username[0]) {
a->aa_username = strdup(username);
a->aa_representative = strdup(username);
} else {
Expand Down Expand Up @@ -630,6 +630,9 @@ access_get_by_username(const char *username)
return a;
}

if (username[0] == '\0')
return a;

TAILQ_FOREACH(ae, &access_entries, ae_link) {

if(!ae->ae_enabled)
Expand Down
12 changes: 2 additions & 10 deletions src/htsp_server.c
Expand Up @@ -2528,14 +2528,6 @@ htsp_authenticate(htsp_connection_t *htsp, htsmsg_t *m)
if((username = htsmsg_get_str(m, "username")) == NULL)
return 0;

if(strcmp(htsp->htsp_username ?: "", username)) {
tvhlog(LOG_INFO, "htsp", "%s: Identified as user %s",
htsp->htsp_logname, username);
tvh_str_update(&htsp->htsp_username, username);
htsp_update_logname(htsp);
notify_reload("connections");
}

if(!htsmsg_get_bin(m, "digest", &digest, &digestlen)) {

rights = access_get_hashed(username, digest, htsp->htsp_challenge,
Expand All @@ -2551,7 +2543,7 @@ htsp_authenticate(htsp_connection_t *htsp, htsmsg_t *m)
htsp->htsp_granted_access->aa_rights) !=
htsp->htsp_granted_access->aa_rights;

tvhlog(LOG_INFO, "htsp", "%s: Identified as user %s",
tvhlog(LOG_INFO, "htsp", "%s: Identified as user '%s'",
htsp->htsp_logname, username);
tvh_str_update(&htsp->htsp_username, username);
htsp_update_logname(htsp);
Expand All @@ -2563,7 +2555,7 @@ htsp_authenticate(htsp_connection_t *htsp, htsmsg_t *m)

} else {

tvhlog(LOG_INFO, "htsp", "%s: Identified as user %s (unverified)",
tvhlog(LOG_INFO, "htsp", "%s: Identified as user '%s' (unverified)",
htsp->htsp_logname, username);
tvh_str_update(&htsp->htsp_username, username);
htsp_update_logname(htsp);
Expand Down

0 comments on commit 7478260

Please sign in to comment.