used workarounds to make it compilable with non-C99 compilers
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 26 Dec 2003 00:48:26 +0000 (00:48 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 26 Dec 2003 00:48:26 +0000 (00:48 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@495 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/tests/escaperoot.c
util-vserver/tests/forkbomb.c
util-vserver/tests/testlimit.c
util-vserver/tests/testopenf.c

index 4a64433..1e56544 100644 (file)
@@ -51,8 +51,9 @@ static void test1()
        if (chroot ("dummy_dir")==-1){
                fprintf (stderr,"Can't chroot into dummy_dir (%s)\n",strerror(errno));
        }else{
+               int i;
                // Try to chdir into the real root
-               for (int i=0; i<1000; i++) chdir("..");
+               for (i=0; i<1000; i++) chdir("..");
                print_pwd();
                if (execl ("/bin/sh","/bin/sh",NULL)==-1){
                        fprintf (stderr,"execl /bin/sh failed (%s)\n",strerror(errno));
@@ -78,8 +79,9 @@ static void test2()
                fprintf (stderr,"Can't fchdir to the current directory (%s)\n"
                        ,strerror(errno));
        }else{
+               int i;
                // Try to chdir into the real root
-               for (int i=0; i<1000; i++) chdir("..");
+               for (i=0; i<1000; i++) chdir("..");
                print_pwd();
                if (execl ("/bin/sh","/bin/sh",NULL)==-1){
                        fprintf (stderr,"execl /bin/sh failed (%s)\n",strerror(errno));
index af18b3f..61b5a8e 100644 (file)
@@ -64,7 +64,8 @@ int main (int argc, char *argv[])
                        "           exits, then the parent start a new one\n"
                        );
        }else{
-               MODE mode;
+               MODE    mode;
+               int     i;
                if (strcmp(argv[3],"sleep")==0){
                        mode = MODE_SLEEP;
                }else if (strcmp(argv[3],"loop")==0){
@@ -77,13 +78,14 @@ int main (int argc, char *argv[])
                        fprintf (stderr,"Invalid mode\n");
                        exit (-1);
                }
-               for (int i=0; i<atoi(argv[2]); i++){
+               for (i=0; i<atoi(argv[2]); i++){
                        if (fork()==0){
                                if (setuid (i+1)==-1){
                                        fprintf (stderr,"Can't setuid to uid %d (%s)\n",i+1
                                                ,strerror(errno));
                                }else{
-                                       for (int j=0; j<atoi(argv[1]); j++){
+                                       int j;
+                                       for (j=0; j<atoi(argv[1]); j++){
                                                forkbomb_userfork (mode);
                                        }
                                        if (mode == MODE_FORK || mode == MODE_FORKSHELL){
index c5bfda1..7d90a1f 100644 (file)
@@ -31,7 +31,8 @@ int main (int argc, char *argv[])
        }else{
                int nbproc = atoi(argv[1]);
                int size   = atoi(argv[2]);
-               for (int i=0; i<nbproc; i++){
+               int i;
+               for (i=0; i<nbproc; i++){
                        if (fork()==0){
                                void *pt = malloc(size);
                                if (pt == NULL){
index 12c0078..38ce70c 100644 (file)
@@ -31,7 +31,8 @@ int main (int argc, char *argv[])
        }else{
                int nbproc = atoi(argv[1]);
                int nbopen = atoi(argv[2]);
-               for (int i=0; i<nbproc; i++){
+               int i;
+               for (i=0; i<nbproc; i++){
                        if (fork()==0){
                                int j;
                                for (j=0; j<nbopen; j++){