Chameleon

Chameleon Commit Details

Date:2015-03-13 13:27:40 (5 years 8 months ago)
Author:zenith432
Commit:2630
Parents: 2629
Message:Change identity snprintf to strncpy + misc printf issues
Changes:
M/branches/zenith432/i386/libsaio/spd.c
M/branches/zenith432/i386/libsaio/fake_efi.c
M/branches/zenith432/i386/libsaio/disk.c
M/branches/zenith432/i386/modules/Resolution/915resolution.c
M/branches/zenith432/i386/libsaio/saio_internal.h
M/branches/zenith432/i386/boot2/gui.h
M/branches/zenith432/i386/boot2/ramdisk.c
M/branches/zenith432/i386/boot2/options.c
M/branches/zenith432/i386/libsaio/xml.c
M/branches/zenith432/i386/libsaio/console.c
M/branches/zenith432/i386/boot2/boot.c
M/branches/zenith432/i386/libsa/libsa.h
M/branches/zenith432/i386/modules/AcpiCodec/acpi_codec.c
M/branches/zenith432/i386/libsaio/nvidia.c
M/branches/zenith432/i386/util/dyldsymboltool.c
M/branches/zenith432/i386/libsaio/ati.c
M/branches/zenith432/i386/libsaio/pci_root.c
M/branches/zenith432/i386/libsaio/hfs.c
M/branches/zenith432/i386/boot2/drivers.c
M/branches/zenith432/i386/libsaio/acpi_patcher.c

File differences

branches/zenith432/i386/libsaio/xml.c
4141
4242
4343
44
44
4545
4646
4747
......
4949
5050
5151
52
52
5353
5454
5555
if(tmp->id == id)
{
tmp->string = malloc(strlen(string)+1);
snprintf(tmp->string, strlen(string)+1,"%s", string);
strncpy(tmp->string, string, strlen(string)+1);
return;
}
tmp = tmp->next;
string_ref *new_ref = malloc(sizeof(string_ref));
new_ref->string = malloc(strlen(string)+1);
snprintf(new_ref->string, (strlen(string)+1)* sizeof(char),"%s", string);
strncpy(new_ref->string, string, (strlen(string)+1)* sizeof(char));
new_ref->id = id;
new_ref->next = ref_strings;
ref_strings = new_ref;
branches/zenith432/i386/libsaio/console.c
130130
131131
132132
133
133
134134
135135
136136
cursor = msgbuf;
msglog("%s\n", "Chameleon " I386BOOT_CHAMELEONVERSION " (svn-r" I386BOOT_CHAMELEONREVISION ")" " [" I386BOOT_BUILDDATE "]");
getRTCdatetime();
verbose("Logging started: %04d/%02d/%02d, %02d:%02d:%02d\n", datetime.year, datetime.mon, datetime.day, datetime.hour, datetime.mins, datetime.secs);
msglog("Logging started: %04d/%02d/%02d, %02d:%02d:%02d\n", datetime.year, datetime.mon, datetime.day, datetime.hour, datetime.mins, datetime.secs);
}
int msglog(const char * fmt, ...)
branches/zenith432/i386/libsaio/hfs.c
568568
569569
570570
571
571
572572
573573
574574
......
727727
728728
729729
730
730
731731
732732
733733
if (offset > fileLength)
{
printf("ReadFile(HFS%c): Offset is too large.\n", gIsHFSPlus ? "+" : "");
printf("ReadFile(HFS%s): Offset is too large.\n", gIsHFSPlus ? "+" : "");
return -1;
}
if ((SWAP_BE32(hfsPlusFile->userInfo.fdType) == kHardLinkFileType) && (SWAP_BE32(hfsPlusFile->userInfo.fdCreator) == kHFSPlusCreator))
{
sprintf(gLinkTemp, "%s/%s%ld", HFSPLUSMETADATAFOLDER, HFS_INODE_PREFIX, SWAP_BE32(hfsPlusFile->bsdInfo.special.iNodeNum));
sprintf(gLinkTemp, "%s/%s%d", HFSPLUSMETADATAFOLDER, HFS_INODE_PREFIX, SWAP_BE32(hfsPlusFile->bsdInfo.special.iNodeNum));
result = ResolvePathToCatalogEntry(gLinkTemp, flags, entry, kHFSRootFolderID, &tmpDirIndex);
}
}
branches/zenith432/i386/libsaio/acpi_patcher.c
104104
105105
106106
107
107
108108
109109
110110
......
390390
391391
392392
393
393
394394
395395
396396
397
397
398398
399399
400400
......
428428
429429
430430
431
431
432
433
434
435
436
437
438
432439
433440
434441
// Try finding 'filename' in the usual places
// Start searching any potential location for ACPI Table
snprintf(dirSpec, sizeof(dirSpec), "%s", filename);
strncpy(dirSpec, filename, sizeof dirSpec);
fd = open(dirSpec, 0);
if (fd < 0)
{
/* Try using the file specified with the DSDT option */
if (getValueForKey(kDSDT, &filename, &len, &bootInfo->chameleonConfig))
{
snprintf(dirSpec, sizeof(dirSpec), filename);
strncpy(dirSpec, filename, sizeof dirSpec);
}
else
{
sprintf(dirSpec, "DSDT.aml");
strcpy(dirSpec, "DSDT.aml");
//verbose("dirSpec, DSDT.aml");
}
{
char filename[512];
sprintf(filename, i > 0 ? "SSDT-%d.aml" : "SSDT.aml", i);
if (i > 0)
{
sprintf(filename, "SSDT-%d.aml", i);
}
else
{
strcpy(filename, "SSDT.aml");
}
if ( (new_ssdt[ssdt_count] = loadACPITable(filename)) )
{
branches/zenith432/i386/libsaio/spd.c
246246
247247
248248
249
249
250250
251251
252252
}
else
{
sprintf(asciiSerial, "0000000000000000");
strcpy(asciiSerial, "0000000000000000");
}
return strdup(asciiSerial);
branches/zenith432/i386/libsaio/pci_root.c
9494
9595
9696
97
97
9898
9999
100100
101
101
102102
103103
104104
// Try using the file specified with the DSDT option
if (getValueForKey(kDSDT, &dsdt_filename, &len, &bootInfo->chameleonConfig))
{
snprintf(dsdt_dirSpec, sizeof(dsdt_dirSpec), dsdt_filename);
strncpy(dsdt_dirSpec, dsdt_filename, sizeof dsdt_dirSpec);
}
else
{
sprintf(dsdt_dirSpec, "DSDT.aml");
strcpy(dsdt_dirSpec, "DSDT.aml");
}
int fd = search_and_get_acpi_fd(dsdt_dirSpec, &dsdt_filename);
branches/zenith432/i386/libsaio/nvidia.c
22842284
22852285
22862286
2287
2287
22882288
22892289
22902290
}
}
snprintf(biosVersion, sizeof(biosVersion), "%s", (nvBiosOveride > 0) ? nvFilename : version_str);
strncpy(biosVersion, (nvBiosOveride > 0) ? nvFilename : version_str, sizeof biosVersion);
snprintf(kNVCAP, sizeof(kNVCAP), "NVCAP_%04x", nvda_dev->device_id);
if (getValueForKey(kNVCAP, &value, &len, &bootInfo->chameleonConfig) && len == NVCAP_LEN * 2)
branches/zenith432/i386/libsaio/ati.c
21622162
21632163
21642164
2165
2165
21662166
21672167
21682168
......
21712171
21722172
21732173
2174
2174
21752175
21762176
21772177
......
23932393
23942394
23952395
2396
2396
23972397
23982398
23992399
24002400
24012401
24022402
2403
2403
24042404
24052405
24062406
if (from_pci)
{
rom_addr = (option_rom_header_t *)(pci_config_read32(card->pci_dev->dev.addr, PCI_ROM_ADDRESS) & ~0x7ff);
verbose(" @0x%x\n", rom_addr);
verbose(" @0x%x\n", (unsigned) rom_addr);
}
else
{
if (!validate_rom(rom_addr, card->pci_dev))
{
verbose("There is no ROM @0x%x\n", rom_addr);
verbose("There is no ROM @0x%x\n", (unsigned) rom_addr);
return false;
}
card->rom_size = rom_addr->rom_size * 512;
return false;
}
verbose("Found ATI card! Device ID:[%04X:%04X] Subsystem ID:[%08X] - Radeon [%04X:%08X] %s\n",
pci_dev->vendor_id, pci_dev->device_id, pci_dev->subsys_id, card->info->device_id, card->info->subsys_id, card->info->model_name);
pci_dev->vendor_id, pci_dev->device_id, pci_dev->subsys_id.subsys_id, card->info->device_id, card->info->subsys_id, card->info->model_name);
card->fb= (uint8_t *)(pci_config_read32(pci_dev->dev.addr, PCI_BASE_ADDRESS_0) & ~0x0f);
card->mmio= (uint8_t *)(pci_config_read32(pci_dev->dev.addr, PCI_BASE_ADDRESS_2) & ~0x0f);
card->io= (uint8_t *)(pci_config_read32(pci_dev->dev.addr, PCI_BASE_ADDRESS_4) & ~0x03);
verbose("Framebuffer @0x%08X MMIO @0x%08XI/O Port @0x%08X ROM Addr @0x%08X\n",
card->fb, card->mmio, card->io, pci_config_read32(pci_dev->dev.addr, PCI_ROM_ADDRESS));
(unsigned) card->fb, (unsigned) card->mmio, (unsigned) card->io, pci_config_read32(pci_dev->dev.addr, PCI_ROM_ADDRESS));
card->posted = radeon_card_posted();
verbose("ATI card %s, ", card->posted ? "POSTed" : "non-POSTed");
branches/zenith432/i386/libsaio/disk.c
742742
743743
744744
745
745746
746747
747748
......
15371538
15381539
15391540
1540
1541
15411542
15421543
15431544
......
23602361
23612362
23622363
2363
2364
23642365
23652366
23662367
//==============================================================================
static
BVRef newAPMBVRef( int biosdev, int partno, unsigned int blkoff,
const DPME * part,
FSInit initFunc, FSLoadFile loadFunc,
{
char stringuuid[100];
efi_guid_unparse_upper((EFI_GUID*)gptMap->ent_type, stringuuid);
verbose("Reading GPT partition %d, type %s\n", gptID, stringuuid);
verbose("Reading GPT partition %d, type %s\n", (unsigned) gptID, stringuuid);
// Getting fdisk like partition type.
fsType = probeFileSystem(biosdev, gptMap->ent_lba_start);
}
// Set the devices label
snprintf(bvr->label, sizeof(bvr->label), p);
strncpy(bvr->label, p, sizeof bvr->label);
}
branches/zenith432/i386/libsaio/fake_efi.c
825825
826826
827827
828
828
829829
830830
831831
if (getValueForKey(kSMBIOSKey, &override_pathname, &len, &bootInfo->chameleonConfig) && len > 0)
{
// Specify a path to a file, e.g. SMBIOS=/Extra/macProXY.plist
sprintf(dirSpecSMBIOS, override_pathname);
strcpy(dirSpecSMBIOS, override_pathname);
err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig);
}
else
branches/zenith432/i386/libsaio/saio_internal.h
9595
9696
9797
98
99
98
99
100100
101101
102102
extern int getchar(void);
extern int printf(const char *format, ...);
extern int error(const char *format, ...);
extern int verbose(const char *format, ...);
extern void stop(const char *format, ...) __attribute__ ((noreturn));
extern int verbose(const char *format, ...) __attribute__((format(printf,1,2)));
extern void stop(const char *format, ...) __attribute__ ((noreturn, format(printf,1,2)));
//Azi: replace getc/getchar with ? console.c
extern void pause();
extern uint64_t getRTCdatetime();
branches/zenith432/i386/boot2/drivers.c
212212
213213
214214
215
215
216216
217217
218218
......
525525
526526
527527
528
528
529529
530530
531531
|| (gRAMDiskVolume && gRAMDiskBTAliased) )
{
// Next try a specfic OS version folder ie 10.5
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion[0]);
if (FileLoadDrivers(dirSpecExtra, 0) != 0) {
// Next we'll try the base
strlcpy(dirSpecExtra, "bt(0,0)/Extra/", sizeof(dirSpecExtra));
}
else
{
snprintf(gFileSpec, 4096, "%s", dirSpec);
strncpy(gFileSpec, dirSpec, 4096);
}
bundlePathLength = strlen(gFileSpec) + 1;
branches/zenith432/i386/boot2/boot.c
345345
346346
347347
348
348
349349
350350
351351
if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
{
snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.recovery.boot/kernelcache", kernelCacheFile);
strncpy(kernelCachePath, "/com.apple.recovery.boot/kernelcache", sizeof kernelCachePath);
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((flags & kFileTypeMask) != kFileTypeFlat)
branches/zenith432/i386/boot2/gui.h
143143
144144
145145
146
147
146
147
148148
149149
150150
void showInfoBox(char *title, char *text);
int dprintf( window_t * window, const char * fmt, ...);
int gprintf( window_t * window, const char * fmt, ...);
int dprintf( window_t * window, const char * fmt, ...) __attribute__((format(printf,2,3)));
int gprintf( window_t * window, const char * fmt, ...) __attribute__((format(printf,2,3)));
int vprf(const char * fmt, va_list ap);
int drawInfoMenu();
branches/zenith432/i386/boot2/ramdisk.c
2929
3030
3131
32
32
3333
3434
3535
......
4747
4848
4949
50
50
5151
5252
5353
5454
55
55
5656
5757
5858
&bootInfo->chameleonConfig))
{
// Use user specified md0 file
snprintf(filename, sizeof(filename), "%s", override_filename);
strncpy(filename, override_filename, sizeof filename);
fh = open(filename, 0);
if(fh < 0)
if(fh < 0)
{
sprintf(filename, "rd(0,0)/Extra/Postboot.img");
strcpy(filename, "rd(0,0)/Extra/Postboot.img");
fh = open(filename, 0);
if(fh < 0)
{
sprintf(filename, "/Extra/Postboot.img");// Check /Extra if not in rd(0,0)
strcpy(filename, "/Extra/Postboot.img");// Check /Extra if not in rd(0,0)
fh = open(filename, 0);
}
}
branches/zenith432/i386/boot2/options.c
752752
753753
754754
755
756
755
756
757757
758
759
760
758
759
760
761761
762762
763763
(i < bootInfo->memoryMapCount) && (bufflen < 1024); /* prevent buffer overflow */
i++) {
bufflen += snprintf(buff+bufflen, 1024-bufflen, "Base 0x%08x%08x, ",
(unsigned long)(mp->base >> 32),
(unsigned long)(mp->base));
(unsigned)(mp->base >> 32),
(unsigned)(mp->base));
bufflen += snprintf(buff+bufflen, 1024-bufflen, "length 0x%08x%08x, type %d\n",
(unsigned long)(mp->length >> 32),
(unsigned long)(mp->length),
mp->type);
(unsigned)(mp->length >> 32),
(unsigned)(mp->length),
(int) mp->type);
mp++;
}
return buff;
branches/zenith432/i386/modules/Resolution/915resolution.c
296296
297297
298298
299
299
300300
301301
302302
303303
304304
305
305
306306
307307
308308
......
922922
923923
924924
925
925
926926
927927
928928
if (map->chipset == CT_UNKNOWN)
{
verbose(" Unknown chipset type: %08x.\n", map->chipset_id);
verbose(" Unknown chipset type: %08x.\n", (unsigned) map->chipset_id);
//verbose("915resolution only works with Intel 800/900 series graphic chipsets.\n");
//verbose("Chipset Id: %x\n", map->chipset_id);
close_vbios(map);
return 0;
} else {
verbose(" Detected chipset/proc id (DRAM controller): %08x\n", map->chipset_id);
verbose(" Detected chipset/proc id (DRAM controller): %08x\n", (unsigned) map->chipset_id);
}
/*if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force) {*/
if (!getMode(&mode))
{
verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode %d patched!\n", mode.h_active, mode.v_active, i);
verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode %d patched!\n", mode.h_active, mode.v_active, (int) i);
mode_timing[i].usH_Total = mode.h_active + mode.h_blanking;
mode_timing[i].usH_Active = mode.h_active;
mode_timing[i].usH_SyncStart = mode.h_active + mode.h_sync_offset;
branches/zenith432/i386/modules/AcpiCodec/acpi_codec.c
635635
636636
637637
638
638
639639
640640
641641
......
41674167
41684168
41694169
4170
4170
41714171
41724172
41734173
......
47604760
47614761
47624762
4763
4763
47644764
47654765
47664766
......
47704770
47714771
47724772
4773
4773
47744774
47754775
47764776
......
47794779
47804780
47814781
4782
4782
47834783
47844784
47854785
if (GetChecksum(header, header->Length) == 0)
{
DBG("Found valid AML file : %s ", filename);
verbose("[ %s ] read and stored at: %x", acpi_file, tableAddr);
verbose("[ %s ] read and stored at: 0x%x", acpi_file, (unsigned) tableAddr);
printf("\n");
return tableAddr;
}
memcpy(fadt_mod, fadt, fadt->Header.Length);
fadt_mod->Header.Length = 0x74;
fadt_mod->Header.Revision = 0x01;
verbose("Warning: ACPI FADT length was < 0x74 which is the minimum for the ACPI FADT V1 specification, \n", fadt->Header.Revision );
verbose("Warning: ACPI FADT length was < 0x74 which is the minimum for the ACPI FADT V1 specification, \n" /*, fadt->Header.Revision */ );
verbose(" trying to convert it to Version 1. \n");
}
ret = GetFileInfo("rd(0,0)/Extra/", "Acpi", &flags, &time);
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory))
{
sprintf(dirspec, "rd(0,0)/Extra/Acpi/");
strcpy(dirspec, "rd(0,0)/Extra/Acpi/");
acpidir_found = true;
}
ret = GetFileInfo("/Extra/", "Acpi", &flags, &time);
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory))
{
sprintf(dirspec, "/Extra/Acpi/");
strcpy(dirspec, "/Extra/Acpi/");
acpidir_found = true;
}
ret = GetFileInfo("bt(0,0)/Extra/", "Acpi", &flags, &time);
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory))
{
sprintf(dirspec, "bt(0,0)/Extra/Acpi/");
strcpy(dirspec, "bt(0,0)/Extra/Acpi/");
acpidir_found = true;
}
branches/zenith432/i386/libsa/libsa.h
137137
138138
139139
140
141
140
141
142142
143143
144144
/*
* printf.c
*/
extern int sprintf(char *s, const char *format, ...);
extern int snprintf(char *s, size_t size, const char *format, ...);
extern int sprintf(char *s, const char *format, ...) __attribute__((format(printf,2,3)));
extern int snprintf(char *s, size_t size, const char *format, ...) __attribute__((format(printf,3,4)));
extern int slvprintf(char *buffer, int len, const char *fmt, va_list arg);
/*
branches/zenith432/i386/util/dyldsymboltool.c
144144
145145
146146
147
147
148148
149149
150150
//dylib.dylib_info.cmdsize += offset;
//dylib.header.sizeofcmds += offset;
sprintf(dylib.module_name, "%s", DYLIB_NAME);
strcpy(dylib.module_name, DYLIB_NAME);
/* Load Commands - Symtable */
dylib.symtab.cmd = LC_SYMTAB;

Archive Download the corresponding diff file

Revision: 2630