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
..
2010-04-13 09:13:24 +02:00
2010-04-13 09:13:24 +02:00
2010-04-13 09:13:24 +02:00
2010-04-13 09:13:24 +02:00
2010-04-21 23:42:38 +02:00
2009-09-01 22:10:10 +02:00
2010-05-28 10:56:04 -04:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2009-12-14 16:42:03 -08:00
2009-08-25 13:35:54 -07:00
2010-04-04 11:08:55 -05:00
2009-12-14 16:42:03 -08:00
2010-04-13 09:13:24 +02:00
2010-06-30 21:37:36 +02:00
2010-01-17 23:06:44 +01:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-04-13 09:13:04 +02:00
2010-04-13 09:13:04 +02:00
2010-04-13 09:13:04 +02:00
2010-04-13 09:13:04 +02:00
2010-04-13 09:13:04 +02:00
2010-01-17 09:17:26 -05:00
2010-01-17 09:17:26 -05:00
2010-01-17 09:17:26 -05:00
2010-07-04 23:55:42 +02:00
2010-04-13 09:13:04 +02:00
2010-04-13 09:13:04 +02:00
2010-04-13 09:13:04 +02:00
2010-04-13 09:13:04 +02:00
2010-01-17 09:17:26 -05:00
2010-04-21 23:42:38 +02:00
2010-07-04 23:55:42 +02:00
2010-04-21 23:42:38 +02:00
2009-09-01 22:35:58 +02:00
2010-03-21 22:44:42 +01:00
2009-10-04 22:37:03 -07:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-04-13 09:13:04 +02:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-04-13 09:13:04 +02:00
2010-04-13 09:13:04 +02:00
2010-01-31 22:37:12 -08:00
2010-04-13 09:13:24 +02:00
2010-04-21 23:42:38 +02:00
2009-10-04 22:37:03 -07:00
2010-04-21 23:42:38 +02:00
2009-08-25 13:35:54 -07:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-01-31 22:37:12 -08:00
2009-12-21 21:39:59 +01:00
2010-05-05 09:48:41 +02:00
2010-06-10 12:04:42 -04:00
2010-04-13 09:13:25 +02:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2009-10-04 22:37:03 -07:00
2010-06-29 22:37:11 +02:00
2010-04-13 09:13:24 +02:00
2010-07-04 23:55:42 +02:00
2010-04-21 23:42:38 +02:00
2010-05-06 00:20:04 +02:00
2010-04-21 23:42:38 +02:00
2009-08-25 13:35:54 -07:00
2009-10-28 00:49:47 +01:00
2010-04-21 23:42:38 +02:00
2010-07-04 23:55:42 +02:00
2009-10-30 10:20:16 +09:00
2010-04-21 23:42:38 +02:00
2009-09-15 00:17:56 +02:00
2010-04-21 23:42:38 +02:00
2010-01-31 22:37:12 -08:00
2010-07-04 23:55:42 +02:00
2010-04-21 23:42:38 +02:00
2009-11-27 16:26:17 -06:00
2010-04-21 23:42:38 +02:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-04-13 09:13:26 +02:00
2010-04-13 09:13:04 +02:00
2009-12-14 16:42:03 -08:00
2010-04-19 15:29:03 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-04-13 09:13:25 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-07-04 23:55:42 +02:00
2010-01-17 09:17:26 -05:00
2010-03-21 22:44:42 +01:00
2010-04-21 23:42:38 +02:00
2010-04-13 09:13:24 +02:00
2009-11-22 23:16:28 +01:00
2009-08-25 13:35:54 -07:00
2009-07-22 22:53:44 -07:00
2010-07-04 23:55:42 +02:00
2009-10-04 22:37:03 -07:00
2010-04-07 01:11:17 -04:00
2010-04-21 23:42:38 +02:00
2010-03-12 23:06:04 +01:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-03-21 22:44:42 +01:00
2010-05-05 09:48:41 +02:00
2010-01-31 22:37:12 -08:00
2010-07-04 23:55:42 +02:00
2010-04-29 10:15:45 +02:00
2010-04-21 23:42:38 +02:00
2010-06-17 19:38:21 +05:30
2010-04-21 23:42:38 +02:00
2009-08-25 13:35:54 -07:00
2010-04-21 23:42:38 +02:00
2009-09-22 23:53:44 +02:00
2010-06-08 10:07:18 -05:00
2009-10-04 22:37:03 -07:00
2010-04-13 09:13:24 +02:00
2009-10-04 22:37:03 -07:00
2009-12-14 16:42:03 -08:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-04-13 09:13:04 +02:00
2010-06-23 23:24:11 +02:00
2010-05-15 20:22:21 +02:00
2010-04-21 23:42:38 +02:00
2010-03-21 22:44:42 +01:00
2010-07-04 23:55:42 +02:00
2010-04-13 09:13:25 +02:00
2010-04-21 23:42:38 +02:00
2010-06-17 23:12:15 +02:00
2010-04-21 23:42:38 +02:00
2010-01-31 22:37:12 -08:00
2009-08-28 17:12:39 -05:00
2010-07-04 23:55:42 +02:00
2009-10-04 22:37:03 -07:00
2009-11-22 23:16:28 +01:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2009-09-22 23:03:24 +02:00
2009-08-25 13:35:54 -07:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-04-24 21:16:57 +02:00
2010-07-04 23:55:42 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-02-12 12:31:53 -06:00
2010-06-08 17:19:22 -04:00
2010-04-13 09:13:25 +02:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-04-13 09:13:04 +02:00
2010-04-13 09:13:04 +02:00
2010-03-21 22:44:42 +01:00
2009-09-24 12:04:58 -05:00
2009-09-24 12:04:58 -05:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-04-16 16:12:39 -04:00
2010-04-13 09:13:25 +02:00
2010-07-04 23:55:42 +02:00
2009-08-22 00:20:20 +02:00
2009-11-02 16:29:04 +01:00
2010-04-21 23:42:38 +02:00
2010-07-04 23:55:42 +02:00
2010-04-21 23:42:38 +02:00
2010-07-04 23:55:42 +02:00
2010-04-21 23:42:38 +02:00
2010-06-06 08:36:28 -05:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-07-04 23:55:42 +02:00
2010-06-14 18:15:20 -05:00
2010-07-04 23:55:42 +02:00
2009-11-02 16:29:04 +01:00
2009-11-27 16:26:13 -06:00
2009-07-27 18:35:53 -05:00
2009-11-04 09:14:59 -06:00
2009-08-28 17:12:39 -05:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2009-09-04 21:57:22 +02:00
2009-09-04 21:57:22 +02:00
2010-05-17 14:44:25 -05:00
2010-07-04 23:55:42 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2009-10-31 12:13:28 +01:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-07-04 23:55:42 +02:00
2009-10-04 22:37:03 -07:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-07-01 10:26:30 +02:00
2009-09-11 10:35:58 +02:00
2010-04-13 09:13:04 +02:00
2010-07-04 23:55:42 +02:00
2010-06-30 21:37:37 +02:00
2010-01-04 08:48:15 -06:00
2010-03-21 22:44:42 +01:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-04-21 23:42:38 +02:00
2010-07-04 23:55:42 +02:00
2010-07-04 23:55:42 +02:00
2010-04-21 23:42:38 +02:00
2009-10-04 22:37:03 -07:00
2010-04-24 21:16:57 +02:00
2010-04-24 21:13:31 +02:00
2009-10-04 22:37:03 -07:00
2009-10-04 22:37:03 -07:00
2010-07-04 23:55:42 +02:00
2009-10-04 22:37:03 -07:00