Skip to content

Commit 3fed220

Browse files
verify disc is iso9660 before mount, fix over-eager updxell
1 parent 6b1743d commit 3fed220

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

libxenon/drivers/iso9660/iso9660.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,35 @@ static const devoptab_t dotab_iso9660 =
11121112
NULL // device data
11131113
};
11141114

1115+
static int verify_iso9660_disc(const DISC_INTERFACE *di)
1116+
{
1117+
char sector_data[2048];
1118+
int is_joliet, i, blk = 0;
1119+
1120+
/* Check for joliet extensions */
1121+
is_joliet = 0;
1122+
for (i=1; i<=3; i++) {
1123+
blk = di->readSectors(16, 1, sector_data);
1124+
if (blk < 0) return blk;
1125+
if (memcmp(sector_data, "\02CD001", 6) == 0) {
1126+
is_joliet = isjoliet(sector_data+88);
1127+
if (is_joliet) break;
1128+
}
1129+
}
1130+
1131+
/* If that failed, go after standard/RockRidge ISO */
1132+
if (!is_joliet) {
1133+
/* Grab and check the volume descriptor */
1134+
blk = di->readSectors(16, 1, sector_data);
1135+
if (blk < 0) return i;
1136+
if (memcmp(sector_data, "\01CD001", 6) != 0) {
1137+
return -1;
1138+
}
1139+
}
1140+
1141+
return 0;
1142+
}
1143+
11151144
bool ISO9660_Mount(const char* name, const DISC_INTERFACE *disc_interface)
11161145
{
11171146
char *nameCopy;
@@ -1126,6 +1155,10 @@ bool ISO9660_Mount(const char* name, const DISC_INTERFACE *disc_interface)
11261155

11271156
if (!disc_interface->isInserted())
11281157
return false;
1158+
1159+
// Verify that it's actually an ISO9660 formatted disc and not another format or not inserted
1160+
if (verify_iso9660_disc(disc_interface) != 0)
1161+
return false;
11291162

11301163
sprintf(devname, "%s:", name);
11311164
if (FindDevice(devname) >= 0)

libxenon/drivers/xb360/xb360.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <string.h>
88
#include <stdio.h>
99
#include <stdlib.h>
10+
#include <sys/stat.h>
1011
#include <pci/io.h>
1112
#include <time/time.h>
1213
#include <xenon_nand/xenon_sfcx.h>
@@ -362,6 +363,13 @@ int updateXeLL(char *path)
362363
FILE *f;
363364
int i, j, k, status, startblock, current, offsetinblock, blockcnt, filelength;
364365
unsigned char *updxell, *user, *spare;
366+
struct stat s;
367+
368+
memset(&s, 0, sizeof(struct stat));
369+
stat(path, &s);
370+
long size = s.st_size;
371+
if (size <= 0)
372+
return -1; //Invalid Filesize
365373

366374
/* Check if updxell.bin is present */
367375
f = fopen(path, "rb");

libxenon/drivers/xenon_nand/xenon_sfcx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ int try_rawflash(char *filename)
560560
{
561561
struct stat s;
562562

563+
memset(&s, 0, sizeof(struct stat));
563564
stat(filename, &s);
564565
long size = s.st_size;
565566
if (size <= 0)

0 commit comments

Comments
 (0)