Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
In sigchild_handler(), finish with waitpid() before reinitializing
[rsync/rsync.git]
/
access.c
diff --git
a/access.c
b/access.c
index
aec633a
..
1dc73ae
100644
(file)
--- a/
access.c
+++ b/
access.c
@@
-27,7
+27,7
@@
static int match_hostname(char *host, char *tok)
{
if (!host || !*host) return 0;
static int match_hostname(char *host, char *tok)
{
if (!host || !*host) return 0;
- return
(fnmatch(tok, host, 0) == 0
);
+ return
wildmatch(tok, host
);
}
static int match_binary(char *b1, char *b2, char *mask, int addrlen)
}
static int match_binary(char *b1, char *b2, char *mask, int addrlen)
@@
-51,7
+51,8
@@
static void make_mask(char *mask, int plen, int addrlen) {
if (w)
memset(mask, 0xff, w);
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);
if (w+1 < addrlen)
memset(mask+w+1, 0, addrlen-w-1);
@@
-72,16
+73,31
@@
static int match_address(char *addr, char *tok)
#endif
char mask[16];
char *a = NULL, *t = NULL;
#endif
char mask[16];
char *a = NULL, *t = NULL;
+ unsigned int len;
if (!addr || !*addr) return 0;
p = strchr(tok,'/');
if (!addr || !*addr) return 0;
p = strchr(tok,'/');
- if (p) *p = 0;
+ if (p) {
+ *p = '\0';
+ len = p - tok;
+ }
+ else
+ len = strlen(tok);
+
+ /* Fail quietly if tok is a hostname (not an address) */
+ if (strspn(tok, ".0123456789") != len
+#ifdef INET6
+ && !strchr(tok, ':')
+#endif
+ ) return 0;
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
+#ifdef AI_NUMERICHOST
hints.ai_flags = AI_NUMERICHOST;
hints.ai_flags = AI_NUMERICHOST;
+#endif
gai = getaddrinfo(addr, NULL, &hints, &resa);
if (gai) return 0;
gai = getaddrinfo(addr, NULL, &hints, &resa);
if (gai) return 0;
@@
-90,7
+106,10
@@
static int match_address(char *addr, char *tok)
if (p)
*p++ = '/';
if (gai) {
if (p)
*p++ = '/';
if (gai) {
- rprintf(FERROR,"malformed address %s\n", tok);
+ rprintf(FERROR,
+ "error matching address %s: %s\n",
+ tok,
+ gai_strerror(gai));
freeaddrinfo(resa);
return 0;
}
freeaddrinfo(resa);
return 0;
}
@@
-119,6
+138,8
@@
static int match_address(char *addr, char *tok)
a = (char *)&sin6a->sin6_addr;
t = (char *)&sin6t->sin6_addr;
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) {
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
if (sin6t->sin6_scope_id &&
sin6a->sin6_scope_id != sin6t->sin6_scope_id) {
@@
-127,10
+148,6
@@
static int match_address(char *addr, char *tok)
}
#endif
}
#endif
- a = (char *)&sin6a->sin6_addr;
- t = (char *)&sin6t->sin6_addr;
- addrlen = 16;
-
break;
}
#endif
break;
}
#endif