Control: tags -1 + pending

On 04/01/2014 11:22 AM, Antonio Terceiro wrote:
> Package: faketime
> Version: 0.9.5-1
> Severity: important
> Tags: patch
> 
> Hello,
> 
> There is logic error in src/faketime.c that causes faketime to damage
> the contents of an existing LD_PRELOAD environment variable. The
> attached patch fixes it for me:
> 
> terceiro@homer:faketime-0.9.5$ dpkg-query --show faketime
> faketime  0.9.5-1
> terceiro@homer:faketime-0.9.5$ tsocks faketime +1day date
> ERROR: ld.so: object '/usr/lib/libtsocks.s' from LD_PRELOAD cannot be 
> preloaded: ignored.
> Seg Mar 31 18:32:01 BRT 2014
> terceiro@homer:faketime-0.9.5$ tsocks ./src/faketime +1day date
> Ter Abr  1 18:32:05 BRT 2014

i can confirm that this is a bug, but i don't think that the offered fix
is correct -- while it fixes the case where there's another LD_PRELOAD,
it breaks the case where there is no LD_PRELOAD at all (it also ends up
segfaulting on the test suite).

I plan to use the attached patch instead.

thanks for finding this bug, Antonio!

        --dkg
Description: fix handling of existing LD_PRELOAD in environment
 This patch fixes handling of the string length when composing an updated
 LD_PRELOAD that includes both the previous value and the entry for
 libeatmydata.
Author: Antonio Terceiro <[email protected]>

--- faketime-0.9.5.orig/src/faketime.c
+++ faketime-0.9.5/src/faketime.c
@@ -311,7 +311,7 @@ int main (int argc, char **argv)
         ftpl_path = PREFIX "/$LIB/faketime/libfaketime.so.1";
 #endif
       }
-      len = (ld_preload)?strlen(ld_preload):0 + 2 + strlen(ftpl_path);
+      len = ((ld_preload)?strlen(ld_preload) + 1: 0) + 1 + strlen(ftpl_path);
       ld_preload_new = malloc(len);
       snprintf(ld_preload_new, len ,"%s%s%s", (ld_preload)?ld_preload:"",
               (ld_preload)?":":"", ftpl_path);

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to