u-boot-brain/board/freescale/common
Wolfgang Denk 54841ab50c Make sure that argv[] argument pointers are not modified.
The hush shell dynamically allocates (and re-allocates) memory for the
argument strings in the "char *argv[]" argument vector passed to
commands.  Any code that modifies these pointers will cause serious
corruption of the malloc data structures and crash U-Boot, so make
sure the compiler can check that no such modifications are being done
by changing the code into "char * const argv[]".

This modification is the result of debugging a strange crash caused
after adding a new command, which used the following argument
processing code which has been working perfectly fine in all Unix
systems since version 6 - but not so in U-Boot:

int main (int argc, char **argv)
{
	while (--argc > 0 && **++argv == '-') {
/* ====> */	while (*++*argv) {
			switch (**argv) {
			case 'd':
				debug++;
				break;
			...
			default:
				usage ();
			}
		}
	}
	...
}

The line marked "====>" will corrupt the malloc data structures and
usually cause U-Boot to crash when the next command gets executed by
the shell.  With the modification, the compiler will prevent this with
an
	error: increment of read-only location '*argv'

N.B.: The code above can be trivially rewritten like this:

	while (--argc > 0 && **++argv == '-') {
		char *arg = *argv;
		while (*++arg) {
			switch (*arg) {
			...

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2010-07-04 23:55:42 +02:00
..
cadmus.c rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
cadmus.h Move the MPC8541/MPC8555/MPC8548 CDS board under board/freescale. 2007-12-11 22:34:20 -06:00
cds_pci_ft.c FSL: Clean up board/freescale/common/Makefile 2008-03-26 11:43:04 -05:00
cds_via.c FSL: Clean up board/freescale/common/Makefile 2008-03-26 11:43:04 -05:00
eeprom.h Move the MPC8541/MPC8555/MPC8548 CDS board under board/freescale. 2007-12-11 22:34:20 -06:00
fsl_diu_fb.c fsl_diu_fb.c: fix build warnings 2010-05-17 23:34:18 +02:00
fsl_diu_fb.h Move 8610 DIU interface structure definitions to header file. 2007-11-20 15:00:53 -06:00
fsl_logo_bmp.c FSL: Add a freescale bitmap logo. 2007-11-07 14:09:08 -06:00
Makefile Convert Makefiles from COBJS-${} to COBJS-$() 2010-05-26 22:27:38 +02:00
ngpixis.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
ngpixis.h fsl: rename 'dma' to 'brdcfg1' in the ngPIXIS structure 2010-05-30 11:10:32 -05:00
pixis.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
pq-mds-pib.c ppc/85xx: Add PIB/ATM support for MPC8569mds 2010-01-25 22:13:26 -06:00
pq-mds-pib.h mpc83xx: Split PIB init code from pci.c and add Qoc3 ATM card support 2007-08-16 23:12:11 -05:00
sgmii_riser.c fsl: Remove unnecessary debug printfs 2009-03-09 17:46:10 -05:00
sgmii_riser.h Fixup SGMII PHY ids in the device tree 2009-02-16 18:05:54 -06:00
sys_eeprom.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
via.h Move the MPC8541/MPC8555/MPC8548 CDS board under board/freescale. 2007-12-11 22:34:20 -06:00