[PC-BSD Commits] r20336 - pcbsd/current/src-sh/pbi-manager/wrapper

svn at pcbsd.org svn at pcbsd.org
Fri Nov 30 12:04:16 PST 2012


Author: kris
Date: 2012-11-30 20:04:16 +0000 (Fri, 30 Nov 2012)
New Revision: 20336

Modified:
   pcbsd/current/src-sh/pbi-manager/wrapper/main.c
Log:

Fix an issue with the PBI binary wrapper,
now use execv() instead of system(). This lets us
properly parse arguments which may have ' or " in them



Modified: pcbsd/current/src-sh/pbi-manager/wrapper/main.c
===================================================================
--- pcbsd/current/src-sh/pbi-manager/wrapper/main.c	2012-11-30 20:02:58 UTC (rev 20335)
+++ pcbsd/current/src-sh/pbi-manager/wrapper/main.c	2012-11-30 20:04:16 UTC (rev 20336)
@@ -20,7 +20,6 @@
     char newpath[MAX_SIZE];
     char newlibdir[MAX_SIZE];
     char newtarget[MAX_SIZE];
-    char newargs[ARG_MAX];
 
     // Setup working variables
     char bfile[PATH_MAX];
@@ -136,41 +135,15 @@
     setenv("LD_LIBRARY_PATH", newlibdir, 1);
     setenv("LD_32_LIBRARY_PATH", newlibdir, 1);
 
-    // Get the arguments
-    if (argc > 1)
-    {
-      int count;
-      for (count = 1; count < argc; count++)
-      {
-           if ( ARG_MAX < (strlen(newargs) + strlen(argv[count]) + 4 ) ) {
-              printf("Max args exceeded!");
-              exit(2);
-           }
-           if ( MAX_SIZE < (strlen(newargs) + strlen(argv[count]) + 4 ) ) {
-              printf("MAX_SIZE exceeded!");
-              exit(2);
-           }
-           strcat(newargs, "'");
-           strcat(newargs, argv[count]);
-           strcat(newargs, "' ");
-      }
-    } 
-
-    if ( MAX_SIZE < (strlen(newtarget) + strlen(progdir) + strlen(progtarget) + strlen(newargs) + 3  ) ) {
-       printf("MAX_SIZE exceeded!");
-       exit(2);
-    }
-
     // Set the target
     strncpy(newtarget, progdir, strlen(progdir) -1 );
     strcat(newtarget, "/");
     strncat(newtarget, progtarget, strlen(progtarget) -1 );
-    strcat(newtarget, " ");
-    strcat(newtarget, newargs);
 
     // Enable for debug
     //printf( "PATH: %s\n", newpath);
     //printf( "LDPATH: %s\n", newlibdir);
     //printf( "Running: %s \n", newtarget);
-    return system(newtarget);
+    //return system(newtarget);
+    return execv(newtarget, argv);
 }



More information about the Commits mailing list