Merge topic 'curl-bug-1192'

e643e02 cmcurl: Backport curl bug 1192 fix (#14250)
This commit is contained in:
Brad King 2013-07-01 09:12:00 -04:00 committed by CMake Topic Stage
commit 84cb494703
7 changed files with 9 additions and 58 deletions

View File

@ -376,7 +376,6 @@ MARK_AS_ADVANCED(RANDOM_FILE)
#sigaction \ #sigaction \
#signal \ #signal \
#getpass_r \ #getpass_r \
#strlcat \
#getpwuid \ #getpwuid \
#geteuid \ #geteuid \
#dlopen \ #dlopen \
@ -428,7 +427,6 @@ CHECK_SYMBOL_EXISTS(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
CHECK_SYMBOL_EXISTS(setvbuf "${CURL_INCLUDES}" HAVE_SETVBUF) CHECK_SYMBOL_EXISTS(setvbuf "${CURL_INCLUDES}" HAVE_SETVBUF)
CHECK_SYMBOL_EXISTS(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP) CHECK_SYMBOL_EXISTS(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP)
CHECK_SYMBOL_EXISTS(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R) CHECK_SYMBOL_EXISTS(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R)
CHECK_SYMBOL_EXISTS(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT)
CHECK_SYMBOL_EXISTS(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID) CHECK_SYMBOL_EXISTS(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID)
CHECK_SYMBOL_EXISTS(geteuid "${CURL_INCLUDES}" HAVE_GETEUID) CHECK_SYMBOL_EXISTS(geteuid "${CURL_INCLUDES}" HAVE_GETEUID)
CHECK_SYMBOL_EXISTS(utime "${CURL_INCLUDES}" HAVE_UTIME) CHECK_SYMBOL_EXISTS(utime "${CURL_INCLUDES}" HAVE_UTIME)

View File

@ -76,7 +76,6 @@ IF(NOT UNIX)
SET(HAVE_SETVBUF 0) SET(HAVE_SETVBUF 0)
SET(HAVE_SIGSETJMP 0) SET(HAVE_SIGSETJMP 0)
SET(HAVE_GETPASS_R 0) SET(HAVE_GETPASS_R 0)
SET(HAVE_STRLCAT 0)
SET(HAVE_GETPWUID 0) SET(HAVE_GETPWUID 0)
SET(HAVE_GETEUID 0) SET(HAVE_GETEUID 0)
SET(HAVE_UTIME 1) SET(HAVE_UTIME 1)

View File

@ -343,9 +343,6 @@
/* Define to 1 if you have the <string.h> header file. */ /* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
/* Define to 1 if you have the `strlcat' function. */
/* #undef HAVE_STRLCAT */
/* Define to 1 if you have the `strlcpy' function. */ /* Define to 1 if you have the `strlcpy' function. */
/* #undef HAVE_STRLCPY */ /* #undef HAVE_STRLCPY */

View File

@ -441,9 +441,6 @@
/* Define to 1 if you have the <string.h> header file. */ /* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H ${HAVE_STRING_H} #cmakedefine HAVE_STRING_H ${HAVE_STRING_H}
/* Define to 1 if you have the `strlcat' function. */
#cmakedefine HAVE_STRLCAT ${HAVE_STRLCAT}
/* Define to 1 if you have the `strlcpy' function. */ /* Define to 1 if you have the `strlcpy' function. */
#cmakedefine HAVE_STRLCPY ${HAVE_STRLCPY} #cmakedefine HAVE_STRLCPY ${HAVE_STRLCPY}

View File

@ -199,8 +199,15 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
* This is currently not supporting "Identification Protocol (RFC1413)". * This is currently not supporting "Identification Protocol (RFC1413)".
*/ */
socksreq[8] = 0; /* ensure empty userid is NUL-terminated */ socksreq[8] = 0; /* ensure empty userid is NUL-terminated */
if (proxy_name) if(proxy_name) {
strlcat((char*)socksreq + 8, proxy_name, sizeof(socksreq) - 8); size_t plen = strlen(proxy_name);
if(plen >= sizeof(socksreq) - 8) {
failf(data, "Too long SOCKS proxy name, can't use!\n");
return CURLE_COULDNT_CONNECT;
}
/* copy the proxy name WITH trailing zero */
memcpy(socksreq + 8, proxy_name, plen+1);
}
/* /*
* Make connection * Make connection

View File

@ -99,45 +99,3 @@ char *Curl_strcasestr(const char *haystack, const char *needle)
} }
return NULL; return NULL;
} }
#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 Curl_strlcat(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;
if (n == 0)
return(dlen + strlen(s));
while (*s != '\0') {
if (n != 1) {
*d++ = *s;
n--;
}
s++;
}
*d = '\0';
return(dlen + (s - src)); /* count does not include NUL */
}
#endif

View File

@ -35,9 +35,4 @@
/* case insensitive strstr() */ /* case insensitive strstr() */
char *Curl_strcasestr(const char *haystack, const char *needle); char *Curl_strcasestr(const char *haystack, const char *needle);
#ifndef HAVE_STRLCAT
#define strlcat(x,y,z) Curl_strlcat(x,y,z)
#endif
size_t strlcat(char *dst, const char *src, size_t siz);
#endif #endif