From: Jaroslav Kysela Date: Wed, 24 Oct 2018 18:06:29 +0000 (+0200) Subject: access: do not allocate always 50 bytes for aa_representative X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a27de8caae0f43b3a8dca2f4e750eb93c31bd68;p=thirdparty%2Ftvheadend.git access: do not allocate always 50 bytes for aa_representative --- diff --git a/src/access.c b/src/access.c index 330fb7f4f..02953765b 100644 --- a/src/access.c +++ b/src/access.c @@ -716,6 +716,7 @@ access_get(struct sockaddr_storage *src, const char *username, verify_callback_t access_t *a = access_alloc(); access_entry_t *ae; int nouser = tvh_str_default(username, NULL) == NULL; + char *s; if (!access_noacl && access_ip_blocked(src)) return a; @@ -727,8 +728,9 @@ access_get(struct sockaddr_storage *src, const char *username, verify_callback_t superuser_username, superuser_password)) return access_full(a); } else { - a->aa_representative = malloc(50); - tcp_get_str_from_ip(src, a->aa_representative, 50); + s = alloca(50); + tcp_get_str_from_ip(src, s, 50); + a->aa_representative = strdup(s); if(!passwd_verify2(username, verify, aux, superuser_username, superuser_password)) return access_full(a); @@ -815,9 +817,10 @@ access_get_by_addr(struct sockaddr_storage *src) { access_t *a = access_alloc(); access_entry_t *ae; + char buf[50]; - a->aa_representative = malloc(50); - tcp_get_str_from_ip(src, a->aa_representative, 50); + tcp_get_str_from_ip(src, buf, sizeof(buf)); + a->aa_representative = strdup(buf); if(access_noacl) return access_full(a);