mirror of
https://github.com/86Box/probing-tools.git
synced 2026-02-21 17:15:34 -07:00
pcireg: Update POSIX-UEFI to fix fseek bug
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -181,7 +181,7 @@ pciids_read_string(uint32_t offset)
|
||||
return NULL;
|
||||
|
||||
/* Seek to string offset. */
|
||||
fseek_to(pciids_f, pciids_header.string_db_offset + offset);
|
||||
fseek(pciids_f, pciids_header.string_db_offset + offset, SEEK_SET);
|
||||
|
||||
/* Read string length, and return nothing if it's an empty string. */
|
||||
fread(&length, sizeof(length), 1, pciids_f);
|
||||
@@ -209,7 +209,7 @@ pciids_find_vendor(uint16_t vendor_id)
|
||||
return 0;
|
||||
|
||||
/* Seek to vendor database. */
|
||||
fseek_to(pciids_f, sizeof(pciids_header));
|
||||
fseek(pciids_f, sizeof(pciids_header), SEEK_SET);
|
||||
|
||||
/* Read vendor entries until the ID is matched or overtaken. */
|
||||
do {
|
||||
@@ -244,7 +244,7 @@ pciids_get_device(uint16_t device_id)
|
||||
return NULL;
|
||||
|
||||
/* Seek to device database entries for the established vendor. */
|
||||
fseek_to(pciids_f, pciids_header.device_db_offset + pciids_vendor.devices_offset);
|
||||
fseek(pciids_f, pciids_header.device_db_offset + pciids_vendor.devices_offset, SEEK_SET);
|
||||
|
||||
/* Read device entries until the ID is matched or overtaken. */
|
||||
do {
|
||||
@@ -271,7 +271,7 @@ pciids_get_subdevice(uint16_t subvendor_id, uint16_t subdevice_id)
|
||||
return NULL;
|
||||
|
||||
/* Seek to subdevice database entries for the established subvendor. */
|
||||
fseek_to(pciids_f, pciids_header.subdevice_db_offset + pciids_device.subdevices_offset);
|
||||
fseek(pciids_f, pciids_header.subdevice_db_offset + pciids_device.subdevices_offset, SEEK_SET);
|
||||
|
||||
/* Read subdevice entries until the ID is matched or overtaken. */
|
||||
do {
|
||||
@@ -296,7 +296,7 @@ pciids_get_class(uint8_t class_id)
|
||||
return NULL;
|
||||
|
||||
/* Seek to class database. */
|
||||
fseek_to(pciids_f, pciids_header.class_db_offset);
|
||||
fseek(pciids_f, pciids_header.class_db_offset, SEEK_SET);
|
||||
|
||||
/* Read class entries until the ID is matched or overtaken. */
|
||||
do {
|
||||
@@ -321,7 +321,7 @@ pciids_get_subclass(uint8_t class_id, uint8_t subclass_id)
|
||||
return NULL;
|
||||
|
||||
/* Seek to subclass database. */
|
||||
fseek_to(pciids_f, pciids_header.subclass_db_offset);
|
||||
fseek(pciids_f, pciids_header.subclass_db_offset, SEEK_SET);
|
||||
|
||||
/* Read subclass entries until the ID is matched or overtaken. */
|
||||
do {
|
||||
@@ -346,7 +346,7 @@ pciids_get_progif(uint8_t class_id, uint8_t subclass_id, uint8_t progif_id)
|
||||
return NULL;
|
||||
|
||||
/* Seek to programming interface database. */
|
||||
fseek_to(pciids_f, pciids_header.progif_db_offset);
|
||||
fseek(pciids_f, pciids_header.progif_db_offset, SEEK_SET);
|
||||
|
||||
/* Read programming interface entries until the ID is matched or overtaken. */
|
||||
do {
|
||||
@@ -782,8 +782,8 @@ dump_info(uint8_t bus, uint8_t dev, uint8_t func)
|
||||
#else
|
||||
reg_val.u32 = pci_readl(bus, dev, func, 0x00);
|
||||
if (!reg_val.u32 || (reg_val.u32 == 0xffffffff)) {
|
||||
printf("\nNo device appears to exist here. (vendor:device %04X:%04X)",
|
||||
reg_val.u16[0], reg_val.u16[1]);
|
||||
printf("\nNo device appears to exist here. (vendor:device %04X:%04X)\n",
|
||||
reg_val.u16[0], reg_val.u16[1]);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -113,6 +113,10 @@ int fclose (FILE *__stream)
|
||||
{
|
||||
efi_status_t status = EFI_SUCCESS;
|
||||
uintn_t i;
|
||||
if(!__stream) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
if(__stream == stdin || __stream == stdout || __stream == stderr || (__ser && __stream == (FILE*)__ser)) {
|
||||
return 1;
|
||||
}
|
||||
@@ -128,6 +132,10 @@ int fflush (FILE *__stream)
|
||||
{
|
||||
efi_status_t status = EFI_SUCCESS;
|
||||
uintn_t i;
|
||||
if(!__stream) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
if(__stream == stdin || __stream == stdout || __stream == stderr || (__ser && __stream == (FILE*)__ser)) {
|
||||
return 1;
|
||||
}
|
||||
@@ -146,7 +154,7 @@ int __remove (const char_t *__filename, int isdir)
|
||||
efi_file_info_t info;
|
||||
uintn_t fsiz = (uintn_t)sizeof(efi_file_info_t), i;
|
||||
FILE *f = fopen(__filename, CL("r"));
|
||||
if(f == stdin || f == stdout || f == stderr || (__ser && f == (FILE*)__ser)) {
|
||||
if(!f || f == stdin || f == stdout || f == stderr || (__ser && f == (FILE*)__ser)) {
|
||||
errno = EBADF;
|
||||
return 1;
|
||||
}
|
||||
@@ -288,6 +296,10 @@ size_t fread (void *__ptr, size_t __size, size_t __n, FILE *__stream)
|
||||
{
|
||||
uintn_t bs = __size * __n, i, n;
|
||||
efi_status_t status;
|
||||
if(!__ptr || __size < 1 || __n < 1 || !__stream) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
if(__stream == stdin || __stream == stdout || __stream == stderr) {
|
||||
errno = ESPIPE;
|
||||
return 0;
|
||||
@@ -320,6 +332,10 @@ size_t fwrite (const void *__ptr, size_t __size, size_t __n, FILE *__stream)
|
||||
{
|
||||
uintn_t bs = __size * __n, n, i;
|
||||
efi_status_t status;
|
||||
if(!__ptr || __size < 1 || __n < 1 || !__stream) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
if(__stream == stdin || __stream == stdout || __stream == stderr) {
|
||||
errno = ESPIPE;
|
||||
return 0;
|
||||
@@ -355,6 +371,10 @@ int fseek (FILE *__stream, long int __off, int __whence)
|
||||
efi_guid_t infoGuid = EFI_FILE_INFO_GUID;
|
||||
efi_file_info_t info;
|
||||
uintn_t fsiz = sizeof(efi_file_info_t), i;
|
||||
if(!__stream || (__whence != SEEK_SET && __whence != SEEK_CUR && __whence != SEEK_END)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if(__stream == stdin || __stream == stdout || __stream == stderr) {
|
||||
errno = ESPIPE;
|
||||
return -1;
|
||||
@@ -399,7 +419,7 @@ int fseek (FILE *__stream, long int __off, int __whence)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
status = __stream->SetPosition(__stream, off);
|
||||
status = __stream->SetPosition(__stream, __off);
|
||||
break;
|
||||
}
|
||||
return EFI_ERROR(status) ? -1 : 0;
|
||||
@@ -410,6 +430,10 @@ long int ftell (FILE *__stream)
|
||||
uint64_t off = 0;
|
||||
uintn_t i;
|
||||
efi_status_t status;
|
||||
if(!__stream) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if(__stream == stdin || __stream == stdout || __stream == stderr) {
|
||||
errno = ESPIPE;
|
||||
return -1;
|
||||
@@ -433,6 +457,10 @@ int feof (FILE *__stream)
|
||||
efi_file_info_t info;
|
||||
uintn_t fsiz = (uintn_t)sizeof(efi_file_info_t), i;
|
||||
efi_status_t status;
|
||||
if(!__stream) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
if(__stream == stdin || __stream == stdout || __stream == stderr) {
|
||||
errno = ESPIPE;
|
||||
return 0;
|
||||
@@ -702,7 +730,7 @@ int vfprintf (FILE *__stream, const char_t *__format, __builtin_va_list args)
|
||||
#else
|
||||
ret = vsnprintf(dst, BUFSIZ, __format, args);
|
||||
#endif
|
||||
if(ret < 1 || __stream == stdin) return 0;
|
||||
if(ret < 1 || !__stream || __stream == stdin) return 0;
|
||||
for(i = 0; i < __blk_ndevs; i++)
|
||||
if(__stream == (FILE*)__blk_devs[i].bio) {
|
||||
errno = EBADF;
|
||||
|
||||
Reference in New Issue
Block a user