Chameleon

Chameleon Commit Details

Date:2011-10-22 12:02:28 (7 years 5 months ago)
Author:JrCs
Commit:1649
Parents: 1648
Message:Populate /chosen devicetree - Fix facetime & iCloud bug - Add protections against buffer overflow
Changes:
M/trunk/i386/boot2/boot.c
M/trunk/i386/libsaio/fake_efi.c
M/trunk/i386/boot2/boot.h
M/trunk/i386/boot2/options.c

File differences

trunk/i386/libsaio/fake_efi.c
620620
621621
622622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
623638
624639
625640
......
683698
684699
685700
701
702
703
686704
687705
688706
}
/*
* Populate the chosen node
*/
void setupChosenNode()
{
Node *chosenNode;
chosenNode = DT__FindNode("/chosen", false);
if (chosenNode == 0)
stop("Couldn't get chosen node");
int bootUUIDLength = strlen(gBootUUIDString);
if (bootUUIDLength)
DT__AddProperty(chosenNode, "boot-uuid", bootUUIDLength + 1, gBootUUIDString);
}
/*
* Load the smbios.plist override config file if any
*/
static void setupSmbiosConfigFile(const char *filename)
gST64->Hdr.CRC32 = 0;
gST64->Hdr.CRC32 = crc32(0L, gST64, gST64->Hdr.HeaderSize);
}
// Setup the chosen node
setupChosenNode();
}
void saveOriginalSMBIOS(void)
trunk/i386/boot2/boot.c
7272
7373
7474
75
75
7676
7777
7878
static chargCacheNameAdler[64 + 256];
char*gPlatformName = gCacheNameAdler;
chargRootDevice[512];
chargRootDevice[ROOT_DEVICE_SIZE];
chargMKextName[512];
chargMacOSVersion[8];
intbvCount = 0, gDeviceCount = 0;
trunk/i386/boot2/boot.h
147147
148148
149149
150
150151
151152
152153
......
224225
225226
226227
227
228
229
228
229
230
231
232
230233
231234
232235
* A global set by boot() to record the device that the booter
* was loaded from.
*/
#define ROOT_DEVICE_SIZE 512
extern int gBIOSDev;
extern long gBootMode;
extern bool sysConfigValid;
/*
* options.c
*/
extern int getBootOptions(bool firstRun);
extern int processBootOptions();
extern int selectAlternateBootDevice(int bootdevice);
extern char gBootUUIDString[];
extern int getBootOptions(bool firstRun);
extern int processBootOptions();
extern int selectAlternateBootDevice(int bootdevice);
extern bool promptForRescanOption(void);
void showHelp();
trunk/i386/boot2/options.c
10631063
10641064
10651065
1066
10661067
10671068
10681069
......
11051106
11061107
11071108
1108
1109
1110
11091111
11101112
11111113
......
11221124
11231125
11241126
1125
1126
1127
1127
1128
11281129
11291130
11301131
......
11341135
11351136
11361137
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1138
1139
1140
1141
1142
1143
1144
1145
1146
11481147
11491148
11501149
......
12241223
12251224
12261225
1227
1228
1229
1230
1231
1232
1226
1227
1228
12331229
12341230
12351231
12361232
1237
1238
1239
1233
1234
1235
12401236
1241
1242
1243
1244
1237
1238
1239
1240
12451241
12461242
1247
1248
1249
1250
1251
1243
1244
1245
12521246
1253
1247
1248
1249
1250
12541251
1255
1252
1253
12561254
12571255
12581256
......
12601258
12611259
12621260
1263
1261
12641262
12651263
12661264
......
12791277
12801278
12811279
1282
1280
1281
12831282
12841283
12851284
//==========================================================================
char gBootUUIDString[32+4+1] = ""; // UUID of the boot volume e.g. 5EB1869F-C4FA-3502-BDEB-3B8ED5D87292
extern unsigned char chainbootdev;
extern unsigned char chainbootflag;
const char *configTable,
char **argP, // Output value
int *cntRemainingP, // Output count
char *foundVal // found value
char *foundVal, // found value
int foundValSize // max found value size
)
{
const char *val;
copyArgument(argName, val, cnt, argP, cntRemainingP);
found = true;
}
if (found && foundVal) {
strlcpy(foundVal, val, cnt+1);
}
if (found && foundVal)
strlcpy(foundVal, val, foundValSize);
return found;
}
int
processBootOptions()
{
const char * cp = gBootArgs;
const char * val = 0;
const char * kernel;
int cnt;
int userCnt;
int cntRemaining;
char * argP;
char uuidStr[64];
bool uuidSet = false;
char * configKernelFlags;
char * valueBuffer;
const char *cp = gBootArgs;
const char *val = 0;
const char *kernel;
int cnt;
int userCnt;
int cntRemaining;
char *argP;
char *configKernelFlags;
char *valueBuffer;
valueBuffer = malloc(VALUE_SIZE);
configKernelFlags = malloc(cnt + 1);
strlcpy(configKernelFlags, val, cnt + 1);
if (processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, 0)) {
// boot-uuid was set either on the command-line
// or in the config file.
uuidSet = true;
} else {
// boot-uuid can be set either on the command-line or in the config file
if (!processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config,
&argP, &cntRemaining, gBootUUIDString, sizeof(gBootUUIDString))) {
//
// Try an alternate method for getting the root UUID on boot helper partitions.
//
if (gBootVolume->flags & kBVFlagBooter)
{
if((loadHelperConfig(&bootInfo->helperConfig) == 0)
&& getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig) )
{
// Load the configuration store in the boot helper partition
if (loadHelperConfig(&bootInfo->helperConfig) == 0)
{
getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig);
copyArgument(kBootUUIDKey, val, cnt, &argP, &cntRemaining);
uuidSet = true;
}
val = getStringForKey(kHelperRootUUIDKey, &bootInfo->helperConfig);
if (val != NULL)
strlcpy(gBootUUIDString, val, sizeof(gBootUUIDString));
}
}
if (!uuidSet && gBootVolume->fs_getuuid && gBootVolume->fs_getuuid (gBootVolume, uuidStr) == 0) {
verbose("Setting boot-uuid to: %s\n", uuidStr);
copyArgument(kBootUUIDKey, uuidStr, strlen(uuidStr), &argP, &cntRemaining);
uuidSet = true;
}
// Try to get the volume uuid string
if (!strlen(gBootUUIDString) && gBootVolume->fs_getuuid)
gBootVolume->fs_getuuid(gBootVolume, gBootUUIDString);
}
// If we have the volume uuid add it to the commandline arguments
if (strlen(gBootUUIDString))
copyArgument(kBootUUIDKey, gBootUUIDString, strlen(gBootUUIDString), &argP, &cntRemaining);
}
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gRootDevice)) {
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config,
&argP, &cntRemaining, gRootDevice, ROOT_DEVICE_SIZE)) {
cnt = 0;
if ( getValueForKey( kBootDeviceKey, &val, &cnt, &bootInfo->chameleonConfig)) {
valueBuffer[0] = '*';
strlcpy(valueBuffer + 1, val, cnt);
val = valueBuffer;
} else {
if (uuidSet) {
if (strlen(gBootUUIDString)) {
val = "*uuid";
cnt = 5;
} else {
/*
* Removed. We don't need this anymore.
*
if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gPlatformName)) {
if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config,
&argP, &cntRemaining, gPlatformName, sizeof(gCacheNameAdler))) {
getPlatformName(gPlatformName);
copyArgument(kPlatformKey, gPlatformName, strlen(gPlatformName), &argP, &cntRemaining);
}

Archive Download the corresponding diff file

Revision: 1649