Description: Fix segfaults in different executables Some executables in the package crashed upon certain command line option combinations. This patch fixes this. Author: Roland Stigge Bug-Debian: http://bugs.debian.org/715651 Bug-Debian: http://bugs.debian.org/716217 Bug-Debian: http://bugs.debian.org/716529 --- alliance-5.0-20120515.orig/asimut/src/vh_simulad.c +++ asimut/src/vh_simulad.c @@ -155,8 +155,8 @@ char **argv; arg_flg [i ] = 1; } - if ((!strcmp (argv [i], "-fixeddelay")) - || (!strcmp (argv [i], "-fd"))) + if (((!strcmp (argv [i], "-fixeddelay")) + || (!strcmp (argv [i], "-fd"))) && (argc > i + 1)) { fixdly_flg = 1; delay_mode |= BEH_DELAY_FIXED; @@ -165,8 +165,8 @@ char **argv; arg_flg [i+1] = 1; } - if ((!strcmp (argv [i], "-backdelay")) - || (!strcmp (argv [i], "-bd"))) + if (((!strcmp (argv [i], "-backdelay")) + || (!strcmp (argv [i], "-bd"))) && (argc > i + 1)) { bckdly_flg = i + 2; delay_mode |= BEH_DELAY_BACKANOTATED; @@ -221,14 +221,14 @@ char **argv; arg_flg [i] = 1; } - if (!strcmp (argv [i], "-p")) + if (!strcmp (argv [i], "-p") && (argc > i + 1)) { sscanf (argv [i+1], "%u", &max_pat); arg_flg [i ] = 1; arg_flg [i+1] = 1; } - if (!strcmp (argv [i], "-l")) + if (!strcmp (argv [i], "-l") && (argc > i + 1)) { sscanf (argv [i+1], "%u", &labelsiz); arg_flg [i ] = 1; @@ -241,7 +241,7 @@ char **argv; arg_flg [i] = 1; } - if (!strcmp (argv [i], "-stat")) + if (!strcmp (argv [i], "-stat") && (argc > i + 1)) { stat_flg = i + 2; sscanf (argv [i+1], "%u", &ref_date); @@ -264,7 +264,7 @@ char **argv; arg_flg [i+1] = 1; } - if (!strcmp (argv [i], "-inspect")) + if (!strcmp (argv [i], "-inspect") && (argc > i + 1)) { str = namealloc (argv [i+1]); pt_pains = pat_addpains (pt_pains, str, str); --- alliance-5.0-20120515.orig/m2e/src/m2e.c +++ m2e/src/m2e.c @@ -102,6 +102,8 @@ int ParseCommand(int argc,char *argv[]) switch(argv[i][1]) { case 'v': + if (argc <= i + 1) + break; i++; sscanf(argv[i],"%d",&VerboseMode); if(VerboseMode>=VMINFO) @@ -109,6 +111,8 @@ int ParseCommand(int argc,char *argv[]) break; case 'o': + if (argc <= i + 1) + break; i++; OutputName=argv[i]; if(VerboseMode>=VMINFO) --- alliance-5.0-20120515.orig/mips_asm/src/mips_y.y +++ mips_asm/src/mips_y.y @@ -92,14 +92,14 @@ char *argv []; { if (arg_flg [i] == 0) { - if (!strcmp (argv[i], "-textsize")) + if (!strcmp (argv[i], "-textsize") && argc > i + 1) { sscanf (argv[i+1], "%u", &txt_siz); arg_flg [i ] = 1; arg_flg [i+1] = 1; } - if (!strcmp (argv[i], "-datasize")) + if (!strcmp (argv[i], "-datasize") && argc > i + 1) { sscanf (argv[i+1], "%u", &dat_siz); arg_flg [i ] = 1; @@ -112,7 +112,7 @@ char *argv []; arg_flg [i] = 1 ; } - if (!strcmp (argv[i], "-symbol")) + if (!strcmp (argv[i], "-symbol") && argc > i + 1) { MPS_SYMBOL = 'y' ; symbol_fil = argv [i+1];