Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 1 | From c6934455ec2337e6da7ea9fbc3486ce9beeb5d82 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 2 | From: OpenEmbedded <oe.patch@oe> |
| 3 | Date: Wed, 11 Apr 2018 22:51:05 +0200 |
| 4 | Subject: [PATCH] x86-linux-setup.c: replace vfscanf() with vsscanf() |
| 5 | |
| 6 | klibc lacks vfscanf() |
| 7 | |
| 8 | Upstream-Status: Inappropriate [klibc specific] |
| 9 | Signed-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 | |
| 15 | diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 16 | index 5514c1c..bdb28c6 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 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); |