1From c6934455ec2337e6da7ea9fbc3486ce9beeb5d82 Mon Sep 17 00:00:00 2001
2From: OpenEmbedded <oe.patch@oe>
3Date: Wed, 11 Apr 2018 22:51:05 +0200
4Subject: [PATCH] x86-linux-setup.c: replace vfscanf() with vsscanf()
5
6klibc lacks vfscanf()
7
8Upstream-Status: Inappropriate [klibc specific]
9Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
10
11---
12 kexec/arch/i386/x86-linux-setup.c | 11 ++++++++++-
13 1 file changed, 10 insertions(+), 1 deletion(-)
14
15diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
16index 5514c1c..bdb28c6 100644
17--- a/kexec/arch/i386/x86-linux-setup.c
18+++ b/kexec/arch/i386/x86-linux-setup.c
19@@ -200,6 +200,8 @@ static int file_scanf(const char *dir, const char *file, const char *scanf_line,
20 	FILE *fp;
21 	int retno;
22 	char filename[PATH_MAX];
23+	long line_size = MAX_LINE;
24+	char *line;
25
26 	snprintf(filename, PATH_MAX, "%s/%s", dir, file);
27 	filename[PATH_MAX-1] = 0;
28@@ -210,7 +212,14 @@ static int file_scanf(const char *dir, const char *file, const char *scanf_line,
29 	}
30
31 	va_start(argptr, scanf_line);
32-	retno = vfscanf(fp, scanf_line, argptr);
33+
34+	line = xmalloc(sizeof(line) * line_size);
35+	while(fgets(line, sizeof(line), fp) != NULL ) {
36+		line_size += MAX_LINE;
37+		line = xrealloc(line,line_size);
38+	}
39+	retno = vsscanf(line, scanf_line, argptr);
40+
41 	va_end(argptr);
42
43 	fclose(fp);
44