summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinoru Usui <usui@mxm.nes.nec.co.jp>2011-06-29 13:33:22 +0900
committerEric Blake <eblake@redhat.com>2011-06-29 09:12:38 -0600
commit72882bc9d9c5f4e0f2593b359d4561accb177296 (patch)
tree4b02918422190c6c2f07317af532cfc69c62b9f3
parentEnsure that EOF is dispatched to the stream callback (diff)
downloadlibvirt-72882bc9d9c5f4e0f2593b359d4561accb177296.tar.gz
libvirt-72882bc9d9c5f4e0f2593b359d4561accb177296.tar.bz2
libvirt-72882bc9d9c5f4e0f2593b359d4561accb177296.zip
sysinfo: fix illegal NULL return
If virSysinfoParse{BIOS,System,Processor,Memory}() can't find newline('\n'), these return NULL. This patch fixes this. Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
-rw-r--r--src/util/sysinfo.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index d32f7f00e..f4edde9f4 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -132,6 +132,10 @@ virSysinfoParseBIOS(char *base, virSysinfoDefPtr ret)
{
char *cur, *eol = NULL;
+ if ((cur = strstr(base, "BIOS Information")) == NULL)
+ return base;
+
+ base = cur;
if ((cur = strstr(base, "Vendor: ")) != NULL) {
cur += 8;
eol = strchr(cur, '\n');
@@ -157,7 +161,7 @@ virSysinfoParseBIOS(char *base, virSysinfoDefPtr ret)
goto no_memory;
}
- return eol ? eol + 1 : NULL;
+ return base + strlen("BIOS Information");
no_memory:
return NULL;
@@ -168,9 +172,10 @@ virSysinfoParseSystem(char *base, virSysinfoDefPtr ret)
{
char *cur, *eol = NULL;
- if ((base = strstr(base, "System Information")) == NULL)
- return 0;
+ if ((cur = strstr(base, "System Information")) == NULL)
+ return base;
+ base = cur;
if ((cur = strstr(base, "Manufacturer: ")) != NULL) {
cur += 14;
eol = strchr(cur, '\n');
@@ -215,7 +220,7 @@ virSysinfoParseSystem(char *base, virSysinfoDefPtr ret)
goto no_memory;
}
- return eol ? eol + 1 : NULL;
+ return base + strlen("System Information");
no_memory:
return NULL;
@@ -314,9 +319,7 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
goto no_memory;
}
- if (!eol)
- break;
- base = eol + 1;
+ base += strlen("Processor Information");
}
return base;
@@ -415,9 +418,7 @@ virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
}
next:
- if (!eol)
- break;
- base = eol + 1;
+ base += strlen("Memory Device");
}
return base;