From 462e0e39b0da4a7185d67af6c4eca241e68dc486 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 28 Aug 2016 09:34:14 +0200 Subject: [PATCH] fix bug in is_qemu_available - before this commit, we wait on the wrong string in the kernel messages --- hermit/tools/proxy.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hermit/tools/proxy.c b/hermit/tools/proxy.c index 904987797..5fa696382 100644 --- a/hermit/tools/proxy.c +++ b/hermit/tools/proxy.c @@ -153,21 +153,28 @@ static int init_env(char *path) static int is_qemu_available(void) { - char line[2048] = ""; + char* line = (char*) malloc(2048); size_t n = 2048; + if (!line) { + fprintf(stderr, "Not enough memory\n"); + exit(1); + } + FILE* file = fopen(tmpname, "r"); if (!file) return 0; - while(getline((char**)&line, &n, file) > 0) { - if (strcmp(line, "Establish IP connection") >= 0) { + while(getline(&line, &n, file) > 0) { + if (strncmp(line, "TCP server listening.\n", 2048) == 0) { fclose(file); + free(line); return 1; } } fclose(file); + free(line); return 0; }