[libvirt] [PATCH] sysinfo: fix illegal NULL return
Eric Blake
eblake at redhat.com
Wed Jun 29 15:14:15 UTC 2011
On 06/28/2011 10:33 PM, Minoru Usui wrote:
> If virSysinfoParse{BIOS,System,Processor,Memory}()
> can't find newline('\n'), these return NULL.
> This patch fixes this.
>
> Signed-off-by: Minoru Usui <usui at mxm.nes.nec.co.jp>
> ---
> src/util/sysinfo.c | 23 +++++++++++++----------
> 1 files changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
> index d32f7f0..a6e525b 100644
> --- a/src/util/sysinfo.c
> +++ b/src/util/sysinfo.c
> @@ -131,7 +131,12 @@ static char *
> virSysinfoParseBIOS(char *base, virSysinfoDefPtr ret)
> {
> char *cur, *eol = NULL;
> + char *tmp_base;
>
> + if ((tmp_base = strstr(base, "BIOS Information")) == NULL)
> + return base;
> +
> + base = tmp_base;
> if ((cur = strstr(base, "Vendor: ")) != NULL) {
I simplified this to use one less local variable.
ACK and push.
diff --git i/src/util/sysinfo.c w/src/util/sysinfo.c
index a6e525b..f4edde9 100644
--- i/src/util/sysinfo.c
+++ w/src/util/sysinfo.c
@@ -131,12 +131,11 @@ static char *
virSysinfoParseBIOS(char *base, virSysinfoDefPtr ret)
{
char *cur, *eol = NULL;
- char *tmp_base;
- if ((tmp_base = strstr(base, "BIOS Information")) == NULL)
+ if ((cur = strstr(base, "BIOS Information")) == NULL)
return base;
- base = tmp_base;
+ base = cur;
if ((cur = strstr(base, "Vendor: ")) != NULL) {
cur += 8;
eol = strchr(cur, '\n');
@@ -172,12 +171,11 @@ static char *
virSysinfoParseSystem(char *base, virSysinfoDefPtr ret)
{
char *cur, *eol = NULL;
- char *tmp_base;
- if ((tmp_base = strstr(base, "System Information")) == NULL)
+ if ((cur = strstr(base, "System Information")) == NULL)
return base;
- base = tmp_base;
+ base = cur;
if ((cur = strstr(base, "Manufacturer: ")) != NULL) {
cur += 14;
eol = strchr(cur, '\n');
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110629/38c4c0d1/attachment-0001.sig>
More information about the libvir-list
mailing list