mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Fixed ftp support with uClibc due to differing inet_ntoa_r() behaviour.
This commit is contained in:
parent
9a5c21c16f
commit
efaf688650
@ -1524,7 +1524,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
|||||||
&separator[2],
|
&separator[2],
|
||||||
&num,
|
&num,
|
||||||
&separator[3])) {
|
&separator[3])) {
|
||||||
char sep1 = separator[0];
|
const char sep1 = separator[0];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* The four separators should be identical, or else this is an oddly
|
/* The four separators should be identical, or else this is an oddly
|
||||||
@ -1539,7 +1539,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
|||||||
newport = num;
|
newport = num;
|
||||||
|
|
||||||
/* use the same IP we are already connected to */
|
/* use the same IP we are already connected to */
|
||||||
snprintf(newhost, NEWHOST_BUFSIZE, "%s", conn->ip_addr_str, newhost);
|
snprintf(newhost, NEWHOST_BUFSIZE, "%s", conn->ip_addr_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
11
lib/if2ip.c
11
lib/if2ip.c
@ -65,10 +65,6 @@
|
|||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL)
|
|
||||||
#include "inet_ntoa_r.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
#include <inet.h>
|
#include <inet.h>
|
||||||
#endif
|
#endif
|
||||||
@ -113,12 +109,7 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size)
|
|||||||
|
|
||||||
struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_dstaddr;
|
struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_dstaddr;
|
||||||
memcpy(&in, &(s->sin_addr.s_addr), sizeof(in));
|
memcpy(&in, &(s->sin_addr.s_addr), sizeof(in));
|
||||||
#if defined(HAVE_INET_NTOA_R)
|
ip = Curl_inet_ntop(s->sin_family, &in, buf, buf_size);
|
||||||
ip = inet_ntoa_r(in,buf,buf_size);
|
|
||||||
#else
|
|
||||||
ip = strncpy(buf,inet_ntoa(in),buf_size);
|
|
||||||
ip[buf_size - 1] = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
sclose(dummy);
|
sclose(dummy);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
#ifndef __INET_NTOA_R_H
|
#ifndef __INET_NTOA_R_H
|
||||||
#define __INET_NTOA_R_H
|
#define __INET_NTOA_R_H
|
||||||
|
|
||||||
|
#include "setup.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_INET_NTOA_R_2_ARGS
|
||||||
|
/*
|
||||||
|
* uClibc 0.9.26 (at least) doesn't define this prototype. The buffer
|
||||||
|
* must be at least 16 characters long.
|
||||||
|
*/
|
||||||
|
char *inet_ntoa_r(const struct in_addr in, char buffer[]);
|
||||||
|
|
||||||
|
#else
|
||||||
/*
|
/*
|
||||||
* My solaris 5.6 system running gcc 2.8.1 does *not* have this prototype
|
* My solaris 5.6 system running gcc 2.8.1 does *not* have this prototype
|
||||||
* in any system include file! Isn't that weird?
|
* in any system include file! Isn't that weird?
|
||||||
@ -7,3 +18,5 @@
|
|||||||
char *inet_ntoa_r(const struct in_addr in, char *buffer, int buflen);
|
char *inet_ntoa_r(const struct in_addr in, char *buffer, int buflen);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -56,8 +56,19 @@
|
|||||||
*/
|
*/
|
||||||
static const char *inet_ntop4 (const u_char *src, char *dst, size_t size)
|
static const char *inet_ntop4 (const u_char *src, char *dst, size_t size)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INET_NTOA_R
|
#if defined(HAVE_INET_NTOA_R_2_ARGS)
|
||||||
|
const char *ptr;
|
||||||
|
size_t len;
|
||||||
|
curlassert(size >= 16);
|
||||||
|
ptr = inet_ntoa_r(*(struct in_addr*)src, dst);
|
||||||
|
len = strlen(ptr);
|
||||||
|
memmove(dst, ptr, len);
|
||||||
|
dst[len] = 0;
|
||||||
|
return dst;
|
||||||
|
|
||||||
|
#elif defined(HAVE_INET_NTOA_R)
|
||||||
return inet_ntoa_r(*(struct in_addr*)src, dst, size);
|
return inet_ntoa_r(*(struct in_addr*)src, dst, size);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
const char *addr = inet_ntoa(*(struct in_addr*)src);
|
const char *addr = inet_ntoa(*(struct in_addr*)src);
|
||||||
|
|
||||||
|
@ -276,4 +276,8 @@ typedef int curl_socket_t;
|
|||||||
|
|
||||||
#define LIBIDN_REQUIRED_VERSION "0.4.1"
|
#define LIBIDN_REQUIRED_VERSION "0.4.1"
|
||||||
|
|
||||||
|
#ifdef __UCLIBC_MAJOR__
|
||||||
|
#define HAVE_INET_NTOA_R_2_ARGS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __CONFIG_H */
|
#endif /* __CONFIG_H */
|
||||||
|
@ -104,7 +104,6 @@ void idn_free (void *ptr); /* prototype from idn-free.h, not provided by
|
|||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "ssluse.h"
|
#include "ssluse.h"
|
||||||
#include "hostip.h"
|
#include "hostip.h"
|
||||||
#include "if2ip.h"
|
|
||||||
#include "transfer.h"
|
#include "transfer.h"
|
||||||
#include "sendf.h"
|
#include "sendf.h"
|
||||||
#include "progress.h"
|
#include "progress.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user