Changeset 1796 for zzuf


Ignore:
Timestamp:
Jul 10, 2007, 1:51:49 AM (13 years ago)
Author:
Sam Hocevar
Message:
  • Do not clobber LD_PRELOAD, patch by Sami Liedes. Heavily rewritten.
Location:
zzuf/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/AUTHORS

    r1691 r1796  
    88 Clément Stenac <zorglub#diwi:org> (pread)
    99 Dominik Kuhlen <dominik.kuhlen#gmit-gmbh:de> (recvfrom)
    10 
     10 Sami Liedes <sliedes#cc:hut:fi> (LD_PRELOAD conservation)
  • zzuf/trunk/src/zzuf.c

    r1791 r1796  
    910910
    911911#if defined HAVE_FORK
    912     libpath = malloc(len + strlen("/.libs/" FILENAME EXTRAINFO) + 1);
     912    /* Meaningless but makes sure there is space for everything */
     913    libpath = malloc(len + strlen(LIBDIR "/.libs/" FILENAME EXTRAINFO) + 1);
    913914    strcpy(libpath, opts->oldargv[0]);
    914915
     916    /* Replace "/path/binaryname" with "/path/.libs/libzzuf.$(EXT)"
     917     *     and "binaryname" with ".libs/libzzuf.$(EXT)"
     918     * Write the result in libpath. */
    915919    tmp = strrchr(libpath, '/');
    916920    strcpy(tmp ? tmp + 1 : libpath, ".libs/" FILENAME);
     921
    917922    ret = access(libpath, R_OK);
    918 
    919     strcpy(tmp ? tmp + 1 : libpath, ".libs/" FILENAME EXTRAINFO);
    920     if(ret == 0)
    921         setenv(PRELOAD, libpath, 1);
    922     else
    923         setenv(PRELOAD, LIBDIR "/" FILENAME EXTRAINFO, 1);
     923    if(ret < 0)
     924        strcpy(libpath, LIBDIR "/" FILENAME);
     925
     926    /* OSF1 only */
     927    strcat(libpath, EXTRAINFO);
     928
     929    /* Do not clobber previous LD_PRELOAD values */
     930    tmp = getenv(PRELOAD);
     931    if(tmp && *tmp)
     932    {
     933        char *bigbuf = malloc(strlen(tmp) + strlen(libpath) + 2);
     934        sprintf(bigbuf, "%s:%s", tmp, libpath);
     935        free(libpath);
     936        libpath = bigbuf;
     937    }
     938
     939    setenv(PRELOAD, libpath, 1);
    924940    free(libpath);
    925941
Note: See TracChangeset for help on using the changeset viewer.