]> diplodocus.org Git - nmh/commitdiff
Migrated show_content_aux2() to argsplit().
authorDavid Levine <levinedl@acm.org>
Wed, 19 Feb 2014 03:26:52 +0000 (21:26 -0600)
committerDavid Levine <levinedl@acm.org>
Wed, 19 Feb 2014 03:26:52 +0000 (21:26 -0600)
uip/mhshowsbr.c

index 601830ca9883e123fa6ba845afc4fb8f3de14bd5..a4a2029f149fa001317e3433ba5b572598b1249b 100644 (file)
@@ -358,8 +358,8 @@ show_content_aux2 (CT ct, int serial, int alternate, char *cracked, char *buffer
                    int fd, int xlist, int xpause, int xstdin, int xtty)
 {
     pid_t child_id;
                    int fd, int xlist, int xpause, int xstdin, int xtty)
 {
     pid_t child_id;
-    int i;
-    char *vec[4];
+    int i, vecp;
+    char **vec, *file;
 
     if (debugsw || cracked) {
        fflush (stdout);
 
     if (debugsw || cracked) {
        fflush (stdout);
@@ -411,10 +411,8 @@ show_content_aux2 (CT ct, int serial, int alternate, char *cracked, char *buffer
        }
     }
 
        }
     }
 
-    vec[0] = "/bin/sh";
-    vec[1] = "-c";
-    vec[2] = buffer;
-    vec[3] = NULL;
+    vec = argsplit(buffer, &file, &vecp);
+    vec[vecp++] = NULL;
 
     fflush (stdout);
 
 
     fflush (stdout);
 
@@ -432,13 +430,15 @@ show_content_aux2 (CT ct, int serial, int alternate, char *cracked, char *buffer
            if (!xstdin)
                dup2 (fd, 0);
            close (fd);
            if (!xstdin)
                dup2 (fd, 0);
            close (fd);
-           execvp ("/bin/sh", vec);
+           execvp (file, vec);
            fprintf (stderr, "unable to exec ");
            perror ("/bin/sh");
            _exit (-1);
            /* NOTREACHED */
 
        default:
            fprintf (stderr, "unable to exec ");
            perror ("/bin/sh");
            _exit (-1);
            /* NOTREACHED */
 
        default:
+           arglist_free(file, vec);
+
            if (!serial) {
                ct->c_pid = child_id;
                if (xtty)
            if (!serial) {
                ct->c_pid = child_id;
                if (xtty)