Chameleon

Chameleon Commit Details

Date:2015-03-12 05:24:41 (4 years 8 months ago)
Author:ErmaC
Commit:2621
Parents: 2620
Message:More strncmp, strlcat and strlcpy.
Changes:
M/trunk/i386/boot2/drivers.c
M/trunk/i386/boot2/gui.c
M/trunk/i386/boot2/options.c

File differences

trunk/i386/boot2/drivers.c
203203
204204
205205
206
206
207207
208208
209209
......
215215
216216
217217
218
218
219219
220220
221221
......
228228
229229
230230
231
232
233
234
235
236
231
232
233
234
235
236
237
238
239
237240
238241
239242
......
352355
353356
354357
355
358
356359
357360
358361
......
514517
515518
516519
517
520
518521
519522
520523
......
532535
533536
534537
535
538
536539
537540
538541
......
546549
547550
548551
552
549553
550554
551555
552556
557
553558
554559
560
555561
556562
557563
558564
565
559566
560567
561568
......
708715
709716
710717
711
718
712719
713720
714721
715722
716
723
717724
718725
719726
}
// Next try to load Extra extensions from the selected root partition.
strcpy(dirSpecExtra, "/Extra/");
strlcpy(dirSpecExtra, "/Extra/", sizeof(dirSpecExtra));
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// If failed, then try to load Extra extensions from the boot partition
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
if (FileLoadDrivers(dirSpecExtra, 0) != 0) {
// Next we'll try the base
strcpy(dirSpecExtra, "bt(0,0)/Extra/");
strlcpy(dirSpecExtra, "bt(0,0)/Extra/", sizeof(dirSpecExtra));
FileLoadDrivers(dirSpecExtra, 0);
}
}
// The /Extra code is not disabled in this case due to a kernel patch that allows for this to happen.
// Also try to load Extensions from boot helper partitions.
if (gBootVolume->flags & kBVFlagBooter) {
strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0) {
strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0) {
strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/");
if (gBootVolume->flags & kBVFlagBooter)
{
strlcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/", sizeof(dirSpecExtra));
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
strlcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/", sizeof(dirSpecExtra));
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
strlcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/", sizeof(dirSpecExtra));
FileLoadDrivers(dirSpecExtra, 0);
}
}
// Make sure this is a kext.
length = strlen(name);
if (strcmp(name + length - 5, ".kext"))
if (strncmp(name + length - 5, ".kext", 5))
{
continue;
}
if (tmpExecutablePath == 0) {
break;
}
strcpy(tmpExecutablePath, gFileSpec);
strlcpy(tmpExecutablePath, gFileSpec, executablePathLength);
if(name)
{
break;
}
strcpy(tmpBundlePath, gFileSpec);
strlcpy(tmpBundlePath, gFileSpec, bundlePathLength);
// Construct the file spec to the plist, then load it.
}
length = LoadFile(gFileSpec);
if (length == -1)
{
break;
}
length = length + 1;
buffer = malloc(length);
if (buffer == 0)
{
break;
}
strlcpy(buffer, (char *)kLoadAddr, length);
// Parse the plist.
driver->bundlePathLength = module->bundlePathLength;
// Save the plist, module and bundle.
strcpy(driver->plistAddr, module->plistAddr);
strlcpy(driver->plistAddr, module->plistAddr,driver->plistLength);
if (length != 0)
{
memcpy(driver->executableAddr, executableAddr, length);
}
strcpy(driver->bundlePathAddr, module->bundlePath);
strlcpy(driver->bundlePathAddr, module->bundlePath, module->bundlePathLength);
// Add an entry to the memory map.
snprintf(segName, sizeof(segName), "Driver-%lx", (unsigned long)driver);
trunk/i386/boot2/gui.c
265265
266266
267267
268
269
268
269
270
271
270272
271273
272274
......
284286
285287
286288
287
289
288290
289291
290292
......
930932
931933
932934
933
934
935
936
937
935938
936939
937940
static int getImageIndexByName(const char *name)
{
int i;
for (i = 0; i < sizeof(images) / sizeof(images[0]); i++) {
if (strcmp(name, images[i].name) == 0) {
for (i = 0; i < sizeof(images) / sizeof(images[0]); i++)
{
if (strncmp(name, images[i].name, sizeof(images[i].name)) == 0)
{
return i; // found the name
}
}
// NOTE: This algorithm assumes that the embedded images are sorted.
// This is currently done using the make file. If the array is
// generated manualy, this *will* fail to work properly.
while((result = strcmp(name, embeddedImages[compareIndex].name)) != 0)
while((result = strncmp(name, embeddedImages[compareIndex].name, sizeof(embeddedImages[compareIndex].name))) != 0)
{
if (result > 0){ // We need to search a HIGHER index
if (compareIndex != lowerLimit) {
config_file_t*config;
config = &bootInfo->themeConfig;
if (ParseXMLFile((char *)__theme_plist, &config->dictionary) != 0) {
return 1;
if (ParseXMLFile((char *)__theme_plist, &config->dictionary) != 0)
{
return 1;
}
#else
trunk/i386/boot2/options.c
266266
267267
268268
269
269
270270
271271
272272
273273
274
274
275275
276276
277277
execute_hook("ClearArgs", NULL, NULL, NULL, NULL);
}
void addBootArg(const char * argStr)
void addBootArg(const char *argStr)
{
if ( (gBootArgsPtr + strlen(argStr) + 1) < gBootArgsEnd)
{
if(gBootArgsPtr != gBootArgs) *gBootArgsPtr++ = ' ';
strcat(gBootArgs, argStr);
strlcat(gBootArgs, argStr, BOOT_STRING_LEN);
gBootArgsPtr += strlen(argStr);
}
}

Archive Download the corresponding diff file

Revision: 2621