wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.71k stars 325 forks source link

ensure faketime can't be initialized more than once #416

Closed v-gb closed 1 year ago

v-gb commented 1 year ago

One callsite of ftpl_init wasn't protected by the if (!initialized) condition, specifically the "constructor" call:

static void ftpl_init (void) __attribute__ ((constructor));

If another "constructor" was called before this one, and that other constructor used time or filesystem functions, ftlp_init would be initialized by that other constructor, and then reinitialized by the ftpl_init constructor. At that point, confusion ensues.

wolfcw commented 1 year ago

very nice catch, thanks for fixing this!