avoid compiler/linker warnings

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32483 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-03-07 11:34:17 +00:00
parent 695c2d279c
commit 96e48988fc
23 changed files with 271 additions and 167 deletions

View file

@ -1,3 +1,29 @@
2011-03-06 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPortCoder.m:
* Source/NSKeyValueCoding.m:
* Source/NSPathUtilities.m:
* Source/NSProcessInfo.m:
* Source/NSMethodSignature.m:
* Source/NSMessagePort.m:
* Source/NSInvocation.m:
* Source/dld-load.h:
* Source/NSFileManager.m:
* Source/NSURL.m:
* Source/NSString.m:
* Source/Additions/Unicode.m:
* Source/Additions/NSError+GNUstepBase.m:
* Source/Additions/GSXML.m:
* Source/Additions/GSObjCRuntime.m:
* Source/NSData.m:
* Source/NSHost.m:
* Source/GSMDNSNetServices.m:
* Source/GSValue.m:
* Source/NSTask.m:
* Tools/defaults.m:
* Tools/locale_alias.m:
Avoid strcpy and strcat to get rid if some bsd warnings.
2011-03-06 Richard Frith-Macdonald <rfm@gnu.org>
* config/config.initialize.m: Correct formatting. Increase time

View file

@ -427,6 +427,7 @@ GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars)
Class classSuperClass;
const char *classNameCString;
char *tmp;
int len;
NSCAssert(name, @"no name");
NSCAssert(superName, @"no superName");
@ -437,8 +438,10 @@ GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars)
NSCAssert1(!NSClassFromString(name), @"A class %@ already exists", name);
classNameCString = [name UTF8String];
tmp = malloc(strlen(classNameCString) + 1);
strcpy(tmp, classNameCString);
len = strlen(classNameCString);
tmp = malloc(len + 1);
strncpy(tmp, classNameCString, len);
tmp[len] = '\0';
classNameCString = tmp;
newClass = objc_allocateClassPair(classSuperClass, classNameCString, 0);

View file

@ -150,7 +150,7 @@ static char * xml_strdup(const char *from)
{
unsigned len = (from == 0) ? 1 : (strlen(from) + 1);
char *to = malloc(len);
strcpy(to, from);
memcpy(to, from, len);
return to;
}

View file

@ -60,14 +60,15 @@ strerror_r(int eno, char *buf, int len)
ptr = strerror(eno);
if (ptr == 0)
{
strncpy(buf, "unknown error number", len);
strncpy(buf, "unknown error number", len - 1);
result = -1;
}
else
{
strncpy(buf, strerror(eno), len);
strncpy(buf, strerror(eno), len - 1);
result = 0;
}
buf[len - 1] = '\0';
[gnustep_global_lock unlock];
return result;
}
@ -80,10 +81,11 @@ strerror_r(int eno, char *buf, int len)
if (eno < 0 || eno >= sys_nerr)
{
strncpy(buf, "unknown error number", len);
strncpy(buf, "unknown error number", len - 1);
return -1;
}
strncpy(buf, sys_errlist[eno], len);
strncpy(buf, sys_errlist[eno], len - 1);
buf[len - 1] = '\0';
return 0;
}
#endif

View file

@ -324,15 +324,16 @@ static void GSSetupEncodingTable(void)
if (entry->iconv != 0 && *(entry->iconv) != 0)
{
iconv_t c;
int l;
char *lossy;
/*
* See if we can do a lossy conversion.
*/
lossy = NSZoneMalloc(NSDefaultMallocZone(),
strlen(entry->iconv) + 12);
strcpy(lossy, entry->iconv);
strcat(lossy, "//TRANSLIT");
l = strlen(entry->iconv);
lossy = NSZoneMalloc(NSDefaultMallocZone(), l + 11);
strncpy(lossy, entry->iconv, l);
strncpy(lossy + l, "//TRANSLIT", 11);
c = iconv_open(UNICODE_ENC, entry->iconv);
if (c == (iconv_t)-1)
{
@ -2565,8 +2566,8 @@ GSPrivateDefaultCStringEncoding()
/* Take it from the system locale information. */
[gnustep_global_lock lock];
strncpy(encbuf, nl_langinfo(CODESET), sizeof(encbuf)-1);
[gnustep_global_lock unlock];
encbuf[sizeof(encbuf)-1] = '\0';
[gnustep_global_lock unlock];
encoding = encbuf;
/*

View file

@ -1523,8 +1523,6 @@ static void DNSSD_API
break;
}
strcat(key, "\0");
if ([[values objectAtIndex: i] isKindOfClass: [NSString class]])
{
char value[256];

View file

@ -100,8 +100,10 @@ typeSize(const char* type)
data = (void *)NSZoneMalloc([self zone], size);
memcpy(data, value, size);
}
objctype = (char *)NSZoneMalloc([self zone], strlen(type)+1);
strcpy(objctype, type);
size = strlen(type);
objctype = (char *)NSZoneMalloc([self zone], size + 1);
strncpy(objctype, type, size);
objctype[size] = '\0';
}
return self;
}

View file

@ -1327,7 +1327,8 @@ failure:
if (local_c_path != 0 && strlen(local_c_path) < (BUFSIZ*2))
{
strcpy(theRealPath,local_c_path);
strncpy(theRealPath, local_c_path, sizeof(theRealPath) - 1);
theRealPath[sizeof(theRealPath) - 1] = '\0';
error_BadPath = NO;
}
}
@ -1344,8 +1345,9 @@ failure:
int desc;
int mask;
strcpy(thePath, theRealPath);
strcat(thePath, "XXXXXX");
strncpy(thePath, theRealPath, sizeof(thePath) - 1);
thePath[sizeof(thePath) - 1] = '\0';
strncat(thePath, "XXXXXX", 6);
if ((desc = mkstemp(thePath)) < 0)
{
NSWarnMLog(@"mkstemp (%s) failed - %@", thePath, [NSError _last]);
@ -1361,7 +1363,8 @@ failure:
}
else
{
strcpy(thePath, theRealPath);
strncpy(thePath, theRealPath, sizeof(thePath) - 1);
thePath[sizeof(thePath) - 1] = '\0';
theFile = fopen(thePath, "wb");
}
#else
@ -1381,8 +1384,9 @@ failure:
goto failure;
}
#else
strcpy(thePath, theRealPath);
strcat(thePath, "XXXXXX");
strncpy(thePath, theRealPath, sizeof(thePath) - 1);
thePath[sizeof(thePath) - 1] = '\0';
strncat(thePath, "XXXXXX", 6);
if (mktemp(thePath) == 0)
{
NSWarnMLog(@"mktemp (%s) failed - %@", thePath, [NSError _last]);
@ -1395,7 +1399,8 @@ failure:
#if defined(__MINGW__)
wcscpy(wthePath,wtheRealPath);
#else
strcpy(thePath, theRealPath);
strncpy(thePath, theRealPath, sizeof(thePath) - 1);
thePath[sizeof(thePath) - 1] = '\0';
#endif
}

View file

@ -813,7 +813,7 @@ static NSStringEncoding defaultEncoding;
return NO;
}
strcpy(dirpath, lpath);
strncpy(dirpath, lpath, len);
dirpath[len] = '\0';
if (dirpath[len-1] == '/')
dirpath[len-1] = '\0';

View file

@ -280,7 +280,8 @@ myHostName()
}
else if (name == nil || strcmp(old, buf) != 0)
{
strcpy(old, buf);
strncpy(old, buf, sizeof(old) - 1);
old[sizeof(old) - 1] = '\0';
RELEASE(name);
name = [[NSString alloc] initWithCString: buf];
}

View file

@ -481,10 +481,13 @@ _arg_addr(NSInvocation *inv, int index)
}
else
{
int len;
char *tmp;
tmp = NSZoneMalloc(NSDefaultMallocZone(), strlen(newstr)+1);
strcpy(tmp, newstr);
len = strlen(newstr);
tmp = NSZoneMalloc(NSDefaultMallocZone(), len + 1);
strncpy(tmp, newstr, len);
tmp[len] = '\0';
_set_arg(self, index, tmp);
}
if (oldstr != 0)
@ -615,9 +618,12 @@ _arg_addr(NSInvocation *inv, int index)
if (str != 0)
{
char *tmp;
int len;
tmp = NSZoneMalloc(NSDefaultMallocZone(), strlen(str)+1);
strcpy(tmp, str);
len = strlen(str);
tmp = NSZoneMalloc(NSDefaultMallocZone(), len + 1);
strncpy(tmp, str, len);
tmp[len] = '\0';
_set_arg(self, i-1, &tmp);
}
}

View file

@ -91,8 +91,8 @@ SetValueForKey(NSObject *self, id anObject, const char *key, unsigned size)
char lo;
char hi;
strcpy(buf, "_set");
strcpy(&buf[4], key);
strncpy(buf, "_set", 4);
strncpy(&buf[4], key, size);
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;
@ -163,8 +163,9 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
char lo;
char hi;
strcpy(buf, "_get");
strcpy(&buf[4], key);
strncpy(buf, "_get", 4);
strncpy(&buf[4], key, size);
buf[size + 4] = '\0';
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;
@ -476,12 +477,13 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
SEL sel;
BOOL (*imp)(id,SEL,id*,id*);
strcpy(name, "validate");
strncpy(name, "validate", 8);
[aKey getCString: &name[8]
maxLength: size + 1
encoding: NSUTF8StringEncoding];
size = strlen(&name[8]);
strcpy(&name[size+8], ":error:");
strncpy(&name[size + 8], ":error:", 7);
name[size + 15] = '\0';
if (islower(name[8]))
{
name[8] = toupper(name[8]);
@ -612,12 +614,13 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
char lo;
char hi;
strcpy(buf, "_get");
strncpy(buf, "_get", 4);
[aKey getCString: key
maxLength: size + 1
encoding: NSUTF8StringEncoding];
size = strlen(key);
strcpy(&buf[4], key);
strncpy(&buf[4], key, size);
buf[size + 4] = '\0';
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;
@ -696,12 +699,13 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
char lo;
char hi;
strcpy(buf, "_set");
strncpy(buf, "_set", 4);
[aKey getCString: key
maxLength: size + 1
encoding: NSUTF8StringEncoding];
size = strlen(key);
strcpy(&buf[4], key);
strncpy(&buf[4], key, size);
buf[size + 4] = '\0';
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;
@ -817,8 +821,8 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
char lo;
char hi;
strcpy(buf, "_set");
strcpy(&buf[4], key);
strncpy(buf, "_set", 4);
strncpy(&buf[4], key, size);
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;

View file

@ -187,7 +187,7 @@ newDataWithEncodedPort(NSMessagePort *port)
pih->type = GSSwapHostI32ToBig(GSP_PORT);
pih->length = GSSwapHostI32ToBig(plen);
pi = (GSPortInfo*)&pih[1];
strcpy((char*)pi->addr, (char*)name);
strncpy((char*)pi->addr, (char*)name, strlen(name) + 1);
NSDebugFLLog(@"NSMessagePort", @"Encoded port as '%s'", pi->addr);

View file

@ -391,6 +391,8 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
const char *q;
char *args;
char *ret;
int alen;
int rlen;
/* In case we have been given a method encoding string without offsets,
* we attempt to generate the frame size and offsets in a new copy of
@ -428,11 +430,14 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
q = p;
p = objc_skip_type_qualifiers (p);
}
sprintf(ret + strlen(ret), "%d", (int)_argFrameLength);
_methodTypes = NSZoneMalloc(NSDefaultMallocZone(),
strlen(args) + strlen(ret) + 1);
strcpy((char*)_methodTypes, ret);
strcat((char*)_methodTypes, args);
alen = strlen(args);
rlen = strlen(ret);
sprintf(ret + rlen, "%d", (int)_argFrameLength);
_methodTypes = NSZoneMalloc(NSDefaultMallocZone(), alen + rlen + 1);
strncpy((char*)_methodTypes, ret, rlen);
strncpy(((char*)_methodTypes) + rlen, args, alen);
((char*)_methodTypes)[alen + rlen] = '\0';
}
return self;
}

View file

@ -1511,7 +1511,8 @@ NSUserName(void)
[gnustep_global_lock lock];
pwent = getpwuid (uid);
strcpy(buf, pwent->pw_name);
strncpy(buf, pwent->pw_name, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
[gnustep_global_lock unlock];
loginName = buf;
#endif /* HAVE_GETPWUID */

View file

@ -872,6 +872,7 @@ static IMP _xRefImp; /* Serialize a crossref. */
else
{
char *tmp;
int len;
if (xref != GSIArrayCount(_ptrAry))
{
@ -879,9 +880,10 @@ static IMP _xRefImp; /* Serialize a crossref. */
format: @"extra string crossref - %d", xref];
}
(*_dDesImp)(_src, dDesSel, &tmp, @encode(char*), &_cursor, nil);
*(void**)address = GSAutoreleasedBuffer(strlen(tmp)+1);
len = strlen(tmp);
*(void**)address = GSAutoreleasedBuffer(len + 1);
GSIArrayAddItem(_ptrAry, (GSIArrayItem)*(void**)address);
strcpy(*(char**)address, tmp);
memcpy(*(char**)address, tmp, len + 1);
NSZoneFree(NSDefaultMallocZone(), tmp);
}
return;

View file

@ -236,8 +236,11 @@ _gnu_process_args(int argc, char *argv[], char *env[])
if (argv != 0 && argv[0] != 0)
{
_gnu_arg_zero = (char*)malloc(strlen(argv[0]) + 1);
strcpy(_gnu_arg_zero, argv[0]);
int len;
len = strlen(argv[0]) + 1;
_gnu_arg_zero = (char*)malloc(len);
memcpy(_gnu_arg_zero, argv[0], len);
arg0 = [[NSString alloc] initWithCString: _gnu_arg_zero];
}
else
@ -246,6 +249,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
unichar *buffer;
int buffer_size = 0;
int needed_size = 0;
int len;
const char *tmp;
while (needed_size == buffer_size)
@ -272,8 +276,9 @@ _gnu_process_args(int argc, char *argv[], char *env[])
}
}
tmp = [arg0 cStringUsingEncoding: [NSString defaultCStringEncoding]];
_gnu_arg_zero = (char*)malloc(strlen(tmp) + 1);
strcpy(_gnu_arg_zero, tmp);
len = strlen(tmp) + 1;
_gnu_arg_zero = (char*)malloc(len);
memcpy(_gnu_arg_zero, tmp, len);
#else
fprintf(stderr, "Error: for some reason, argv not properly set up "
"during GNUstep base initialization\n");
@ -423,7 +428,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
{
char buf[len+2];
strcpy(buf, env[i]);
memcpy(buf, env[i], len + 1);
cp = &buf[cp - env[i]];
*cp++ = '\0';
[keys addObject:

View file

@ -3398,7 +3398,7 @@ static NSFileManager *fm = nil;
{
return NO;
}
strcpy(buffer, ptr);
strncpy(buffer, ptr, size);
return YES;
}
#endif
@ -4187,7 +4187,7 @@ static NSFileManager *fm = nil;
{
return IMMUTABLE(self); /* Resolved name too long. */
}
memcpy(dest, start, len);
memmove(dest, start, len);
dest += len;
*dest = '\0';
@ -4198,6 +4198,7 @@ static NSFileManager *fm = nil;
if (S_ISLNK(st.st_mode))
{
char buf[PATH_MAX];
int l;
if (++num_links > MAXSYMLINKS)
{
@ -4210,7 +4211,8 @@ static NSFileManager *fm = nil;
}
buf[n] = '\0';
if ((n + strlen(end)) >= PATH_MAX)
l = strlen(end);
if ((n + l) >= PATH_MAX)
{
return IMMUTABLE(self); /* Path too long. */
}
@ -4218,8 +4220,11 @@ static NSFileManager *fm = nil;
* Concatenate the resolved name with the string still to
* be processed, and start using the result as input.
*/
strcat(buf, end);
strcpy(extra, buf);
memcpy(buf + n, end, l);
n += l;
buf[n] = '\0';
memcpy(extra, buf, n);
extra[n] = '\0';
name = end = extra;
if (buf[0] == '/')
@ -4262,7 +4267,9 @@ static NSFileManager *fm = nil;
if (lstat(&newBuf[8], &st) == 0)
{
strcpy(newBuf, &newBuf[8]);
int l = strlen(newBuf) - 7;
memmove(newBuf, &newBuf[8], l);
}
}
return [[NSFileManager defaultManager]

View file

@ -167,7 +167,7 @@ pty_master(char* name, int len)
}
else
{
strcpy(name, (char*)slave);
strncpy(name, (char*)slave, len);
}
}
else
@ -178,7 +178,7 @@ pty_master(char* name, int len)
master = -1;
if (len > 10)
{
strcpy(name, "/dev/ptyXX");
strncpy(name, "/dev/ptyXX", len);
while (master < 0 && *groups != '\0')
{
int i;

View file

@ -166,6 +166,7 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
char *buf;
char *ptr;
char *tmp;
int l;
unsigned int len = 1;
if (rel->scheme != 0)
@ -222,8 +223,9 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
if (rel->scheme != 0)
{
strcpy(ptr, rel->scheme);
ptr = &ptr[strlen(ptr)];
l = strlen(rel->scheme);
memcpy(ptr, rel->scheme, l);
ptr += l;
*ptr++ = ':';
}
if (rel->isGeneric == YES
@ -235,14 +237,16 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
{
if (rel->user != 0)
{
strcpy(ptr, rel->user);
ptr = &ptr[strlen(ptr)];
l = strlen(rel->user);
memcpy(ptr, rel->user, l);
ptr += l;
}
if (rel->password != 0)
{
*ptr++ = ':';
strcpy(ptr, rel->password);
ptr = &ptr[strlen(ptr)];
l = strlen(rel->password);
memcpy(ptr, rel->password, l);
ptr += l;
}
if (rel->host != 0 || rel->port != 0)
{
@ -251,14 +255,16 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
}
if (rel->host != 0)
{
strcpy(ptr, rel->host);
ptr = &ptr[strlen(ptr)];
l = strlen(rel->host);
memcpy(ptr, rel->host, l);
ptr += l;
}
if (rel->port != 0)
{
*ptr++ = ':';
strcpy(ptr, rel->port);
ptr = &ptr[strlen(ptr)];
l = strlen(rel->port);
memcpy(ptr, rel->port, l);
ptr += l;
}
}
@ -273,11 +279,15 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
{
*tmp++ = '/';
}
strcpy(tmp, rpath);
l = strlen(rpath);
memcpy(tmp, rpath, l);
tmp += l;
}
else if (base == 0)
{
strcpy(tmp, rpath);
l = strlen(rpath);
memcpy(tmp, rpath, l);
tmp += l;
}
else if (rpath[0] == 0)
{
@ -285,7 +295,9 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
{
*tmp++ = '/';
}
strcpy(tmp, base->path);
l = strlen(base->path);
memcpy(tmp, base->path, l);
tmp += l;
}
else
{
@ -295,12 +307,15 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
if (end != 0)
{
*tmp++ = '/';
strncpy(tmp, start, end - start);
memcpy(tmp, start, end - start);
tmp += (end - start);
}
*tmp++ = '/';
strcpy(tmp, rpath);
l = strlen(rpath);
memcpy(tmp, rpath, l);
tmp += l;
}
*tmp = '\0';
if (standardize == YES)
{
@ -322,7 +337,8 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
}
else
{
strcpy(tmp, &tmp[2]);
l = strlen(&tmp[2]) + 1;
memmove(tmp, &tmp[2], l);
}
}
else
@ -338,7 +354,8 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
{
if (tmp[0] == '/' && tmp[1] == '/')
{
strcpy(tmp, &tmp[1]);
l = strlen(&tmp[1]) + 1;
memmove(tmp, &tmp[1], l);
}
else
{
@ -370,7 +387,8 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
}
else
{
strcpy(tmp, next);
l = strlen(next) + 1;
memmove(tmp, next, l);
}
}
/*
@ -379,7 +397,7 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
tmp = ptr;
if (*tmp == '\0')
{
strcpy(tmp, "/");
memcpy(tmp, "/", 2);
}
}
ptr = &ptr[strlen(ptr)];
@ -387,21 +405,25 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
if (rel->parameters != 0)
{
*ptr++ = ';';
strcpy(ptr, rel->parameters);
ptr = &ptr[strlen(ptr)];
l = strlen(rel->parameters);
memcpy(ptr, rel->parameters, l);
ptr += l;
}
if (rel->query != 0)
{
*ptr++ = '?';
strcpy(ptr, rel->query);
ptr = &ptr[strlen(ptr)];
l = strlen(rel->query);
memcpy(ptr, rel->query, l);
ptr += l;
}
if (rel->fragment != 0)
{
*ptr++ = '#';
strcpy(ptr, rel->fragment);
l = strlen(rel->fragment);
memcpy(ptr, rel->fragment, l);
ptr += l;
}
*ptr = '\0';
return buf;
}
@ -1343,6 +1365,7 @@ static unsigned urlAlign;
{
char *ptr = buf;
char *tmp = buf;
int l;
if (myData->pathIsAbsolute == YES)
{
@ -1352,14 +1375,16 @@ static unsigned urlAlign;
}
if (myData->path != 0)
{
strcpy(tmp, myData->path);
l = strlen(myData->path);
memcpy(tmp, myData->path, l + 1);
}
}
else if (_baseURL == nil)
{
if (myData->path != 0)
{
strcpy(tmp, myData->path);
l = strlen(myData->path);
memcpy(tmp, myData->path, l + 1);
}
}
else if (*myData->path == 0)
@ -1370,7 +1395,8 @@ static unsigned urlAlign;
}
if (baseData->path != 0)
{
strcpy(tmp, baseData->path);
l = strlen(baseData->path);
memcpy(tmp, baseData->path, l + 1);
}
}
else
@ -1387,7 +1413,8 @@ static unsigned urlAlign;
*tmp++ = '/';
if (myData->path != 0)
{
strcpy(tmp, myData->path);
l = strlen(myData->path);
memcpy(tmp, myData->path, l + 1);
}
}

View file

@ -57,14 +57,18 @@ __dld_construct_ctor_list(dl_handle_t module)
free(dld_ctor_list);
dld_ctor_list = (void **) __objc_xmalloc(length * sizeof(void *));
/* Find all symbols with the GLOBAL_PREFIX prefix */
for (i=0; i < TABSIZE; i++) {
for (i=0; i < TABSIZE; i++)
{
struct glosym *sym_entry = _dld_symtab[i];
for (; sym_entry; sym_entry = sym_entry->link) {
for (; sym_entry; sym_entry = sym_entry->link)
{
if (strstr(sym_entry->name, GLOBAL_PREFIX)
&& strstr(sym_entry->defined_by->filename, module)) {
&& strstr(sym_entry->defined_by->filename, module))
{
dld_ctor_list[ctors] = (void **)sym_entry->value;
ctors++;
if (ctors > length) {
if (ctors > length)
{
length *= 2;
dld_ctor_list = (void **) __objc_xrealloc(dld_ctor_list,
length * sizeof(void *));
@ -94,13 +98,15 @@ static dl_handle_t
__objc_dynamic_link(const char* module, int mode, const char* debug_file)
{
int error;
int length = strlen(module);
dl_handle_t handle;
error = dld_link(module);
if (error)
return NULL;
handle = (dl_handle_t)__objc_xmalloc (strlen(module) + 1);
strcpy(handle, module);
handle = (dl_handle_t)__objc_xmalloc (length + 1);
strncpy(handle, module, length);
handle[length] = '\0';
return handle;
}
@ -115,7 +121,8 @@ __objc_dynamic_find_symbol(dl_handle_t handle, const char* symbol)
static dl_symbol_t
__objc_dynamic_find_symbol(dl_handle_t handle, const char* symbol)
{
if (strcmp(symbol, DLD_CTOR_LIST) == 0) {
if (strcmp(symbol, DLD_CTOR_LIST) == 0)
{
return (dl_symbol_t)__dld_construct_ctor_list(handle);
}
return dld_get_bare_symbol(symbol);

View file

@ -55,7 +55,7 @@ static NSString *input(char **ptr)
{
if (*tmp == '\'')
{
strcpy(&tmp[-1], tmp);
memmove(&tmp[-1], tmp, strlen(tmp) + 1);
}
else
{

View file

@ -68,7 +68,8 @@ loc_read_file(const char *dir, const char *file)
}
if ((s = strstr(buf, "ocale for")) != NULL)
{
strcpy(country, s+10);
strncpy(country, s + 10, sizeof(country) - 1);
country[sizeof(country) - 1] = '\0';
s = strchr(country, '\n');
if (s)
*s = '\0';
@ -77,10 +78,11 @@ loc_read_file(const char *dir, const char *file)
break;
}
strcpy(locale, file);
strncpy(locale, file, sizeof(locale) - 1);
locale[sizeof(locale) - 1] = '\0';
if (strlen(country) > 0 && strcmp(country, language) != 0)
{
strcat(country, language);
strncat(country, language, sizeof(country) - 1 - strlen(country));
[dict setObject: [NSString stringWithUTF8String: country]
forKey: [NSString stringWithUTF8String: locale]];
}