mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-07-16 16:27:27 +00:00
d357cc7df0
The POSIX standard http://pubs.opengroup.org/onlinepubs/009695399/functions/fgets.html states: If the stream is at end-of-file ... fgets() shall return a null pointer... If a read error occurs ... fgets() shall return a null pointer... Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
28 lines
704 B
Diff
28 lines
704 B
Diff
--- a/kexec/arch/i386/x86-linux-setup.c
|
|
+++ b/kexec/arch/i386/x86-linux-setup.c
|
|
@@ -176,6 +176,8 @@ static int file_scanf(const char *dir, c
|
|
FILE *fp;
|
|
int retno;
|
|
char filename[PATH_MAX];
|
|
+ long line_size = MAX_LINE;
|
|
+ char *line;
|
|
|
|
snprintf(filename, PATH_MAX, "%s/%s", dir, file);
|
|
filename[PATH_MAX-1] = 0;
|
|
@@ -186,7 +188,14 @@ static int file_scanf(const char *dir, c
|
|
}
|
|
|
|
va_start(argptr, scanf_line);
|
|
- retno = vfscanf(fp, scanf_line, argptr);
|
|
+
|
|
+ line = xmalloc(sizeof(line) * line_size);
|
|
+ while(fgets(line, sizeof(line), fp) != NULL ) {
|
|
+ line_size += MAX_LINE;
|
|
+ line = xrealloc(line,line_size);
|
|
+ }
|
|
+ retno = vsscanf(line, scanf_line, argptr);
|
|
+
|
|
va_end(argptr);
|
|
|
|
fclose(fp);
|