From 45f79cb279d4f00f1c0be33e101ffc2c1c1fdf8d Mon Sep 17 00:00:00 2001 From: Michael Karcher Date: Wed, 24 Mar 2010 17:55:04 +0000 Subject: Fix handling of empty dmidecode output Corresponding to flashrom svn r973. Signed-off-by: Michael Karcher Acked-by: Carl-Daniel Hailfinger --- dmi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'dmi.c') diff --git a/dmi.c b/dmi.c index 716a7c6..d9f307f 100644 --- a/dmi.c +++ b/dmi.c @@ -56,11 +56,14 @@ static char *get_dmi_string(const char *string_name) printf_debug("DMI pipe open error\n"); return NULL; } - if (!fgets(answerbuf, DMI_MAX_ANSWER_LEN, dmidecode_pipe) && - ferror(dmidecode_pipe)) { - printf_debug("DMI pipe read error\n"); - pclose(dmidecode_pipe); - return NULL; + if (!fgets(answerbuf, DMI_MAX_ANSWER_LEN, dmidecode_pipe)) { + if(ferror(dmidecode_pipe)) { + printf_debug("DMI pipe read error\n"); + pclose(dmidecode_pipe); + return NULL; + } else { + answerbuf[0] = 0; /* Hit EOF */ + } } /* Toss all output above DMI_MAX_ANSWER_LEN away to prevent deadlock on pclose. */ -- cgit v1.1