int sslen;
char hbuf[NI_MAXHOST];
char *localaddr;
+ struct sockaddr *sa=(struct sockaddr *)&ss;
#ifdef NI_WITHSCOPEID
const int niflags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
#else
return CURLE_FTP_PORT_FAILED;
memset(&hints, 0, sizeof(hints));
- hints.ai_family = ss.ss_family;
+ hints.ai_family = sa->sa_family;
+ /*hints.ai_family = ss.ss_family;
+ this way can be used if sockaddr_storage is properly defined, as glibc
+ 2.1.X doesn't do*/
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
if (getaddrinfo(hbuf, "0", &hints, &res))
}
sslen = sizeof(ss);
- if (getsockname(portsock, (struct sockaddr *)&ss, &sslen) < 0) {
+ if (getsockname(portsock, sa, &sslen) < 0) {
failf(data, strerror(errno));
freeaddrinfo(res);
return CURLE_FTP_PORT_FAILED;
for (modep = mode; modep && *modep; modep++) {
int lprtaf, eprtaf;
- switch (ss.ss_family) {
+ switch (sa->sa_family) {
case AF_INET:
ap = (char *)&((struct sockaddr_in *)&ss)->sin_addr;
alen = sizeof(((struct sockaddr_in *)&ss)->sin_addr);
portmsgbuf, sizeof(portmsgbuf), tmp, sizeof(tmp), niflags))
continue;
/* do not transmit IPv6 scope identifier to the wire */
- if (ss.ss_family == AF_INET6) {
+ if (sa->sa_family == AF_INET6) {
char *q = strchr(portmsgbuf, '%');
if (q)
*q = '\0';
if (strcmp(*modep, "LPRT") == 0 && lprtaf < 0)
continue;
- if (strcmp(*modep, "PORT") == 0 && ss.ss_family != AF_INET)
+ if (strcmp(*modep, "PORT") == 0 && sa->sa_family != AF_INET)
continue;
portmsgbuf[0] = '\0';
#endif
}
+#ifndef HAVE_STRLCAT
+/*
+ * The strlcat() function appends the NUL-terminated string src to the end
+ * of dst. It will append at most size - strlen(dst) - 1 bytes, NUL-termi-
+ * nating the result.
+ *
+ * The strlcpy() and strlcat() functions return the total length of the
+ * string they tried to create. For strlcpy() that means the length of src.
+ * For strlcat() that means the initial length of dst plus the length of
+ * src. While this may seem somewhat confusing it was done to make trunca-
+ * tion detection simple.
+ */
+size_t strlcat(char *dst, const char *src, size_t size)
+{
+ size_t len = strlen(dst);
+ size_t orglen = len;
+ int index=0;
+
+ while(src[index] && (len < (size-1)) ) {
+ dst[len++] = src[index++];
+ }
+ dst[len]=0;
+
+ return orglen + strlen(src);
+}
+#endif