From 2e15825b4821e1409635aa9b5836cedcb65c670c Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Fri, 11 Oct 2002 23:48:15 +0000 Subject: [PATCH] read bug fix from Khali git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1557 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/detect/dmidecode.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/prog/detect/dmidecode.c b/prog/detect/dmidecode.c index 975f9671..e372e14c 100644 --- a/prog/detect/dmidecode.c +++ b/prog/detect/dmidecode.c @@ -644,7 +644,14 @@ static void dmi_table(int fd, u32 base, int len, int num) struct dmi_header *dm; u8 *data; int i=0; + int r=0, r2=0; + if(len==0) + { + fputs("dmi: no data\n", stderr); + return; + } + if(buf==NULL) { perror("dmi: malloc"); @@ -655,7 +662,9 @@ static void dmi_table(int fd, u32 base, int len, int num) perror("dmi: lseek"); return; } - if(read(fd, buf, len)!=len) + while(r2!=len && (r=read(fd, buf+r2, len-r2))!=0) + r2+=r; + if(r==0) { perror("dmi: read"); return;