From 78cdd6e7eca44346377346fa6d84a9b59a8f5624 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Nov 2007 09:27:04 -0700 Subject: Fix state_path to take a const string, not use pstring. Jeremy. (This used to be commit 8c73e19f51d6e3f520cf44dd22f9b9584d4b460f) --- source3/lib/util.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index c8f0c3121f..0ae80c1f9e 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -550,7 +550,7 @@ int set_message(char *buf,int num_words,int num_bytes,bool zero) int set_message_bcc(char *buf,int num_bytes) { int num_words = CVAL(buf,smb_wct); - SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); + SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4); return (smb_size + num_words*2 + num_bytes); } @@ -2450,21 +2450,25 @@ char *data_path(const char *name) /***************************************************************** a useful function for returning a path in the Samba state directory *****************************************************************/ -char *state_path(char *name) + +char *state_path(const char *name) { - pstring fname; + TALLOC_CTX *ctx = talloc_tos(); + char *fname = talloc_strdup(ctx, dyn_STATEDIR()); - pstrcpy(fname,dyn_STATEDIR()); + if (!fname) { + smb_panic("state_path: out of memory"); + } trim_string(fname,"","/"); if (!directory_exist(fname,NULL)) { mkdir(fname,0755); } - pstrcat(fname,"/"); - pstrcat(fname,name); + fname = talloc_asprintf(ctx, "%s/%s", + fname, name); - return talloc_strdup(talloc_tos(), fname); + return fname; } /** -- cgit From e075b3692bb2c9507231f0662010fc55c1b506c4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Nov 2007 10:25:34 -0700 Subject: Fix Solaris by ensuring we use the IPv4 or IPv6 length in any getnameinfo calls. Jeremy (This used to be commit 4d7badb0c44f287034f58d9a412e662c0fbecdc9) --- source3/lib/interfaces.c | 17 ++++++++++++++--- source3/lib/system.c | 24 ++++++++++++++++++++++++ source3/lib/util_sock.c | 7 ++++--- 3 files changed, 42 insertions(+), 6 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c index 38abb9299b..01481c50e9 100644 --- a/source3/lib/interfaces.c +++ b/source3/lib/interfaces.c @@ -696,6 +696,16 @@ int get_interfaces(struct iface_struct *ifaces, int max_interfaces) #ifdef AUTOCONF_TEST /* this is the autoconf driver to test get_interfaces() */ +static socklen_t calc_sa_size(struct sockaddr *psa) +{ + socklen_t sl = sizeof(struct sockaddr_in); +#if defined(HAVE_IPV6) + if (psa->sa_family == AF_INET6) { + salen = sizeof(struct sockaddr_in6); + } +#endif +} + int main() { struct iface_struct ifaces[MAX_INTERFACES]; @@ -710,22 +720,23 @@ int get_interfaces(struct iface_struct *ifaces, int max_interfaces) for (i=0;isa_family == AF_INET6) { + salen = sizeof(struct sockaddr_in6); + } +#endif + } + return getnameinfo(psa, salen, host, hostlen, service, servlen, flags); +} diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index bbcbcacb4a..b4fda54ebd 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -495,7 +495,7 @@ bool is_address_any(const struct sockaddr_storage *psa) Print out an IPv4 or IPv6 address from a struct sockaddr_storage. ****************************************************************************/ -char *print_sockaddr_len(char *dest, +static char *print_sockaddr_len(char *dest, size_t destlen, const struct sockaddr_storage *psa, socklen_t psalen) @@ -503,7 +503,7 @@ char *print_sockaddr_len(char *dest, if (destlen > 0) { dest[0] = '\0'; } - (void)getnameinfo((const struct sockaddr *)psa, + (void)sys_getnameinfo((const struct sockaddr *)psa, psalen, dest, destlen, NULL, 0, @@ -519,7 +519,8 @@ char *print_sockaddr(char *dest, size_t destlen, const struct sockaddr_storage *psa) { - return print_sockaddr_len(dest, destlen, psa, sizeof(*psa)); + return print_sockaddr_len(dest, destlen, psa, + sizeof(struct sockaddr_storage)); } /**************************************************************************** -- cgit