openbsd-ports/net/bitlbee/patches/patch-url_c
naddy a2c69a5b0d Update to 0.90.
Partial audit for string handling.

From: Andrew Dalgleish <openbsd@ajd.net.au>
2004-06-20 16:27:49 +00:00

90 lines
2.5 KiB
Plaintext

$OpenBSD: patch-url_c,v 1.1 2004/06/20 16:27:49 naddy Exp $
--- url.c.orig 2004-04-05 03:06:56.000000000 +1000
+++ url.c 2004-06-09 20:37:14.000000000 +1000
@@ -35,7 +35,7 @@ int url_set( url_t *url, char *set_url )
if( ( i = strstr( set_url, "://" ) ) == NULL )
{
url->proto = PROTO_DEFAULT;
- strncpy( s, set_url, MAX_STRING );
+ strlcpy( s, set_url, sizeof(s));
}
else
{
@@ -49,22 +49,22 @@ int url_set( url_t *url, char *set_url )
{
return( 0 );
}
- strncpy( s, i + 3, MAX_STRING );
+ strlcpy( s, i + 3, sizeof(s));
}
/* Split */
if( ( i = strchr( s, '/' ) ) == NULL )
{
- strcpy( url->dir, "/" );
+ strlcpy(url->dir, "/", sizeof(url->dir));
}
else
{
*i = 0;
- g_snprintf( url->dir, MAX_STRING, "/%s", i + 1 );
+ g_snprintf( url->dir, sizeof(url->dir), "/%s", i + 1 );
if( url->proto == PROTO_HTTP )
- http_encode( url->dir );
+ http_encode( url->dir, sizeof(url->dir) );
}
- strncpy( url->host, s, MAX_STRING );
+ strlcpy( url->host, s, sizeof(url->host));
j = strchr( url->dir, '?' );
if( j != NULL )
*j = 0;
@@ -74,22 +74,22 @@ int url_set( url_t *url, char *set_url )
*j = '?';
if( i == NULL )
{
- strcpy( url->file, url->dir );
- strcpy( url->dir, "/" );
+ strlcpy( url->file, url->dir, sizeof(url->file) );
+ strlcpy( url->dir, "/", sizeof(url->dir) );
}
else
{
- strcpy( url->file, i + 1 );
- strcat( url->dir, "/" );
+ strlcpy( url->file, i + 1, sizeof(url->file) );
+ strlcat( url->dir, "/", sizeof(url->dir) );
}
/* Check for username in host field */
if( strrchr( url->host, '@' ) != NULL )
{
- strncpy( url->user, url->host, MAX_STRING );
+ strlcpy( url->user, url->host, sizeof(url->user));
i = strrchr( url->user, '@' );
*i = 0;
- strcpy( url->host, i + 1 );
+ strlcpy( url->host, i + 1, sizeof(url->host) );
*url->pass = 0;
}
/* If not: Fill in defaults */
@@ -97,8 +97,8 @@ int url_set( url_t *url, char *set_url )
{
if( url->proto == PROTO_FTP )
{
- strcpy( url->user, "anonymous" );
- strcpy( url->pass, "-p.artmaps@lintux.cx" );
+ strlcpy( url->user, "anonymous", sizeof(url->user) );
+ strlcpy( url->pass, "-p.artmaps@lintux.cx", sizeof(url->pass) );
}
else
{
@@ -110,7 +110,7 @@ int url_set( url_t *url, char *set_url )
if( ( i = strchr( url->user, ':' ) ) != NULL )
{
*i = 0;
- strcpy( url->pass, i + 1 );
+ strlcpy( url->pass, i + 1, sizeof(url->pass) );
}
/* Port number? */
if( ( i = strchr( url->host, ':' ) ) != NULL )