Chameleon

Chameleon Commit Details

Date:2011-08-22 15:22:56 (12 years 8 months ago)
Author:JrCs
Commit:1449
Parents: 1448
Message:Add protections against buffer overflow
Changes:
M/trunk/i386/boot2/boot.c
M/trunk/i386/boot2/options.c

File differences

trunk/i386/boot2/boot.c
499499
500500
501501
502
502
503503
504504
505505
......
671671
672672
673673
674
674
675675
676676
677677
......
691691
692692
693693
694
694
695695
696696
697697
void*binary = (void *)kLoadAddr;
// additional variable for testing alternate kernel image locations on boot helper partitions.
char bootFile[512];
char bootFile[sizeof(bootInfo->bootFile)];
charbootFilePath[512];
// Initialize globals.
if (!bootFileWithDevice && (bootInfo->bootFile)[0] != '/')
sprintf(bootFile, "/%s", bootInfo->bootFile); // append a leading /
else
strcpy(bootFile, bootInfo->bootFile);
strlcpy(bootFile, bootInfo->bootFile, sizeof(bootFile));
// Try to load kernel image from alternate locations on boot helper partitions.
ret = -1;
}
if (ret == -1) {
// No alternate location found, using the original kernel image path.
strcpy(bootFilePath, bootFile);
strlcpy(bootFilePath, bootFile,sizeof(bootFilePath));
}
verbose("Loading kernel %s\n", bootFilePath);
trunk/i386/boot2/options.c
11961196
11971197
11981198
1199
1199
12001200
12011201
12021202
12031203
1204
1204
12051205
12061206
12071207
gOverrideKernel = false;
if (( kernel = extractKernelName((char **)&cp) )) {
strcpy( bootInfo->bootFile, kernel );
strlcpy( bootInfo->bootFile, kernel, sizeof(bootInfo->bootFile) );
} else {
if ( getValueForKey( kKernelNameKey, &val, &cnt, &bootInfo->bootConfig ) ) {
strlcpy( bootInfo->bootFile, val, cnt+1 );
} else {
strcpy( bootInfo->bootFile, kDefaultKernel );
strlcpy( bootInfo->bootFile, kDefaultKernel, sizeof(bootInfo->bootFile) );
}
}
if (strcmp( bootInfo->bootFile, kDefaultKernel ) != 0) {

Archive Download the corresponding diff file

Revision: 1449