Sat Dec 05 06:41:48 2009: Request 52407 was acted upon.
Transaction: Correspondence added by SMUELLER
       Queue: PAR-Packer
     Subject: pp creates par-<user>/ in /, not /tmp
   Broken in: 1.001
    Severity: Normal
       Owner: RSCHUPP
  Requestors: sw...@cpan.org
      Status: open
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=52407 >


Hi,

On Fri Dec 04 11:24:50 2009, RSCHUPP wrote:
> I know what's goin' on: does a C construct like
> 
> sprintf(stmpdir, "%s other %stuff", stmpdir, ...);
> 
> (in mlydr/mktempdir.c) ring a bell? 
> The big question is: this code has been in there for ages -
> why does it break now?

Quite honestly... I have no good idea. Looking at the differences to
0.991, there is some change to myldr/mktempdir.c:

--- myldr/mktmpdir.c    (revision 7467)
+++ myldr/mktmpdir.c    (local)
@@ -160,6 +160,29 @@
     if (progname == NULL)
         progname = argv[0];

+    /* If invoked as "/usr/bin/parl foo.par myscript.pl" then progname
should
+     * be ".../parl", and we don't want to base our checksum on that, but
+     * rather on "foo.par".
+     */
+    {
+#ifdef WIN32
+#define STREQ(a,b) (strcasecmp(a,b) == 0)
+#else
+#define STREQ(a,b) (strcmp(a,b) == 0)
+#endif
+       int prog_len = strlen(progname);
+       int parl_len = strlen(PARL_EXE);
+
+       if (prog_len >= parl_len
+           && STREQ(progname + prog_len - parl_len, PARL_EXE)
+           && (prog_len == parl_len || progname[prog_len - parl_len -
1] == dir_sep[0])
+           && argv[1]
+           && strlen(argv[1]) >= 4
+           && STREQ(argv[1] + strlen(argv[1]) - 4, ".par"))
+               progname = argv[1];
+#undef STREQ
+    }
+
     if ( !par_env_clean() && (f = open( progname, O_RDONLY |
OPEN_O_BINARY ))) {
         lseek(f, -18, 2);
         read(f, buf, 6);
@@ -176,6 +199,7 @@
         }
         else {
             /* "$TEMP/par-$USER/cache-$SHA1" */
+           lseek(f, 0, 0);
             sha_init( &sha_info );
             while( ( j = read( f, buf, sizeof( buf ) ) ) > 0 )
             {

Reply via email to