Finally fixed strzcat on 64bit.

git-svn-id: https://proxytunnel.svn.sourceforge.net/svnroot/proxytunnel/trunk/proxytunnel@180 bc163920-b10d-0410-b2c5-a5491ca2ceef
This commit is contained in:
Dag Wieers 2008-01-20 12:06:15 +00:00
parent baaca8a6c4
commit bef1f87532
2 changed files with 39 additions and 46 deletions

44
http.c
View file

@ -108,20 +108,21 @@ void print_line_prefix(char *buf, char *prefix)
}
/*
* Append an undefined number of strings together
* Append an variable number of strings together
*/
void strzcat(char *strz, ...)
size_t strzcat(char *strz, ...)
{
va_list ap;
va_start(ap, strz);
char *z;
int i;
for(i=0; i<sizeof(*ap); i++) {
size_t dlen = 0;
va_start(ap, strz);
for(i=0; i<sizeof(*ap); i+=sizeof(ap[0])) {
z = va_arg(ap, char *);
strlcat(strz, z, SIZE);
// fprintf ( stderr, "strzcat: len-strz(%d)(%s), len-z(%d)(%s), size(%d)\n", strlen(strz), strz, strlen(z), z, SIZE );
dlen += strlcat(strz, z, SIZE);
}
va_end(ap);
return dlen;
}
/*
@ -155,37 +156,26 @@ void proxy_protocol(PTSTREAM *pts)
if (ntlm_challenge == 1)
{
build_type3_response();
// strzcat( buf, "Proxy-Authorization: NTLM ", ntlm_type3_buf, "\r\n" );
strlcat( buf, "Proxy-Authorization: NTLM ", SIZE );
strlcat( buf, ntlm_type3_buf, SIZE );
strlcat( buf, "\r\n", SIZE );
strzcat( buf, "Proxy-Authorization: NTLM ", ntlm_type3_buf, "\r\n" );
}
else if (ntlm_challenge == 0)
{
// strzcat( buf, "Proxy-Authorization: NTLM ", ntlm_type1_buf, "\r\n" );
strlcat( buf, "Proxy-Authorization: NTLM ", SIZE );
strlcat( buf, ntlm_type1_buf, SIZE );
strlcat( buf, "\r\n", SIZE );
strzcat( buf, "Proxy-Authorization: NTLM ", ntlm_type1_buf, "\r\n" );
}
}
else
{
// strzcat( buf, "Proxy-authorization: Basic ", basicauth, "\r\n" );
strlcat( buf, "Proxy-authorization: Basic ", SIZE );
strlcat( buf, basicauth, SIZE);
strlcat( buf, "\r\n", SIZE );
strzcat( buf, "Proxy-authorization: Basic ", basicauth, "\r\n" );
}
}
/* Add extra header(s) */
if ( args_info.header_given )
{
// strzcat( buf, args_info.header_arg, "\r\n" );
strlcat( buf, args_info.header_arg, SIZE );
strlcat( buf, "\r\n", SIZE );
strzcat( buf, args_info.header_arg, "\r\n" );
}
strlcat( buf, "Proxy-Connection: Keep-Alive\r\n\r\n", SIZE);
strzcat( buf, "Proxy-Connection: Keep-Alive\r\n\r\n");
/*
* Print the CONNECT instruction before sending to proxy
@ -228,19 +218,15 @@ void proxy_protocol(PTSTREAM *pts)
*/
if ( args_info.header_given )
{
// strzcat( buf, args_info.header_arg, "\r\n" );
strlcat( buf, args_info.header_arg, SIZE );
strlcat( buf, "\r\n", SIZE );
strzcat( buf, args_info.header_arg, "\r\n" );
}
if ( args_info.user_given && args_info.pass_given )
{
strlcat( buf, "Proxy-authorization: Basic ", SIZE );
strlcat( buf, basicauth, SIZE );
strlcat( buf, "\r\n", SIZE );
strzcat( buf, "Proxy-authorization: Basic ", basicauth, "\r\n" );
}
strlcat( buf, "Proxy-Connection: Keep-Alive\r\n\r\n", SIZE );
strzcat( buf, "Proxy-Connection: Keep-Alive\r\n\r\n" );
/*
* Print the CONNECT instruction before sending to proxy

View file

@ -86,7 +86,7 @@ int tunnel_connect() {
if( ! ( he = gethostbyname( args_info.proxyhost_arg ) ) )
{
// FIXME: my_perror("Local proxy %s could not be resolved", args_info.proxyhost_arg);
my_perror("Local proxy could not be resolved" );
my_perror("Local proxy could not be resolved." );
exit(1);
}
@ -119,12 +119,23 @@ int tunnel_connect() {
exit(1);
}
if( ! args_info.quiet_flag )
{
message( "Connected to %s:%d (local proxy)\n",
args_info.proxyhost_arg,
args_info.proxyport_arg );
}
if( ! args_info.quiet_flag )
{
if ( ! args_info.verbose_flag ) {
if ( args_info.remproxy_given ) {
message( "Via %s -> %s -> %s\n",
args_info.proxy_arg,
args_info.remproxy_arg,
args_info.dest_arg );
} else {
message( "Via %s -> %s\n",
args_info.proxy_arg,
args_info.dest_arg );
}
} else {
message( "Connected to %s (local proxy)\n", args_info.proxy_arg );
}
}
{ /* Increase interactivity of tunnel, patch by Ingo Molnar */
int flag = 1;
@ -146,16 +157,6 @@ int tunnel_connect() {
void closeall() {
// message( "In closeall\n");
if( args_info.verbose_flag )
{
message( "Tunnel closed\n" );
}
if( !args_info.quiet_flag )
{
message( "Goodbye" );
}
#ifndef CYGWIN
closelog();
#endif
@ -173,6 +174,12 @@ void closeall() {
stream_close(std);
std = NULL;
}
if( args_info.verbose_flag )
{
message( "Tunnel closed.\n" );
}
}
/*