Index: branches/cparm/Chameleon.xcodeproj/project.pbxproj =================================================================== --- branches/cparm/Chameleon.xcodeproj/project.pbxproj (revision 2065) +++ branches/cparm/Chameleon.xcodeproj/project.pbxproj (revision 2066) @@ -450,9 +450,6 @@ AB43B3F814C384040018D529 /* stack_protector.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stack_protector.c; sourceTree = ""; }; AB79217514F38CF200F5EB39 /* bootXnu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootXnu.h; sourceTree = ""; }; AB79219214F3919E00F5EB39 /* ModuleHelp.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ModuleHelp.txt; sourceTree = ""; }; - ABA02705156CE81A00F8E5F3 /* ext2fs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ext2fs.c; sourceTree = ""; }; - ABA02706156CE81A00F8E5F3 /* ext2fs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ext2fs.h; sourceTree = ""; }; - ABA02707156CE81A00F8E5F3 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; ABA0C7BF1568190C003440AF /* arc4random-fbsd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "arc4random-fbsd.c"; sourceTree = ""; }; ABA0C7C01568190C003440AF /* lib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lib.c; sourceTree = ""; }; ABA0C7C11568190C003440AF /* rtc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rtc.c; sourceTree = ""; }; @@ -1082,7 +1079,6 @@ AB43B34914C37E520018D529 /* ACPICodec */, AB43B35214C37E520018D529 /* ACPIPatcher */, AB43B35914C37E520018D529 /* CPUfreq */, - ABA02704156CE81A00F8E5F3 /* Ext2fs */, AB43B35C14C37E520018D529 /* GraphicsEnabler */, AB43B36614C37E520018D529 /* GUI */, AB43B37014C37E520018D529 /* HelloWorld */, @@ -1396,16 +1392,6 @@ path = Intel_Acpi; sourceTree = ""; }; - ABA02704156CE81A00F8E5F3 /* Ext2fs */ = { - isa = PBXGroup; - children = ( - ABA02705156CE81A00F8E5F3 /* ext2fs.c */, - ABA02706156CE81A00F8E5F3 /* ext2fs.h */, - ABA02707156CE81A00F8E5F3 /* Makefile */, - ); - path = Ext2fs; - sourceTree = ""; - }; ABBBFCF915D55908002D7A1E /* bin */ = { isa = PBXGroup; children = ( Index: branches/cparm/CHANGES =================================================================== --- branches/cparm/CHANGES (revision 2065) +++ branches/cparm/CHANGES (revision 2066) @@ -1,3 +1,8 @@ +- Few security fixes +- Fixed a serious bug in picopng +- Fixed a bug in gui.c, related to the images loading +- Fixed a bug with acpi, where no acpi table may be configured + - Security fixes - Updated smbus(spd.c) and radeon(ati.c) card list (taken from the last cosmo1t's update) Index: branches/cparm/i386/libsaio/fake_efi.c =================================================================== --- branches/cparm/i386/libsaio/fake_efi.c (revision 2065) +++ branches/cparm/i386/libsaio/fake_efi.c (revision 2066) @@ -64,16 +64,17 @@ * necessary hardware. */ static inline char * mallocStringForGuid(EFI_GUID const *pGuid); -static VOID EFI_ST_FIX_CRC32(void); -static EFI_STATUS setupAcpiNoMod(); +static VOID EFI_ST_FIX_CRC32(VOID); +static EFI_STATUS setupAcpiNoMod(VOID); static EFI_CHAR16* getSmbiosChar16(const char * key, size_t* len); -static EFI_CHAR8* getSmbiosUUID(); -static int8_t *getSystemID(); -static VOID setupSystemType(); -static VOID setupEfiDeviceTree(void); -static VOID setup_Smbios(); -static VOID setup_machine_signature(); -static VOID setupEfiConfigurationTable(); +static EFI_CHAR8* getSmbiosUUID(VOID); +static int8_t *getSystemID(VOID); +static VOID setupSystemType(VOID); +static VOID setupEfiDeviceTree(VOID); +static VOID setup_Smbios(VOID); +static VOID setup_machine_signature(VOID); +static VOID setupEfiConfigurationTable(VOID); +static EFI_STATUS EFI_FindAcpiTables(VOID); /*========================================================================== * Utility function to make a device tree string from an EFI_GUID @@ -469,13 +470,14 @@ * ACPI */ -static uint64_t local_rsd_p; +static uint64_t local_rsd_p = 0; +static uint64_t kFSBFrequency = 0; +static uint32_t kHardware_signature = 0; +static uint8_t kType = 0; +static uint32_t kAdler32 = 0; static ACPI_TABLES acpi_tables; -static uint64_t kFSBFrequency; -static uint32_t kHardware_signature; -static uint8_t kType; -static uint32_t kAdler32; + EFI_STATUS Register_Acpi_Efi(void* rsd_p, unsigned char rev ) { EFI_STATUS Status = EFI_UNSUPPORTED; @@ -490,43 +492,73 @@ { Status = addConfigurationTable(&gEfiAcpiTableGuid, &local_rsd_p, "ACPI"); } - } + } + else + { + Status = setupAcpiNoMod(); + } + return Status; } -/* Setup ACPI without any patch. */ -static EFI_STATUS setupAcpiNoMod() -{ +static EFI_STATUS EFI_FindAcpiTables(VOID) +{ EFI_STATUS ret = EFI_UNSUPPORTED; - ACPI_TABLE_RSDP* rsdp = (ACPI_TABLE_RSDP*)((uint32_t)local_rsd_p); - if(rsdp->Revision > 0 && (GetChecksum(rsdp, sizeof(ACPI_TABLE_RSDP)) == 0)) + if (local_rsd_p) { - ret = addConfigurationTable(&gEfiAcpi20TableGuid, &local_rsd_p, "ACPI_20"); + return EFI_SUCCESS; } - else + + if (!FindAcpiTables(&acpi_tables)) { - ret = addConfigurationTable(&gEfiAcpiTableGuid, &local_rsd_p, "ACPI"); + printf("Failed to detect ACPI tables.\n"); + ret = EFI_NOT_FOUND; } + local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer)); + + if (local_rsd_p) + { + ret = EFI_SUCCESS; + } return ret; + } -EFI_STATUS setup_acpi (void) +/* Setup ACPI without any patch. */ +static EFI_STATUS setupAcpiNoMod(VOID) +{ + EFI_STATUS ret = EFI_UNSUPPORTED; + + if (EFI_FindAcpiTables() == EFI_SUCCESS) + { + ACPI_TABLE_RSDP* rsdp = (ACPI_TABLE_RSDP*)((uint32_t)local_rsd_p); + if(rsdp->Revision > 0 && (GetChecksum(rsdp, sizeof(ACPI_TABLE_RSDP)) == 0)) + { + ret = addConfigurationTable(&gEfiAcpi20TableGuid, &local_rsd_p, "ACPI_20"); + } + else + { + ret = addConfigurationTable(&gEfiAcpiTableGuid, &local_rsd_p, "ACPI"); + } + } + + return ret; +} + +EFI_STATUS setup_acpi (VOID) { EFI_STATUS ret = EFI_UNSUPPORTED; do { - if (!FindAcpiTables(&acpi_tables)) - { - printf("Failed to detect ACPI tables.\n"); - ret = EFI_NOT_FOUND; + + if ((ret = EFI_FindAcpiTables()) != EFI_SUCCESS) + { break; - } + } - local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer)); - { ACPI_TABLE_FADT *FacpPointer = (acpi_tables.FacpPointer64 != (void*)0ul) ? (ACPI_TABLE_FADT *)acpi_tables.FacpPointer64 : (ACPI_TABLE_FADT *)acpi_tables.FacpPointer; @@ -606,7 +638,7 @@ * Get the SystemID from the bios dmi info */ -static EFI_CHAR8* getSmbiosUUID() +static EFI_CHAR8* getSmbiosUUID(VOID) { static EFI_CHAR8 uuid[UUID_LEN]; int i, isZero, isOnes; @@ -648,7 +680,7 @@ * or from the bios if not, or from a fixed value if no bios value is found */ -static int8_t *getSystemID() +static int8_t *getSystemID(VOID) { static int8_t sysid[16]; // unable to determine UUID for host. Error: 35 fix @@ -687,7 +719,7 @@ * facp content to reflect in ioregs */ -static VOID setupSystemType() +static VOID setupSystemType(VOID) { Node *node = DT__FindNode("/", false); if (node == 0) stop("Couldn't get root node"); @@ -697,7 +729,7 @@ DT__AddProperty(node, SYSTEM_TYPE_PROP, sizeof(uint8_t), &kType); } -static VOID setupEfiDeviceTree(void) +static VOID setupEfiDeviceTree(VOID) { Node *node; @@ -941,7 +973,7 @@ } } -static VOID setup_Smbios() +static VOID setup_Smbios(VOID) { if (execute_hook("getSmbiosPatched",NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS) { @@ -951,7 +983,7 @@ } } -static VOID setup_machine_signature() +static VOID setup_machine_signature(VOID) { Node *chosenNode = DT__FindNode("/chosen", false); if (chosenNode) @@ -961,12 +993,11 @@ do { if (!local_rsd_p) { - if (!FindAcpiTables(&acpi_tables)){ + if ( EFI_FindAcpiTables() != EFI_SUCCESS) + { printf("Failed to detect ACPI tables.\n"); break; - } - - local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer)); + } } ACPI_TABLE_FACS *FacsPointer = (acpi_tables.FacsPointer64 != (void*)0ul) ? (ACPI_TABLE_FACS *)acpi_tables.FacsPointer64:(ACPI_TABLE_FACS *)acpi_tables.FacsPointer; @@ -993,7 +1024,7 @@ * Installs all the needed configuration table entries */ -static VOID setupEfiConfigurationTable() +static VOID setupEfiConfigurationTable(VOID) { if (smbios_p) addConfigurationTable(&gEfiSmbiosTableGuid, &smbios_p, NULL); Index: branches/cparm/i386/modules/GUI/picopng.c =================================================================== --- branches/cparm/i386/modules/GUI/picopng.c (revision 2065) +++ branches/cparm/i386/modules/GUI/picopng.c (revision 2066) @@ -110,16 +110,23 @@ void *png_alloc_realloc(void *addr, size_t size) { - void *new_addr; + void *new_addr = NULL; if (!addr) return png_alloc_malloc(size); - new_addr = realloc(addr, size); - if (new_addr && (new_addr != addr)) { - png_alloc_node_t *old_node; - old_node = png_alloc_find_node(addr); - png_alloc_remove_node(old_node); - png_alloc_add_node(new_addr, size); + + png_alloc_node_t *old_node; + old_node = png_alloc_find_node(addr); + + if (old_node) + { + new_addr = realloc(addr, size); + if (new_addr && (new_addr != addr)) + { + png_alloc_remove_node(old_node); + png_alloc_add_node(new_addr, size); + } } + return new_addr; } Index: branches/cparm/i386/modules/GUI/gui.c =================================================================== --- branches/cparm/i386/modules/GUI/gui.c (revision 2065) +++ branches/cparm/i386/modules/GUI/gui.c (revision 2066) @@ -501,7 +501,7 @@ width = 0; height = 0; imagedata = NULL; - if ( strlen(theme_name) > 0 && (loadPngImage(dirspec, &width, &height, &imagedata)) == 0) + if ((strlen(theme_name) > 0) && (loadPngImage(dirspec, &width, &height, &imagedata) != -1 )) { images[i].image->width = width; images[i].image->height = height; @@ -509,6 +509,7 @@ flipRB(images[i].image); DBG("[ %s ] succesfully loaded and registred !!\n", dirspec); + DBG("width = %d : height = %d !!\n",images[i].image->width,images[i].image->height); return 0; } @@ -520,7 +521,7 @@ embed_data = embeddedImages[e].pngdata; embed_size = *embeddedImages[e].length; - if (loadEmbeddedPngImage(embed_data, embed_size, &width, &height, &imagedata) == 0) + if (loadEmbeddedPngImage(embed_data, embed_size, &width, &height, &imagedata) != -1) { images[i].image->width = width; images[i].image->height = height; @@ -542,6 +543,9 @@ images[i].image->height = images[alt_image].image->height; images[i].image->pixels = images[alt_image].image->pixels; + DBG("Passing to alt_image !!\n"); + DBG("width = %d : height = %d !!\n",images[alt_image].image->width,images[alt_image].image->height); + } else { DBG("Unable to load %s, this image not vital anyway, reseting and returning success !!\n", dirspec); @@ -575,7 +579,7 @@ printf("[ %s/%s/%s.png ] not used in this version, skipped !!\n",src, theme_name, image); sleep(2); #endif - return 1; + return 0; } static int loadGraphics(char *src) @@ -983,7 +987,7 @@ if(GUI_getDimensionForKey("menu_height", &pixel, theme, gui.screen.height , 0 ) ) gui.menu.height = pixel; else - gui.menu.height = (infoMenuItemsCount) * images[iMenuSelection].image->height; + gui.menu.height = infoMenuItemsCount * images[iMenuSelection].image->height; if(GUI_getDimensionForKey("menu_pos_x", &pixel, theme, screen_width , gui.menu.width ) ) gui.menu.pos.x = pixel; @@ -2585,9 +2589,9 @@ return; } sprintf(dirspec, "%s/%s/boot.png", src, theme_name); - if (strlen(theme_name) == 0 || loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0) { + if ((strlen(theme_name) == 0) || (loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) == -1)) { #ifdef EMBED_THEME - if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) != 0) + if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) == -1) #endif usePngImage = false; } Index: branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c =================================================================== --- branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c (revision 2065) +++ branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c (revision 2066) @@ -558,7 +558,9 @@ bytes[patchLocation + 3] = 0x00; // cpuid_extfamily bytes[patchLocation + 4] = 0x02; // cpuid_stepping +#if 0 patchLocation = jumpLocation; +#endif // We now have 14 bytes available for a patch } else Index: branches/cparm/i386/modules/GraphicsEnabler/nvidia.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/nvidia.c (revision 2065) +++ branches/cparm/i386/modules/GraphicsEnabler/nvidia.c (revision 2066) @@ -1433,6 +1433,7 @@ DBG("%s Signature 0x%02x%02x %d bytes\n", nvFilename, rom[0], rom[1], nvBiosOveride); } else { printf("ERROR: unable to open nVidia Video BIOS File %s\n", nvFilename); + free(rom); return false; } } else { Index: branches/cparm/i386/modules/ACPICodec/acpi_codec.c =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 2065) +++ branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 2066) @@ -4711,7 +4711,10 @@ if (!FindAcpiTables(&acpi_tables)) { printf("Error: AcpiCodec Failed to detect ACPI tables.\n"); +#if DEBUG_ACPI getc(); +#endif + Register_Acpi_Efi(NULL, 0); return EFI_NOT_FOUND; } @@ -4912,6 +4915,7 @@ if (rsdp == (void*)0ul || (GetChecksum(rsdp, (rsdp->Revision == 0) ? ACPI_RSDP_REV0_SIZE:sizeof(ACPI_TABLE_RSDP)) != 0) ) { printf("Error : ACPI RSD PTR Revision %d checksum is incorrect or table not found \n",rsdp->Revision ); + Register_Acpi_Efi(NULL, 0); return EFI_UNSUPPORTED; } @@ -4941,7 +4945,11 @@ { rsdp_mod=(ACPI_TABLE_RSDP *) AllocateKernelMemory(rsdplength); - if (!rsdp_mod) return EFI_OUT_OF_RESOURCES; + if (!rsdp_mod) + { + Register_Acpi_Efi(NULL, 0); + return EFI_OUT_OF_RESOURCES; + } memcpy(rsdp_mod, rsdp, rsdplength); } @@ -5088,45 +5096,50 @@ } } - if ((rsdp_mod != (void *)0ul) && (rsdp_mod->Length >= ACPI_RSDP_REV0_SIZE) ) + if (rsdp_mod == (void *)0ul) + { + printf("Error: rsdp_mod == null \n"); + Register_Acpi_Efi(NULL, 0); + return EFI_ABORTED; + } + + if (!(rsdp_mod->Length >= ACPI_RSDP_REV0_SIZE)) { + printf("Error: rsdp_mod size is incorrect \n"); + Register_Acpi_Efi(NULL, 0); + return EFI_ABORTED; + + } + + do { + if ((rsdp_mod->Revision == 0) || (gen_xsdt == true)) { - process_rsdt(rsdp_mod, gen_xsdt, new_table_list); - goto out; + if (process_rsdt(rsdp_mod, gen_xsdt, new_table_list)) + break; + printf("Error : ACPI RSD PTR Revision 1 is incorrect, \n"); } - } - else - { + if ((GetChecksum(rsdp_mod, sizeof(ACPI_TABLE_RSDP)) == 0) && + (Revision == 2) && + (rsdplength == sizeof(ACPI_TABLE_RSDP))) + { + if (process_xsdt(rsdp_mod, new_table_list)) + break; + printf("Error : ACPI RSD PTR Revision 2 is incorrect \n"); + } + + Revision = 0; // fallback to Revision 0 + + if (process_rsdt(rsdp_mod, false, new_table_list)) + break; + printf("Error: Incorect ACPI RSD PTR or not found \n"); - return EFI_UNSUPPORTED; - } - - if ((GetChecksum(rsdp_mod, sizeof(ACPI_TABLE_RSDP)) == 0) && - (Revision == 2) && - (rsdplength == sizeof(ACPI_TABLE_RSDP))) - { - process_xsdt(rsdp_mod, new_table_list); - - } - else - { - printf("Warning : ACPI RSD PTR Revision 2 is incorrect, \n"); - printf(" trying to fallback to Revision 1\n"); - if ((rsdp_mod != (void *)0ul) && (rsdp_mod->Length >= ACPI_RSDP_REV0_SIZE) ) - { - process_rsdt(rsdp_mod, false, new_table_list); - - } - else - { - printf("Error: Incorect ACPI RSD PTR or not found \n"); - return EFI_UNSUPPORTED; - } - } - -out: + Register_Acpi_Efi(NULL, 0); + return EFI_ABORTED; + + } while (0); + // Correct the checksum of RSDP DBG("RSDP: Original checksum %d\n", rsdp_mod->Checksum); Index: branches/cparm/xcode3_sym.zip =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream