Update of /cvsroot/blob/blob/src
In directory usw-pr-cvs1:/tmp/cvs-serv3467
Modified Files:
Tag: blob_1_0_9_hack
main.c
Log Message:
add size check before we try to write too large images to the flash
Index: main.c
===================================================================
RCS file: /cvsroot/blob/blob/src/main.c,v
retrieving revision 1.1.1.1.2.12
retrieving revision 1.1.1.1.2.13
diff -u -r1.1.1.1.2.12 -r1.1.1.1.2.13
--- main.c 2001/07/26 00:33:03 1.1.1.1.2.12
+++ main.c 2001/07/31 21:45:56 1.1.1.1.2.13
@@ -273,12 +273,14 @@
{
u32 startAddress = 0;
tBlockType block;
- int numBytes = 0;;
+ int numBytes = 0;
+ int maxSize = 0;
if(MyStrNCmp(commandline, "blob", 4) == 0) {
startAddress = BLOB_RAM_BASE;
block = blBlob;
numBytes = blob_status.blobSize;
+ maxSize = BLOB_LEN;
if(blob_status.blobType == fromFlash) {
SerialOutputString("*** No blob downloaded\n");
@@ -290,6 +292,7 @@
startAddress = KERNEL_RAM_BASE;
block = blKernel;
numBytes = blob_status.kernelSize;
+ maxSize = KERNEL_LEN;
if(blob_status.kernelType == fromFlash) {
SerialOutputString("*** No kernel downloaded\n");
@@ -301,6 +304,7 @@
startAddress = RAMDISK_RAM_BASE;
block = blRamdisk;
numBytes = blob_status.ramdiskSize;
+ maxSize = INITRD_LEN;
if(blob_status.ramdiskType == fromFlash) {
SerialOutputString("*** No ramdisk downloaded\n");
@@ -312,6 +316,17 @@
SerialOutputString("*** Don't know how to flash \"");
SerialOutputString(commandline);
SerialOutputString("\"\n");
+ return;
+ }
+
+ if(numBytes > maxSize) {
+ SerialOutputString("*** Downloaded image too large for flash area\n");
+ SerialOutputString("*** (0x");
+ SerialOutputHex(numBytes);
+ SerialOutputString(" downloaded, maximum size is 0x");
+ SerialOutputHex(maxSize);
+ SerialOutputString(" bytes)\n");
+
return;
}
|