X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/8d2aad49e306e51cae9c694bb1ef2a4e73416036..136c5c5ec3b3cc56d3952c3ce463f58615f00f8f:/access.c diff --git a/access.c b/access.c index d792eafd..4cbd9a1e 100644 --- a/access.c +++ b/access.c @@ -51,7 +51,8 @@ static void make_mask(char *mask, int plen, int addrlen) { if (w) memset(mask, 0xff, w); - mask[w] = 0xff & (0xff<<(8-b)); + if (w < addrlen) + mask[w] = 0xff & (0xff<<(8-b)); if (w+1 < addrlen) memset(mask+w+1, 0, addrlen-w-1); @@ -78,6 +79,11 @@ static int match_address(char *addr, char *tok) p = strchr(tok,'/'); if (p) *p = 0; + /* skip if last char is not a digit (i.e. not an address) */ + /* (don't check first char - might be 11.22.33.44.an.isp) */ + if (!*tok) return 0; /* nothing to check */ + if (!isdigit(*(unsigned char*)tok+strlen(tok)-1)) return 0; + memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; @@ -121,6 +127,8 @@ static int match_address(char *addr, char *tok) a = (char *)&sin6a->sin6_addr; t = (char *)&sin6t->sin6_addr; + addrlen = 16; + #ifdef HAVE_SOCKADDR_IN6_SCOPE_ID if (sin6t->sin6_scope_id && sin6a->sin6_scope_id != sin6t->sin6_scope_id) { @@ -129,10 +137,6 @@ static int match_address(char *addr, char *tok) } #endif - a = (char *)&sin6a->sin6_addr; - t = (char *)&sin6t->sin6_addr; - addrlen = 16; - break; } #endif