mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
Fix C-string termination issues and a few dead assignments
This commit is contained in:
parent
9c9c918a8c
commit
1c2b81d724
1 changed files with 10 additions and 7 deletions
|
@ -701,7 +701,7 @@ static NSUInteger urlAlign;
|
||||||
host: (NSString*)aHost
|
host: (NSString*)aHost
|
||||||
path: (NSString*)aPath
|
path: (NSString*)aPath
|
||||||
{
|
{
|
||||||
NSRange r = NSMakeRange(NSNotFound, 0);
|
NSRange r;
|
||||||
NSString *auth = nil;
|
NSString *auth = nil;
|
||||||
NSString *aUrlString = [NSString alloc];
|
NSString *aUrlString = [NSString alloc];
|
||||||
|
|
||||||
|
@ -833,7 +833,7 @@ static NSUInteger urlAlign;
|
||||||
size += sizeof(parsedURL) + urlAlign + 1;
|
size += sizeof(parsedURL) + urlAlign + 1;
|
||||||
buf = _data = (parsedURL*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
buf = _data = (parsedURL*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
||||||
memset(buf, '\0', size);
|
memset(buf, '\0', size);
|
||||||
start = end = ptr = (char*)&buf[1];
|
start = end = (char*)&buf[1];
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
[_urlString getCString: start
|
[_urlString getCString: start
|
||||||
|
@ -931,7 +931,7 @@ static NSUInteger urlAlign;
|
||||||
if (start[0] == '/' && start[1] == '/')
|
if (start[0] == '/' && start[1] == '/')
|
||||||
{
|
{
|
||||||
buf->isGeneric = YES;
|
buf->isGeneric = YES;
|
||||||
start = end = &end[2];
|
start = &end[2];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set 'end' to point to the start of the path, or just past
|
* Set 'end' to point to the start of the path, or just past
|
||||||
|
@ -1439,11 +1439,13 @@ static NSUInteger urlAlign;
|
||||||
char *tmp = buf;
|
char *tmp = buf;
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
|
*buf = '\0';
|
||||||
if (myData->pathIsAbsolute == YES)
|
if (myData->pathIsAbsolute == YES)
|
||||||
{
|
{
|
||||||
if (myData->hasNoPath == NO)
|
if (myData->hasNoPath == NO)
|
||||||
{
|
{
|
||||||
*tmp++ = '/';
|
*tmp++ = '/';
|
||||||
|
*tmp = '\0';
|
||||||
}
|
}
|
||||||
if (myData->path != 0)
|
if (myData->path != 0)
|
||||||
{
|
{
|
||||||
|
@ -1464,6 +1466,7 @@ static NSUInteger urlAlign;
|
||||||
if (baseData->hasNoPath == NO)
|
if (baseData->hasNoPath == NO)
|
||||||
{
|
{
|
||||||
*tmp++ = '/';
|
*tmp++ = '/';
|
||||||
|
*tmp = '\0';
|
||||||
}
|
}
|
||||||
if (baseData->path != 0)
|
if (baseData->path != 0)
|
||||||
{
|
{
|
||||||
|
@ -1483,6 +1486,7 @@ static NSUInteger urlAlign;
|
||||||
tmp += end - start;
|
tmp += end - start;
|
||||||
}
|
}
|
||||||
*tmp++ = '/';
|
*tmp++ = '/';
|
||||||
|
*tmp = '\0';
|
||||||
if (myData->path != 0)
|
if (myData->path != 0)
|
||||||
{
|
{
|
||||||
l = strlen(myData->path);
|
l = strlen(myData->path);
|
||||||
|
@ -1504,8 +1508,8 @@ static NSUInteger urlAlign;
|
||||||
if (myData->isFile == YES)
|
if (myData->isFile == YES)
|
||||||
{
|
{
|
||||||
if ((ptr[1] && isalpha(ptr[1]))
|
if ((ptr[1] && isalpha(ptr[1]))
|
||||||
&& (ptr[2] == ':' || ptr[2] == '|')
|
&& (ptr[2] == ':' || ptr[2] == '|')
|
||||||
&& (ptr[3] == '\0' || ptr[3] == '/' || ptr[3] == '\\'))
|
&& (ptr[3] == '\0' || ptr[3] == '/' || ptr[3] == '\\'))
|
||||||
{
|
{
|
||||||
ptr[2] = ':';
|
ptr[2] = ':';
|
||||||
ptr++; // remove leading slash
|
ptr++; // remove leading slash
|
||||||
|
@ -1531,7 +1535,7 @@ static NSUInteger urlAlign;
|
||||||
{
|
{
|
||||||
char *end = unescape(myData->host + 1, buf);
|
char *end = unescape(myData->host + 1, buf);
|
||||||
|
|
||||||
if (end[-1] == ']')
|
if (end > buf && end[-1] == ']')
|
||||||
{
|
{
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -2490,7 +2494,6 @@ static NSCharacterSet *queryItemCharSet = nil;
|
||||||
location += 1;
|
location += 1;
|
||||||
[urlString appendString: component];
|
[urlString appendString: component];
|
||||||
internal->_rangeOfFragment = NSMakeRange(location, len);
|
internal->_rangeOfFragment = NSMakeRange(location, len);
|
||||||
location += len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIGNCOPY(internal->_string, urlString);
|
ASSIGNCOPY(internal->_string, urlString);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue