From 2b6d251dec7854902adfaf45e461bb29ce753312 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 22 Aug 2016 23:53:01 +0200 Subject: [PATCH] Fix a fun bug where, every now again, ego would get its temporary files mangled and generate invalid calls to the optimisers. Previously ego would generate a temporary file template that looked like /tmp/ego.A.BB.XXXXXX, call mktemp() on it to randomise the XXXXXX, and then replace A and BB with data. However, it used strrchr to find the A and B. Which would fine, except when mktemp produced an A or a B in the randomised part... This code was written on 4 March 1991. I was 16. --- util/ego/em_ego/em_ego.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 5475618b1..60a99ea5d 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -418,8 +418,9 @@ int main(int argc, char* argv[]) (void)strcat(pdump, "/ego.pd.XXXXXX"); (void)mktemp(pdump); - (void)strcat(tmpbufs[0], "/ego.A.BB.XXXXXX"); + (void)strcat(tmpbufs[0], "/ego.XXXXXX"); (void)mktemp(tmpbufs[0]); + (void)strcat(tmpbufs[0], ".A.BB"); for (i = 2 * NTEMPS - 1; i >= 1; i--) { (void)strcpy(tmpbufs[i], tmpbufs[0]);