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
Fix const
[rsync/rsync.git]
/
socket.c
diff --git
a/socket.c
b/socket.c
index
6073dac
..
eb1ab3f
100644
(file)
--- a/
socket.c
+++ b/
socket.c
@@
-33,6
+33,8
@@
#include "rsync.h"
#include "rsync.h"
+static const char default_name[] = "UNKNOWN";
+
static int lookup_name(const struct sockaddr_storage *ss,
socklen_t ss_len,
char *name_buf, size_t name_buf_len,
static int lookup_name(const struct sockaddr_storage *ss,
socklen_t ss_len,
char *name_buf, size_t name_buf_len,
@@
-40,7
+42,7
@@
static int lookup_name(const struct sockaddr_storage *ss,
static int check_name(const struct sockaddr_storage *ss,
socklen_t ss_len,
static int check_name(const struct sockaddr_storage *ss,
socklen_t ss_len,
- c
onst c
har *name_buf,
+ char *name_buf,
const char *port_buf);
/* Establish a proxy connection on an open socket to a web roxy by
const char *port_buf);
/* Establish a proxy connection on an open socket to a web roxy by
@@
-610,6
+612,10
@@
static int get_sockaddr_family(const struct sockaddr_storage *ss)
*
* The name is statically cached so that repeated lookups are quick,
* so there is a limit of one lookup per customer.
*
* The name is statically cached so that repeated lookups are quick,
* so there is a limit of one lookup per customer.
+ *
+ * If anything goes wrong, including the name->addr->name check, then
+ * we just use "UNKNOWN", so you can use that value in hosts allow
+ * lines.
**/
char *client_name(int fd)
{
**/
char *client_name(int fd)
{
@@
-621,6
+627,7
@@
char *client_name(int fd)
if (initialised) return name_buf;
if (initialised) return name_buf;
+ strcpy(name_buf, default_name);
initialised = 1;
if (getpeername(fd, (struct sockaddr *)&ss, &ss_len)) {
initialised = 1;
if (getpeername(fd, (struct sockaddr *)&ss, &ss_len)) {
@@
-646,7
+653,6
@@
static int lookup_name(const struct sockaddr_storage *ss,
char *port_buf, size_t port_buf_len)
{
int name_err;
char *port_buf, size_t port_buf_len)
{
int name_err;
- const char *def = "UNKNOWN";
#ifdef INET6
if (get_sockaddr_family(ss) == AF_INET6 &&
#ifdef INET6
if (get_sockaddr_family(ss) == AF_INET6 &&
@@
-683,7
+689,7
@@
static int lookup_name(const struct sockaddr_storage *ss,
port_buf, port_buf_len,
NI_NAMEREQD | NI_NUMERICSERV);
if (name_err != 0) {
port_buf, port_buf_len,
NI_NAMEREQD | NI_NUMERICSERV);
if (name_err != 0) {
- strcpy(name_buf, def);
+ strcpy(name_buf, def
ault_name
);
rprintf(FERROR, RSYNC_NAME ": name lookup failed: %s\n",
gai_strerror(name_err));
return name_err;
rprintf(FERROR, RSYNC_NAME ": name lookup failed: %s\n",
gai_strerror(name_err));
return name_err;
@@
-699,7
+705,7
@@
static int lookup_name(const struct sockaddr_storage *ss,
* we don't abort the connection but just emit a warning. */
static int check_name(const struct sockaddr_storage *ss,
socklen_t ss_len,
* we don't abort the connection but just emit a warning. */
static int check_name(const struct sockaddr_storage *ss,
socklen_t ss_len,
- c
onst c
har *name_buf,
+ char *name_buf,
const char *port_buf)
{
struct addrinfo hints, *res, *res0;
const char *port_buf)
{
struct addrinfo hints, *res, *res0;
@@
-711,8
+717,7
@@
static int check_name(const struct sockaddr_storage *ss,
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(name_buf, port_buf, &hints, &res0);
if (error) {
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(name_buf, port_buf, &hints, &res0);
if (error) {
- /* We still use the name found by the reverse lookup,
- * but emit a warning. */
+ strcpy(name_buf, default_name);
rprintf(FERROR,
RSYNC_NAME ": forward name lookup for %s:%s failed: %s\n",
name_buf, port_buf,
rprintf(FERROR,
RSYNC_NAME ": forward name lookup for %s:%s failed: %s\n",
name_buf, port_buf,
@@
-732,6
+737,7
@@
static int check_name(const struct sockaddr_storage *ss,
}
if (res == NULL) {
}
if (res == NULL) {
+ strcpy(name_buf, default_name);
/* We hit the end of the list without finding an
* address that was the same as ss. */
rprintf(FERROR, RSYNC_NAME
/* We hit the end of the list without finding an
* address that was the same as ss. */
rprintf(FERROR, RSYNC_NAME